-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve default password policy to follow latest OWASP recommend…
…ations fixes AM-526 (cherry picked from commit 4dcaf23) # Conflicts: # gravitee-am-test/specs/gateway/login-flow.jest.spec.ts # gravitee-am-test/specs/gateway/remember-me.jest.spec.ts
- Loading branch information
1 parent
5e29308
commit 8097483
Showing
13 changed files
with
452 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...service/src/test/java/io/gravitee/am/service/validators/DefaultPasswordValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.gravitee.am.service.validators; | ||
|
||
import io.gravitee.am.service.validators.password.PasswordValidator; | ||
import io.gravitee.am.service.validators.password.impl.DefaultPasswordValidatorImpl; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* @author Eric LELEU (eric.leleu at graviteesource.com) | ||
* @author GraviteeSource Team | ||
*/ | ||
public class DefaultPasswordValidatorTest { | ||
@ParameterizedTest | ||
@MethodSource("providerValidatePassword") | ||
void validatePassword(String password, boolean expected) { | ||
PasswordValidator validator = new DefaultPasswordValidatorImpl( | ||
"^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!~<>.,;:_=?/*+\\-#\\\"'&§`£€%°()|\\[\\]$^@])(?!.*(.)\\1{2,}).{12,128}$" | ||
); | ||
assertEquals(expected, validator.validate(password)); | ||
} | ||
|
||
private static Stream<Arguments> providerValidatePassword() { | ||
return Stream.of( | ||
Arguments.of("a1!atjubclzf", false), | ||
Arguments.of("A1!ABVREFAGD", false), | ||
Arguments.of("Aa!AHYaeffSF", false), | ||
Arguments.of("AaBbCcDd1324", false), | ||
Arguments.of("Aa1!", false), | ||
Arguments.of("Password12!", false), | ||
Arguments.of("Passsword123!", false), | ||
Arguments.of("Password123!!!", false), | ||
Arguments.of( | ||
"MA48*xP:344MA48*xP:344MA48*xP:344MA48*xP:344MA48*xP:344MA48*xP:344MA48*xP:344MA48*xP:344MA48*xP:344MA48*xP:344MA48*xP:344MA48*xPz:", | ||
false | ||
), | ||
Arguments.of("Password1231!", true), | ||
Arguments.of("Password123!2£1", true), | ||
Arguments.of("MA48*xP:344d", true), | ||
Arguments.of("Ab0!~<>,;:_-=?*+#.\"'&§`€%°()|[]$^@", true), | ||
Arguments.of("SomeP@ssw0rd", true) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ let openIdConfiguration; | |
let application; | ||
let user = { | ||
username: 'SelfAccountUser', | ||
password: 'Test123!', | ||
password: 'SomeP@ssw0rd', | ||
firstName: 'SelfAccount', | ||
lastName: 'User', | ||
email: '[email protected]', | ||
|
@@ -135,7 +135,7 @@ describe('SelfAccount - Change Password', () => { | |
describe('With default settings', () => { | ||
describe('End User', () => { | ||
it('must be able to change his password', async () => { | ||
user.password = 'Test1234!!'; | ||
user.password = 'SomeP@ssw0rd!'; | ||
|
||
await performPost( | ||
`${process.env.AM_GATEWAY_URL}/${domain.hrid}/account/api/changePassword`, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ let openIdConfiguration; | |
let application; | ||
let user = { | ||
username: 'LogoutUser', | ||
password: 'Test123!', | ||
password: 'SomeP@ssw0rd', | ||
firstName: 'Logout', | ||
lastName: 'User', | ||
email: '[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ let openIdConfiguration; | |
let application; | ||
let user = { | ||
username: 'FlowUser', | ||
password: 'Test123!', | ||
password: 'SomeP@ssw0rd', | ||
firstName: 'Flow', | ||
lastName: 'User', | ||
email: '[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ beforeAll(async () => { | |
}); | ||
|
||
describe('multiple user', () => { | ||
<<<<<<< HEAD | ||
const contractValue = '1234'; | ||
let user1; | ||
const user1Password = 'Zxc123!!'; | ||
|
@@ -70,6 +71,21 @@ describe('multiple user', () => { | |
let user6; | ||
const secondCommonPassword = 'Phd123!!'; | ||
const secondCommonEmail = '[email protected]'; | ||
======= | ||
const contractValue = '1234'; | ||
let user1; | ||
const user1Password = 'ZxcPrm7123!!'; | ||
let user2; | ||
const commonPassword = 'AsdPrm7123!!'; | ||
const commonEmail = '[email protected]'; | ||
let user3; //user3 has same password as user2 | ||
let user4; | ||
const user4Password = 'QwePrm7123!!'; | ||
let user5; | ||
let user6; | ||
const secondCommonPassword = 'PhdPrm7123!!'; | ||
const secondCommonEmail = '[email protected]'; | ||
>>>>>>> 4dcaf234bb (fix: improve default password policy to follow latest OWASP recommendations) | ||
|
||
beforeAll(async () => { | ||
user1 = await createUser(domain.id, accessToken, { | ||
|
Oops, something went wrong.