Browse Source
Merge pull request #5710 from desoliture1/pass_with_spaces_fix
[3.3.x] Add allow-whitespace password policy
pull/5744/head
Igor Kulikov
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with
14 additions and
2 deletions
-
application/src/main/java/org/thingsboard/server/service/security/auth/rest/RestLoginProcessingFilter.java
-
application/src/main/java/org/thingsboard/server/service/security/system/DefaultSystemSecurityService.java
-
common/data/src/main/java/org/thingsboard/server/common/data/security/model/UserPasswordPolicy.java
-
ui-ngx/src/app/modules/home/pages/admin/security-settings.component.html
-
ui-ngx/src/app/modules/home/pages/admin/security-settings.component.ts
-
ui-ngx/src/app/shared/models/settings.models.ts
-
ui-ngx/src/assets/locale/locale.constant-en_US.json
|
|
|
@ -73,7 +73,7 @@ public class RestLoginProcessingFilter extends AbstractAuthenticationProcessingF |
|
|
|
throw new AuthenticationServiceException("Invalid login request payload"); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isBlank(loginRequest.getUsername()) || StringUtils.isBlank(loginRequest.getPassword())) { |
|
|
|
if (StringUtils.isBlank(loginRequest.getUsername()) || StringUtils.isEmpty(loginRequest.getPassword())) { |
|
|
|
throw new AuthenticationServiceException("Username or Password not provided"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -27,6 +27,7 @@ import org.passay.PasswordData; |
|
|
|
import org.passay.PasswordValidator; |
|
|
|
import org.passay.Rule; |
|
|
|
import org.passay.RuleResult; |
|
|
|
import org.passay.WhitespaceRule; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.cache.annotation.CacheEvict; |
|
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
|
@ -174,6 +175,9 @@ public class DefaultSystemSecurityService implements SystemSecurityService { |
|
|
|
if (isPositiveInteger(passwordPolicy.getMinimumSpecialCharacters())) { |
|
|
|
passwordRules.add(new CharacterRule(EnglishCharacterData.Special, passwordPolicy.getMinimumSpecialCharacters())); |
|
|
|
} |
|
|
|
if (passwordPolicy.getAllowWhitespaces() != null && !passwordPolicy.getAllowWhitespaces()) { |
|
|
|
passwordRules.add(new WhitespaceRule()); |
|
|
|
} |
|
|
|
PasswordValidator validator = new PasswordValidator(passwordRules); |
|
|
|
PasswordData passwordData = new PasswordData(password); |
|
|
|
RuleResult result = validator.validate(passwordData); |
|
|
|
|
|
|
|
@ -35,6 +35,8 @@ public class UserPasswordPolicy implements Serializable { |
|
|
|
private Integer minimumDigits; |
|
|
|
@ApiModelProperty(position = 1, value = "Minimum number of special in the password." ) |
|
|
|
private Integer minimumSpecialCharacters; |
|
|
|
@ApiModelProperty(position = 1, value = "Allow whitespaces") |
|
|
|
private Boolean allowWhitespaces = true; |
|
|
|
|
|
|
|
@ApiModelProperty(position = 1, value = "Password expiration period (days). Force expiration of the password." ) |
|
|
|
private Integer passwordExpirationPeriodDays; |
|
|
|
|
|
|
|
@ -139,6 +139,9 @@ |
|
|
|
{{ 'admin.password-reuse-frequency-days-range' | translate }} |
|
|
|
</mat-error> |
|
|
|
</mat-form-field> |
|
|
|
<mat-checkbox formControlName = "allowWhitespaces" > |
|
|
|
<mat-label translate>admin.allow-whitespace</mat-label> |
|
|
|
</mat-checkbox> |
|
|
|
</section> |
|
|
|
</mat-expansion-panel> |
|
|
|
</mat-accordion> |
|
|
|
|
|
|
|
@ -63,7 +63,8 @@ export class SecuritySettingsComponent extends PageComponent implements OnInit, |
|
|
|
minimumDigits: [null, Validators.min(0)], |
|
|
|
minimumSpecialCharacters: [null, Validators.min(0)], |
|
|
|
passwordExpirationPeriodDays: [null, Validators.min(0)], |
|
|
|
passwordReuseFrequencyDays: [null, Validators.min(0)] |
|
|
|
passwordReuseFrequencyDays: [null, Validators.min(0)], |
|
|
|
allowWhitespaces: [true] |
|
|
|
} |
|
|
|
) |
|
|
|
}); |
|
|
|
|
|
|
|
@ -55,6 +55,7 @@ export interface UserPasswordPolicy { |
|
|
|
minimumDigits: number; |
|
|
|
minimumSpecialCharacters: number; |
|
|
|
passwordExpirationPeriodDays: number; |
|
|
|
allowWhitespaces: boolean; |
|
|
|
} |
|
|
|
|
|
|
|
export interface SecuritySettings { |
|
|
|
|
|
|
|
@ -152,6 +152,7 @@ |
|
|
|
"password-expiration-period-days-range": "Password expiration period in days can't be negative", |
|
|
|
"password-reuse-frequency-days": "Password reuse frequency in days", |
|
|
|
"password-reuse-frequency-days-range": "Password reuse frequency in days can't be negative", |
|
|
|
"allow-whitespace": "Allow whitespace", |
|
|
|
"general-policy": "General policy", |
|
|
|
"max-failed-login-attempts": "Maximum number of failed login attempts, before account is locked", |
|
|
|
"minimum-max-failed-login-attempts-range": "Maximum number of failed login attempts can't be negative", |
|
|
|
|