Skip to content

Commit e3484f7

Browse files
committed
FactorGrantedAuthority
1 parent 323111a commit e3484f7

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

servlet/spring-boot/java/authentication/mfa/formLogin+ott/src/test/java/example/CustomPagesConfigTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.springframework.test.context.ActiveProfiles;
1010
import org.springframework.test.web.servlet.MockMvc;
1111

12-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_OTT_AUTHORITY;
13-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_PASSWORD_AUTHORITY;
12+
import static org.springframework.security.core.authority.FactorGrantedAuthority.OTT_AUTHORITY;
13+
import static org.springframework.security.core.authority.FactorGrantedAuthority.PASSWORD_AUTHORITY;
1414
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
1515
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
1616
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -38,15 +38,15 @@ void indexWhenAuthenticatedButNoFactorsThenRedirectsToLogin() throws Exception {
3838
}
3939

4040
@Test
41-
@WithMockUser(authorities = FACTOR_OTT_AUTHORITY)
41+
@WithMockUser(authorities = OTT_AUTHORITY)
4242
void indexWhenAuthenticatedWithX509ThenRedirectsToLogin() throws Exception {
4343
this.mvc.perform(get("/"))
4444
.andExpect(status().is3xxRedirection())
4545
.andExpect(redirectedUrl("http://localhost/auth/password?factor=password"));
4646
}
4747

