Giter Site home page Giter Site logo

divineomega / password_exposed Goto Github PK

View Code? Open in Web Editor NEW
215.0 11.0 34.0 169 KB

๐Ÿ”’ Password Exposed Helper Function - Check if a password has been exposed in a data breach.

License: GNU Lesser General Public License v3.0

PHP 100.00%
data-breach passwords security php helper-functions

password_exposed's Introduction

๐Ÿ”’ Password Exposed Helper Function

This PHP package provides a password_exposed helper function, that uses the haveibeenpwned.com API to check if a password has been exposed in a data breach.

Build Status StyleCI

Installation

The password_exposed package can be easily installed using Composer. Just run the following command from the root of your project.

composer require "divineomega/password_exposed"

If you have never used the Composer dependency manager before, head to the Composer website for more information on how to get started.

Usage

To check if a password has been exposed in a data breach, just pass it to the password_exposed method.

Here is a basic usage example:

switch(password_exposed('hunter2')) {

    case PasswordStatus::EXPOSED:
        // Password has been exposed in a data breach.
        break;

    case PasswordStatus::NOT_EXPOSED:
        // Password has not been exposed in a known data breach.
        break;

    case PasswordStatus::UNKNOWN:
        // Unable to check password due to an API error.
        break;
}

If you prefer to avoid using helper functions, the following syntax is also available.

$passwordStatus = (new PasswordExposedChecker())->passwordExposed($password);

SHA1 Hash

You can also supply the SHA1 hash instead of the plain text password, by using the following method.

$passwordStatus = (new PasswordExposedChecker())->passwordExposedByHash($hash);

or...

$passwordStatus = password_exposed_by_hash($hash);

password_exposed's People

Contributors

caugner avatar divineomega avatar jameswilddev avatar nicklog avatar paragonie-scott avatar paragonie-security avatar peter279k avatar tacovandenbroek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

password_exposed's Issues

api keys

for commercial use haveibeenpwned uses api-keys for authentication.

looking at the current api of this package, I don't know where/how to pass in the api key into the lib.
Am I the only one in need for this feature? :)

Very strange rename error

We had a user in production get a strange error today which seems to originate from this package:

rename(/home/sites/15a/5/564543e965/production/releases/161/vendor/divineomega/password_exposed/src/../bundles/ca-certs.json,/home/sites/15a/5/564543e965/production/releases/161/vendor/divineomega/password_exposed/src/../bundles/ca-certs-backup-20210915192000.json): No such file or directory

Its only happened once but should I be worried here?

please bump old psr/cache deps

hi,

cant install as a dependemcy from divineomega/laravel-password-exposed-validation-rule :

Running composer update langleyfoxall/laravel-nist-password-rules
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - divineomega/password_exposed v3.2.0 requires psr/cache ^1.0 -> found psr/cache[1.0.0, 1.0.1] but the package is fixed to 3.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - langleyfoxall/laravel-nist-password-rules[v5.0.0, ..., v5.0.1] require divineomega/laravel-password-exposed-validation-rule ^2.4.0 -> satisfiable by divineomega/laravel-password-exposed-validation-rule[v2.4.0].
    - divineomega/laravel-password-exposed-validation-rule v2.4.0 requires divineomega/password_exposed ^3.2.0 -> satisfiable by divineomega/password_exposed[v3.2.0].
    - Root composer.json requires langleyfoxall/laravel-nist-password-rules ^5.0 -> satisfiable by langleyfoxall/laravel-nist-password-rules[v5.0.0, v5.0.1].

"psr/cache": "^1.0",

Make hashing optional

Maybe I didn't see it or am I right that it currently only takes blank strings as input? Useful for the exact moment when users have to choose a new password.

But it would be even nicer to also be able to use this tool for checking against already hashed passwords. Would that work with Troys API? With different hash types? Or does it anyways only work with sha1?

Empty string in $line causes an Exception that can expose a User's password

In this method, if the $line variable does not contain a colon (e.g., is an empty string), then the call to list() will throw an Exception.

list($exposedHashSuffix, $occurrences) = explode(':', $line);

This exception is not caught by the handling in NIST or the DivineOmega packages. The stack trace of this exception will contain the submitted password in plain text.

Laravel 5.7 incompatibility

It seems this package should not indicate support for v1 of the guzzle6-adapter package, because the type of object returned differs between v1 and v2 of the guzzle6-adapter.

This causes a compatibility issue with Laravel 5.7

It is caused by Laravel 5.7 requiring the laravel/nexmo-notification-channel as standard, which depends on the nexmo/client which enforces the use v1 of the guzzle6-adapter.

My plan of action is going to be:

  • Create a simple PSR18 Guzzle adapter package, that returns an object which implements the correct PSR18 client interface.
  • Modify this package to make use of the new PSR18 Guzzle adapter package.

This issue was discovered by @tswestendorp. See #24.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.