Browse Source

FactorGrantedAuthority

Rob Winch 1 month ago
parent
commit
e3484f79cb

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

@@ -9,8 +9,8 @@ import org.springframework.security.test.context.support.WithMockUser;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.web.servlet.MockMvc;
 
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_OTT_AUTHORITY;
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_PASSWORD_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.OTT_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.PASSWORD_AUTHORITY;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -38,7 +38,7 @@ class CustomPagesConfigTests {
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_OTT_AUTHORITY)
+	@WithMockUser(authorities = OTT_AUTHORITY)
 	void indexWhenAuthenticatedWithX509ThenRedirectsToLogin() throws Exception {
 		this.mvc.perform(get("/"))
 			.andExpect(status().is3xxRedirection())
@@ -46,7 +46,7 @@ class CustomPagesConfigTests {
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_PASSWORD_AUTHORITY)
+	@WithMockUser(authorities = PASSWORD_AUTHORITY)
 	void indexWhenAuthenticatedWithPasswordThenRedirectsToOtt() throws Exception {
 		this.mvc.perform(get("/"))
 			.andExpect(status().is3xxRedirection())

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

@@ -9,8 +9,8 @@ import org.springframework.security.test.context.support.WithMockUser;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.web.servlet.MockMvc;
 
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_OTT_AUTHORITY;
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_PASSWORD_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.OTT_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.PASSWORD_AUTHORITY;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -38,7 +38,7 @@ class DefaultConfigTests {
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_OTT_AUTHORITY)
+	@WithMockUser(authorities = OTT_AUTHORITY)
 	void indexWhenAuthenticatedWithX509ThenRedirectsToLogin() throws Exception {
 		this.mvc.perform(get("/"))
 			.andExpect(status().is3xxRedirection())
@@ -46,7 +46,7 @@ class DefaultConfigTests {
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_PASSWORD_AUTHORITY)
+	@WithMockUser(authorities = PASSWORD_AUTHORITY)
 	void indexWhenAuthenticatedWithPasswordThenRedirectsToOtt() throws Exception {
 		this.mvc.perform(get("/"))
 			.andExpect(status().is3xxRedirection())

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

@@ -9,8 +9,8 @@ import org.springframework.security.test.context.support.WithMockUser;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.web.servlet.MockMvc;
 
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_OTT_AUTHORITY;
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_PASSWORD_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.OTT_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.PASSWORD_AUTHORITY;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -37,21 +37,21 @@ class ElevatedSecurityPageConfigTests {
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_OTT_AUTHORITY)
+	@WithMockUser(authorities = OTT_AUTHORITY)
 	void indexWhenAuthenticatedWithOttThenAllows() throws Exception {
 		this.mvc.perform(get("/"))
 			.andExpect(status().isOk());
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_PASSWORD_AUTHORITY)
+	@WithMockUser(authorities = PASSWORD_AUTHORITY)
 	void indexWhenAuthenticatedWithPasswordThenAllows() throws Exception {
 		this.mvc.perform(get("/"))
 			.andExpect(status().isOk());
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_PASSWORD_AUTHORITY)
+	@WithMockUser(authorities = PASSWORD_AUTHORITY)
 	void profileWhenAuthenticatedWithPasswordThenRedirectsToOtt() throws Exception {
 		this.mvc.perform(get("/profile"))
 			.andExpect(status().is3xxRedirection())
@@ -59,7 +59,7 @@ class ElevatedSecurityPageConfigTests {
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_OTT_AUTHORITY)
+	@WithMockUser(authorities = OTT_AUTHORITY)
 	void profileWhenAuthenticatedWithOttThenAllows() throws Exception {
 		this.mvc.perform(get("/profile"))
 			.andExpect(status().isOk());

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

@@ -26,11 +26,11 @@ import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.provisioning.InMemoryUserDetailsManager;
 import org.springframework.security.web.SecurityFilterChain;
 
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_PASSWORD_AUTHORITY;
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_X509_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.PASSWORD_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.X509_AUTHORITY;
 
 @Configuration(proxyBeanMethods = false)
-@EnableGlobalMultiFactorAuthentication(authorities = { FACTOR_X509_AUTHORITY, FACTOR_PASSWORD_AUTHORITY })
+@EnableGlobalMultiFactorAuthentication(authorities = { X509_AUTHORITY, PASSWORD_AUTHORITY })
 public class SecurityConfig {
 
 	@Bean

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

@@ -24,8 +24,8 @@ import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
 import org.springframework.security.test.context.support.WithMockUser;
 import org.springframework.test.web.servlet.MockMvc;
 
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_PASSWORD_AUTHORITY;
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_X509_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.PASSWORD_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.X509_AUTHORITY;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -55,7 +55,7 @@ class MfaApplicationTests {
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_X509_AUTHORITY)
+	@WithMockUser(authorities = X509_AUTHORITY)
 	void indexWhenAuthenticatedWithX509ThenRedirectsToLogin() throws Exception {
 		this.mvc.perform(get("/"))
 			.andExpect(status().is3xxRedirection())
@@ -63,7 +63,7 @@ class MfaApplicationTests {
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_PASSWORD_AUTHORITY)
+	@WithMockUser(authorities = PASSWORD_AUTHORITY)
 	void indexWhenAuthenticatedWithPasswordThenForbidden() throws Exception {
 		this.mvc.perform(get("/"))
 			.andExpect(status().isForbidden());

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

@@ -26,11 +26,11 @@ import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.provisioning.InMemoryUserDetailsManager;
 import org.springframework.security.web.SecurityFilterChain;
 
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_WEBAUTHN_AUTHORITY;
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_X509_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.WEBAUTHN_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.X509_AUTHORITY;
 
 @Configuration
-@EnableGlobalMultiFactorAuthentication(authorities = { FACTOR_X509_AUTHORITY, FACTOR_WEBAUTHN_AUTHORITY})
+@EnableGlobalMultiFactorAuthentication(authorities = { X509_AUTHORITY, WEBAUTHN_AUTHORITY})
 public class SecurityConfig {
 
 	@Bean

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

@@ -24,8 +24,8 @@ import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
 import org.springframework.security.test.context.support.WithMockUser;
 import org.springframework.test.web.servlet.MockMvc;
 
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_WEBAUTHN_AUTHORITY;
-import static org.springframework.security.core.authority.FactorGrantedAuthority.FACTOR_X509_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.WEBAUTHN_AUTHORITY;
+import static org.springframework.security.core.authority.FactorGrantedAuthority.X509_AUTHORITY;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -54,14 +54,14 @@ public class X509WebAuthnMfaApplicationTests {
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_WEBAUTHN_AUTHORITY)
+	@WithMockUser(authorities = WEBAUTHN_AUTHORITY)
 	void indexWhenAuthenticatedWithWebAuthnThenForbidden() throws Exception {
 		this.mvc.perform(get("/"))
 			.andExpect(status().isForbidden());
 	}
 
 	@Test
-	@WithMockUser(authorities = FACTOR_X509_AUTHORITY)
+	@WithMockUser(authorities = X509_AUTHORITY)
 	void indexWhenAuthenticatedWithX509ThenRedirectsToWebAuthn() throws Exception {
 		this.mvc.perform(get("/"))
 			.andExpect(status().is3xxRedirection())