All Projects → auth0 → password-sheriff

auth0 / password-sheriff

Licence: other
Password policies made easy.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to password-sheriff

auth0-golang-web-app
Auth0 Integration Samples for Go Web Applications
Stars: ✭ 112 (+47.37%)
Mutual labels:  dx-sdk
Java Jwt
Java implementation of JSON Web Token (JWT)
Stars: ✭ 4,501 (+5822.37%)
Mutual labels:  dx-sdk
auth0-jquery-samples
Auth0 Integration Samples for jQuery
Stars: ✭ 14 (-81.58%)
Mutual labels:  dx-sdk
auth0-golang-api-samples
Auth0 Integration Samples for Go REST API Services
Stars: ✭ 93 (+22.37%)
Mutual labels:  dx-sdk
auth0-django-web-app
Auth0 Integration Samples for Django Web Applications
Stars: ✭ 33 (-56.58%)
Mutual labels:  dx-sdk
auth0-spring-security5-api-sample
Sample demonstrating how to secure your API using Spring Boot 2 and Spring Security 5
Stars: ✭ 39 (-48.68%)
Mutual labels:  dx-sdk
auth0-spring-mvc-sample
Auth0 Integration Samples for Java Spring MVC Web Applications
Stars: ✭ 20 (-73.68%)
Mutual labels:  dx-sdk
auth0-oidc-client-net
OIDC Client for .NET Desktop and Mobile applications
Stars: ✭ 53 (-30.26%)
Mutual labels:  dx-sdk
auth0-rubyonrails-sample
Auth0 Integration Samples for Ruby on Rails Web Applications
Stars: ✭ 36 (-52.63%)
Mutual labels:  dx-sdk
angular-lock
No description or website provided.
Stars: ✭ 16 (-78.95%)
Mutual labels:  dx-sdk
auth0-ios-swift-sample
Auth0 Integration Samples for iOS Swift
Stars: ✭ 55 (-27.63%)
Mutual labels:  dx-sdk
auth0-cordova
Auth0 integration for Cordova apps
Stars: ✭ 48 (-36.84%)
Mutual labels:  dx-sdk
Auth0.Android
Android toolkit for Auth0 API
Stars: ✭ 138 (+81.58%)
Mutual labels:  dx-sdk
auth0-aspnetcore-mvc-samples
Auth0 Integration Samples for ASP.NET Core MVC Web Applications
Stars: ✭ 120 (+57.89%)
Mutual labels:  dx-sdk
auth0-android-sample
Auth0 Integration Samples for Android Applications
Stars: ✭ 61 (-19.74%)
Mutual labels:  dx-sdk
auth0-aspnet-owin-webapi-samples
Auth0 Integration Samples for ASP.NET OWIN Web API Services
Stars: ✭ 25 (-67.11%)
Mutual labels:  dx-sdk
express-oauth2-bearer
Experimental Middleware for express.js to validate access tokens.
Stars: ✭ 30 (-60.53%)
Mutual labels:  dx-sdk
auth0-laravel-api-samples
Auth0 Integration Samples for Laravel REST API Services
Stars: ✭ 18 (-76.32%)
Mutual labels:  dx-sdk

Password Sheriff

FOSSA Status

Node.js (and browserify supported) library to enforce password policies.

Install

npm install password-sheriff

Usage

var PasswordPolicy = require('password-sheriff').PasswordPolicy;

// Create a length password policy
var lengthPolicy = new PasswordPolicy({length: {minLength: 6}});

// will throw as the password does not meet criteria
lengthPolicy.assert('hello');

// returns false if password does not meet rules
assert.equal(false, lengthPolicy.check('hello'));

// explains the policy
var explained = lengthPolicy.explain();

assert.equal(1, explained.length);

// easier i18n
assert.equal('lengthAtLeast', explained[0].code);
assert.equal('At least 6 characters in length',
             format(explained[0].message, explained[0].format));

API

Password Rules

Password Rules are objects that implement the following methods:

  • rule.validate(options): method called after the rule was created in order to validate options arguments.
  • rule.assert(options, password): returns true if password is valid.
  • rule.explain(options): returns an object with code, message and format attributes:
    • code: Identifier of the rule. This attribute is meant to aid i18n.
    • message: Description of the rule that must be formatted using util.format.
    • format: Array of string or Number that will be used for the replacements required in message.
  • rule.missing(options, password): returns an object similar to rule.explain plus an additional field verified that informs whether the password meets the rule.

Example of rule.explain method:

FooRule.prototype.explain = function (options) {
  return {
    // identifier rule (to make i18n easier)
    code: 'foo',
    message: 'Foo should be present at least %d times.',
    format: [options.count]
  };
};

When explained:

var explained = fooRule.explain({count: 5});

// "Foo should be present at least 5 times"
util.format(explained.message, explained.format[0]);

See the custom-rule example section for more information.

Built-in Password Rules

Password Sheriff includes some default rules:

  • length: The minimum amount of characters a password must have.
var lengthPolicy = new PasswordPolicy({length: {minLength: 3}});
  • contains: Password should contain all of the charsets specified. There are 4 predefined charsets: upperCase, lowerCase, numbers and specialCharacters (specialCharactersare the ones defined in OWASP Password Policy recommendation document).
var charsets = require('password-sheriff').charsets;

var containsPolicy = new PasswordPolicy({contains: {
  expressions: [charsets.upperCase, charsets.numbers]
}});
  • containsAtLeast: Passwords should contain at least atLeast of a total of expressions.length groups.
var charsets = require('password-sheriff').charsets;

var containsAtLeastPolicy = new PasswordPolicy({
  containsAtLeast: {
    atLeast: 2,
    expressions: [ charsets.lowerCase, charsets.upperCase, charsets.numbers ]
  }
});
  • identicalChars: Passwords should not contain any character repeated continuously max + 1 times.
var identitcalCharsPolicy = new PasswordPolicy({
  identicalChars: {
    max: 3
  }
});

See the default-rules example section for more information.

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].