Update HttpSecurity Formatting

This commit is contained in:
Josh Cummings
2021-11-10 09:42:09 -07:00
parent 3a4eec6eda
commit 3a58daf55d
27 changed files with 98 additions and 100 deletions

View File

@@ -72,7 +72,9 @@ public class OAuth2AuthorizationServerSecurityConfiguration {
public SecurityFilterChain standardSecurityFilterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((requests) -> requests.anyRequest().authenticated())
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.formLogin(Customizer.withDefaults());
// @formatter:on

View File

@@ -334,16 +334,12 @@ public class OAuth2LoginApplicationTests {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests((requests) -> requests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.oauth2Login((oauth2) -> oauth2
.tokenEndpoint((tokens) -> tokens
.accessTokenResponseClient(this.mockAccessTokenResponseClient())
)
.userInfoEndpoint((userInfo) -> userInfo
.userService(this.mockUserService())
)
.tokenEndpoint((token) -> token.accessTokenResponseClient(mockAccessTokenResponseClient()))
.userInfoEndpoint((userInfo) -> userInfo.userService(mockUserService()))
);
}
// @formatter:on

View File

@@ -40,11 +40,10 @@ public class OAuth2ResourceServerSecurityConfiguration extends WebSecurityConfig
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((requests) ->
requests
.antMatchers(HttpMethod.GET, "/message/**").hasAuthority("SCOPE_message:read")
.antMatchers(HttpMethod.POST, "/message/**").hasAuthority("SCOPE_message:write")
.anyRequest().authenticated()
.authorizeRequests((authorize) -> authorize
.antMatchers(HttpMethod.GET, "/message/**").hasAuthority("SCOPE_message:read")
.antMatchers(HttpMethod.POST, "/message/**").hasAuthority("SCOPE_message:write")
.anyRequest().authenticated()
)
.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt);
// @formatter:on

View File

@@ -72,15 +72,11 @@ public class OAuth2ResourceServerSecurityConfiguration extends WebSecurityConfig
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((requests) ->
requests
.antMatchers("/message/**").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated()
.authorizeRequests((authorize) -> authorize
.antMatchers("/message/**").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated()
)
.oauth2ResourceServer((resourceServer) ->
resourceServer
.jwt(withDefaults())
);
.oauth2ResourceServer((oauth2) -> oauth2.jwt(withDefaults()));
// @formatter:on
}

View File

@@ -47,11 +47,11 @@ public class OAuth2ResourceServerSecurityConfiguration {
AuthenticationManagerResolver<HttpServletRequest> authenticationManagerResolver) throws Exception {
// @formatter:off
http
.authorizeRequests((requests) -> requests
.authorizeRequests((authorize) -> authorize
.mvcMatchers("/**/message/**").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated()
)
.oauth2ResourceServer((resourceServer) -> resourceServer
.oauth2ResourceServer((oauth2) -> oauth2
.authenticationManagerResolver(authenticationManagerResolver)
);
// @formatter:on

View File

@@ -42,16 +42,16 @@ public class OAuth2ResourceServerSecurityConfiguration extends WebSecurityConfig
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((requests) -> requests
.mvcMatchers(HttpMethod.GET, "/message/**").hasAuthority("SCOPE_message:read")
.mvcMatchers(HttpMethod.POST, "/message/**").hasAuthority("SCOPE_message:write")
.anyRequest().authenticated()
.authorizeRequests((authorize) -> authorize
.mvcMatchers(HttpMethod.GET, "/message/**").hasAuthority("SCOPE_message:read")
.mvcMatchers(HttpMethod.POST, "/message/**").hasAuthority("SCOPE_message:write")
.anyRequest().authenticated()
)
.oauth2ResourceServer((resourceServer) -> resourceServer
.opaqueToken((opaqueToken) -> opaqueToken
.introspectionUri(this.introspectionUri)
.introspectionClientCredentials(this.clientId, this.clientSecret)
)
.oauth2ResourceServer((oauth2) -> oauth2
.opaqueToken((opaque) -> opaque
.introspectionUri(this.introspectionUri)
.introspectionClientCredentials(this.clientId, this.clientSecret)
)
);
// @formatter:on
}

View File

@@ -40,14 +40,12 @@ public class OAuth2ResourceServerSecurityConfiguration extends WebSecurityConfig
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((requests) -> requests
.mvcMatchers("/message/**").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated()
.authorizeRequests((authorize) -> authorize
.mvcMatchers("/message/**").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated()
)
.oauth2ResourceServer((resourceServer) -> resourceServer
.jwt((jwt) -> jwt
.decoder(jwtDecoder())
)
.oauth2ResourceServer((oauth2) -> oauth2
.jwt((jwt) -> jwt.decoder(jwtDecoder()))
);
// @formatter:on
}

View File

@@ -38,9 +38,9 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((requests) -> requests
.mvcMatchers("/", "/public/**").permitAll()
.anyRequest().authenticated()
.authorizeRequests((authorize) -> authorize
.mvcMatchers("/", "/public/**").permitAll()
.anyRequest().authenticated()
)
.formLogin(withDefaults())
.oauth2Login(withDefaults())