4848
@Test
49-
@WithMockUser(authorities = FACTOR_PASSWORD_AUTHORITY)
49+
@WithMockUser(authorities = PASSWORD_AUTHORITY)
5050
void indexWhenAuthenticatedWithPasswordThenRedirectsToOtt() throws Exception {
5151
this.mvc.perform(get("/"))
5252
.andExpect(status().is3xxRedirection())

servlet/spring-boot/java/authentication/mfa/formLogin+ott/src/test/java/example/DefaultConfigTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.springframework.test.context.ActiveProfiles;
1010
import org.springframework.test.web.servlet.MockMvc;
1111

12-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_OTT_AUTHORITY;
13-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_PASSWORD_AUTHORITY;
12+
import static org.springframework.security.core.authority.FactorGrantedAuthority.OTT_AUTHORITY;
13+
import static org.springframework.security.core.authority.FactorGrantedAuthority.PASSWORD_AUTHORITY;
1414
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
1515
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
1616
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -38,15 +38,15 @@ void indexWhenAuthenticatedButNoFactorsThenRedirectsToLogin() throws Exception {
3838
}
3939

4040
@Test
41-
@WithMockUser(authorities = FACTOR_OTT_AUTHORITY)
41+
@WithMockUser(authorities = OTT_AUTHORITY)
4242
void indexWhenAuthenticatedWithX509ThenRedirectsToLogin() throws Exception {
4343
this.mvc.perform(get("/"))
4444
.andExpect(status().is3xxRedirection())
4545
.andExpect(redirectedUrl("http://localhost/login?factor=password"));
4646
}
4747

4848
@Test
49-
@WithMockUser(authorities = FACTOR_PASSWORD_AUTHORITY)
49+
@WithMockUser(authorities = PASSWORD_AUTHORITY)
5050
void indexWhenAuthenticatedWithPasswordThenRedirectsToOtt() throws Exception {
5151
this.mvc.perform(get("/"))
5252
.andExpect(status().is3xxRedirection())

servlet/spring-boot/java/authentication/mfa/formLogin+ott/src/test/java/example/ElevatedSecurityPageConfigTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.springframework.test.context.ActiveProfiles;
1010
import org.springframework.test.web.servlet.MockMvc;
1111

12-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_OTT_AUTHORITY;
13-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_PASSWORD_AUTHORITY;
12+
import static org.springframework.security.core.authority.FactorGrantedAuthority.OTT_AUTHORITY;
13+
import static org.springframework.security.core.authority.FactorGrantedAuthority.PASSWORD_AUTHORITY;
1414
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
1515
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
1616
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -37,29 +37,29 @@ void indexWhenAuthenticatedButNoFactorsThenAllows() throws Exception {
3737
}
3838

3939
@Test
40-
@WithMockUser(authorities = FACTOR_OTT_AUTHORITY)
40+
@WithMockUser(authorities = OTT_AUTHORITY)
4141
void indexWhenAuthenticatedWithOttThenAllows() throws Exception {
4242
this.mvc.perform(get("/"))
4343
.andExpect(status().isOk());
4444
}
4545

4646
@Test
47-
@WithMockUser(authorities = FACTOR_PASSWORD_AUTHORITY)
47+
@WithMockUser(authorities = PASSWORD_AUTHORITY)
4848
void indexWhenAuthenticatedWithPasswordThenAllows() throws Exception {
4949
this.mvc.perform(get("/"))
5050
.andExpect(status().isOk());
5151
}
5252

5353
@Test
54-
@WithMockUser(authorities = FACTOR_PASSWORD_AUTHORITY)
54+
@WithMockUser(authorities = PASSWORD_AUTHORITY)
5555
void profileWhenAuthenticatedWithPasswordThenRedirectsToOtt() throws Exception {
5656
this.mvc.perform(get("/profile"))
5757
.andExpect(status().is3xxRedirection())
5858
.andExpect(redirectedUrl("http://localhost/auth/ott?factor=ott"));
5959
}
6060

6161
@Test
62-
@WithMockUser(authorities = FACTOR_OTT_AUTHORITY)
62+
@WithMockUser(authorities = OTT_AUTHORITY)
6363
void profileWhenAuthenticatedWithOttThenAllows() throws Exception {
6464
this.mvc.perform(get("/profile"))
6565
.andExpect(status().isOk());

servlet/spring-boot/java/authentication/mfa/x509+formLogin/src/main/java/example/SecurityConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
2727
import org.springframework.security.web.SecurityFilterChain;
2828

29-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_PASSWORD_AUTHORITY;
30-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_X509_AUTHORITY;
29+
import static org.springframework.security.core.authority.FactorGrantedAuthority.PASSWORD_AUTHORITY;
30+
import static org.springframework.security.core.authority.FactorGrantedAuthority.X509_AUTHORITY;
3131

3232
@Configuration(proxyBeanMethods = false)
33-
@EnableGlobalMultiFactorAuthentication(authorities = { FACTOR_X509_AUTHORITY, FACTOR_PASSWORD_AUTHORITY })
33+
@EnableGlobalMultiFactorAuthentication(authorities = { X509_AUTHORITY, PASSWORD_AUTHORITY })
3434
public class SecurityConfig {
3535

3636
@Bean

servlet/spring-boot/java/authentication/mfa/x509+formLogin/src/test/java/example/MfaApplicationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import org.springframework.security.test.context.support.WithMockUser;
2525
import org.springframework.test.web.servlet.MockMvc;
2626

27-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_PASSWORD_AUTHORITY;
28-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_X509_AUTHORITY;
27+
import static org.springframework.security.core.authority.FactorGrantedAuthority.PASSWORD_AUTHORITY;
28+
import static org.springframework.security.core.authority.FactorGrantedAuthority.X509_AUTHORITY;
2929
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
3030
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
3131
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -55,15 +55,15 @@ void indexWhenAuthenticatedButNoFactorsThenForbidden() throws Exception {
5555
}
5656

5757
@Test
58-
@WithMockUser(authorities = FACTOR_X509_AUTHORITY)
58+
@WithMockUser(authorities = X509_AUTHORITY)
5959
void indexWhenAuthenticatedWithX509ThenRedirectsToLogin() throws Exception {
6060
this.mvc.perform(get("/"))
6161
.andExpect(status().is3xxRedirection())
6262
.andExpect(redirectedUrl("http://localhost/login?factor=password"));
6363
}
6464

6565
@Test
66-
@WithMockUser(authorities = FACTOR_PASSWORD_AUTHORITY)
66+
@WithMockUser(authorities = PASSWORD_AUTHORITY)
6767
void indexWhenAuthenticatedWithPasswordThenForbidden() throws Exception {
6868
this.mvc.perform(get("/"))
6969
.andExpect(status().isForbidden());

servlet/spring-boot/java/authentication/mfa/x509+webauthn/src/main/java/example/SecurityConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
2727
import org.springframework.security.web.SecurityFilterChain;
2828

29-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_WEBAUTHN_AUTHORITY;
30-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_X509_AUTHORITY;
29+
import static org.springframework.security.core.authority.FactorGrantedAuthority.WEBAUTHN_AUTHORITY;
30+
import static org.springframework.security.core.authority.FactorGrantedAuthority.X509_AUTHORITY;
3131

3232
@Configuration
33-
@EnableGlobalMultiFactorAuthentication(authorities = { FACTOR_X509_AUTHORITY, FACTOR_WEBAUTHN_AUTHORITY})
33+
@EnableGlobalMultiFactorAuthentication(authorities = { X509_AUTHORITY, WEBAUTHN_AUTHORITY})
3434
public class SecurityConfig {
3535

3636
@Bean

servlet/spring-boot/java/authentication/mfa/x509+webauthn/src/test/java/example/X509WebAuthnMfaApplicationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import org.springframework.security.test.context.support.WithMockUser;
2525
import org.springframework.test.web.servlet.MockMvc;
2626

27-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_WEBAUTHN_AUTHORITY;
28-
import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_X509_AUTHORITY;
27+
import static org.springframework.security.core.authority.FactorGrantedAuthority.WEBAUTHN_AUTHORITY;
28+
import static org.springframework.security.core.authority.FactorGrantedAuthority.X509_AUTHORITY;
2929
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
3030
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
3131
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -54,14 +54,14 @@ void indexWhenAuthenticatedButNoFactorsThenRedirectsToLogin() throws Exception {
5454
}
5555

5656
@Test
57-
@WithMockUser(authorities = FACTOR_WEBAUTHN_AUTHORITY)
57+
@WithMockUser(authorities = WEBAUTHN_AUTHORITY)
5858
void indexWhenAuthenticatedWithWebAuthnThenForbidden() throws Exception {
5959
this.mvc.perform(get("/"))
6060
.andExpect(status().isForbidden());
6161
}
6262

6363
@Test
64-
@WithMockUser(authorities = FACTOR_X509_AUTHORITY)
64+
@WithMockUser(authorities = X509_AUTHORITY)
6565
void indexWhenAuthenticatedWithX509ThenRedirectsToWebAuthn() throws Exception {
6666
this.mvc.perform(get("/"))
6767
.andExpect(status().is3xxRedirection())

0 commit comments

Comments
 (0)