-
-
Notifications
You must be signed in to change notification settings - Fork 964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make the password policy more configurable #2118
Changes from 8 commits
9953f13
e50a5cd
2ce6da0
d723ca2
098a988
b54c868
657a281
5114402
d71256d
64ea534
233925a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,33 @@ | ||||||
--- | ||||||
id: password-policy | ||||||
title: Configuring The Password Policy | ||||||
--- | ||||||
|
||||||
The password policy is a set of rules that define the password requirements for | ||||||
Kratos identities. They can be changed by modifying the following configuration | ||||||
parameters: | ||||||
|
||||||
```yaml title=path/to/kratos/config.yml | ||||||
selfservice: | ||||||
methods: | ||||||
enabled: true | ||||||
config: | ||||||
haveibeenpwned_enabled: true | ||||||
min_password_length: 6 | ||||||
identifier_similarity_check_enabled: true | ||||||
``` | ||||||
|
||||||
#### `haveibeenpwned_enabled` | ||||||
|
||||||
If set to `true`, the password policy will check if the password has been found | ||||||
in the [Have I Been Pwned](https://haveibeenpwned.com/) database. The default | ||||||
value is `true`. | ||||||
|
||||||
#### `min_password_length` | ||||||
|
||||||
The minimum length of the password. The default value is `6`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
#### `identifier_similarity_check_enabled` | ||||||
|
||||||
If set to `true`, the password policy will check if the password is similar to | ||||||
the user identifier. The default value is `true`. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -144,6 +144,8 @@ const ( | |||||
ViperKeyPasswordHaveIBeenPwnedHost = "selfservice.methods.password.config.haveibeenpwned_host" | ||||||
ViperKeyPasswordHaveIBeenPwnedEnabled = "selfservice.methods.password.config.haveibeenpwned_enabled" | ||||||
ViperKeyPasswordMaxBreaches = "selfservice.methods.password.config.max_breaches" | ||||||
ViperKeyPasswordMinLength = "selfservice.methods.password.config.min_password_length" | ||||||
ViperKeyPasswordIdentifierSimilarityCheckEnabled = "selfservice.methods.password.config.identifier_similarity_check_enabled" | ||||||
ViperKeyIgnoreNetworkErrors = "selfservice.methods.password.config.ignore_network_errors" | ||||||
ViperKeyTOTPIssuer = "selfservice.methods.totp.config.issuer" | ||||||
ViperKeyWebAuthnRPDisplayName = "selfservice.methods.webauthn.config.rp.display_name" | ||||||
|
@@ -195,10 +197,12 @@ type ( | |||||
URL string `json:"url"` | ||||||
} | ||||||
PasswordPolicy struct { | ||||||
HaveIBeenPwnedHost string `json:"haveibeenpwned_host"` | ||||||
HaveIBeenPwnedEnabled bool `json:"haveibeenpwned_enabled"` | ||||||
MaxBreaches uint `json:"max_breaches"` | ||||||
IgnoreNetworkErrors bool `json:"ignore_network_errors"` | ||||||
HaveIBeenPwnedHost string `json:"haveibeenpwned_host"` | ||||||
HaveIBeenPwnedEnabled bool `json:"haveibeenpwned_enabled"` | ||||||
MaxBreaches uint `json:"max_breaches"` | ||||||
IgnoreNetworkErrors bool `json:"ignore_network_errors"` | ||||||
MinPasswordLength uint `json:"min_password_length"` | ||||||
IdentifierSimilarityCheckEnabled bool `json:"identifier_similarity_check_enabled"` | ||||||
} | ||||||
Schemas []Schema | ||||||
Config struct { | ||||||
|
@@ -998,10 +1002,12 @@ func (p *Config) ConfigVersion() string { | |||||
|
||||||
func (p *Config) PasswordPolicyConfig() *PasswordPolicy { | ||||||
return &PasswordPolicy{ | ||||||
HaveIBeenPwnedHost: p.p.StringF(ViperKeyPasswordHaveIBeenPwnedHost, "api.pwnedpasswords.com"), | ||||||
HaveIBeenPwnedEnabled: p.p.BoolF(ViperKeyPasswordHaveIBeenPwnedEnabled, true), | ||||||
MaxBreaches: uint(p.p.Int(ViperKeyPasswordMaxBreaches)), | ||||||
IgnoreNetworkErrors: p.p.BoolF(ViperKeyIgnoreNetworkErrors, true), | ||||||
HaveIBeenPwnedHost: p.p.StringF(ViperKeyPasswordHaveIBeenPwnedHost, "api.pwnedpasswords.com"), | ||||||
HaveIBeenPwnedEnabled: p.p.BoolF(ViperKeyPasswordHaveIBeenPwnedEnabled, true), | ||||||
MaxBreaches: uint(p.p.Int(ViperKeyPasswordMaxBreaches)), | ||||||
IgnoreNetworkErrors: p.p.BoolF(ViperKeyIgnoreNetworkErrors, true), | ||||||
MinPasswordLength: uint(p.p.IntF(ViperKeyPasswordMinLength, 6)), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
IdentifierSimilarityCheckEnabled: p.p.BoolF(ViperKeyPasswordIdentifierSimilarityCheckEnabled, true), | ||||||
} | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1128,6 +1128,18 @@ | |
"description": "If set to false the password validation fails when the network or the Have I Been Pwnd API is down.", | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"min_password_length": { | ||
"title": "Minimum Password Length", | ||
"description": "Defines the minimum length of the password.", | ||
"type": "integer", | ||
"default": 6 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make the default |
||
}, | ||
"identifier_similarity_check_enabled": { | ||
"title": "Enable password-identifier similarity check", | ||
"description": "If set to false the password validation does not check for similarity between the password and the user identifier.", | ||
"type": "boolean", | ||
"default": true | ||
} | ||
}, | ||
"additionalProperties": false | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.