Password validator

Password validation rules

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

nl.42
ArtifactId

ArtifactId

spring-boot-starter-password-validation
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Password validator
Password validation rules
Project Organization

Project Organization

42 BV
Source Code Management

Source Code Management

https://github.com/42BV/spring-boot-starter-password-validation

Download spring-boot-starter-password-validation

How to add to project

<!-- https://jarcasting.com/artifacts/nl.42/spring-boot-starter-password-validation/ -->
<dependency>
    <groupId>nl.42</groupId>
    <artifactId>spring-boot-starter-password-validation</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/nl.42/spring-boot-starter-password-validation/
implementation 'nl.42:spring-boot-starter-password-validation:1.1.0'
// https://jarcasting.com/artifacts/nl.42/spring-boot-starter-password-validation/
implementation ("nl.42:spring-boot-starter-password-validation:1.1.0")
'nl.42:spring-boot-starter-password-validation:jar:1.1.0'
<dependency org="nl.42" name="spring-boot-starter-password-validation" rev="1.1.0">
  <artifact name="spring-boot-starter-password-validation" type="jar" />
</dependency>
@Grapes(
@Grab(group='nl.42', module='spring-boot-starter-password-validation', version='1.1.0')
)
libraryDependencies += "nl.42" % "spring-boot-starter-password-validation" % "1.1.0"
[nl.42/spring-boot-starter-password-validation "1.1.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-autoconfigure jar
org.springframework.boot : spring-boot-starter-security Optional jar
org.projectlombok : lombok jar

test (2)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar
org.springframework.security : spring-security-test jar

Project Modules

There are no modules declared in this project.

Spring Boot Starter Password Validation

This library makes validating new passwords easy.

Steps necessary to make this library work in your application:

  • Configure the validations you want. See the available configurations below.
  • Make your user (or equivalent) class implement the interface PasswordHolder. This provides the validators a way to retrieve the current (encoded) password. This is required for certain validators.
  • Autowire the PasswordValidator bean in your application. Use the PasswordValidator.validate(newPassword, passwordHolder) method to validate new passwords. An exception of type PasswordValidationFailedException is thrown when a validation fails. No exception? Your new password is valid for use.
  • If desired: you can add new validation rules by implementing the ValidationRule interface.

Configuration:

password:
  different-than-current-enabled
  minimum-length-enabled
  not-used-in-past-enabled
  strength-enabled
  minimum-length
  strength-regex

password.different-than-current-enabled

Default: false
Type: boolean
Enables the validation where the password is not allowed to be the password the user is currently using.

password.minimum-length-enabled

Default: false
Type: boolean
Enables the minimum length check. See also property: password.minimum-length.

password.not-used-in-past-enabled

Default: false
Type: boolean
Enables the validation where the password is not allowed to have been used in the past by the same user.
Requires you to provide a bean of OldPasswordRepository as a means to retrieve the old passwords.

password.strength-enabled

Default: false
Type: boolean
Enables the strength check. Meaning the password must be valid according to a specific regex expression. See also property: password.strength-regex.

password.minimum-length

Default: 8
Type: int
Only used when password.minimum-length-enabled is turned on. Defines the minimum length of passwords; shorter passwords will be denied.

password.strength-regex

Default: ^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=.,?!])(?=\S+$).*$
Type: String
Only used when password.strength-enabled is turned on. Defines the regex for the strength check. The default checks for at least one capital letter, one lower case letter, one number and one special character.

nl.42

Versions

Version
1.1.0
1.0.0