|
@@ -1281,11 +1281,10 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
|
|
* @Override
|
|
|
* protected void configure(HttpSecurity http) throws Exception {
|
|
|
* http
|
|
|
- * .authorizeHttpRequests((authorizeHttpRequests) ->
|
|
|
- * authorizeHttpRequests
|
|
|
- * .antMatchers("/**").hasRole("USER")
|
|
|
- * )
|
|
|
- * .formLogin(withDefaults());
|
|
|
+ * .authorizeHttpRequests()
|
|
|
+ * .antMatchers("/**").hasRole("USER")
|
|
|
+ * .and()
|
|
|
+ * .formLogin();
|
|
|
* }
|
|
|
* }
|
|
|
* </pre>
|
|
@@ -1302,12 +1301,11 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
|
|
* @Override
|
|
|
* protected void configure(HttpSecurity http) throws Exception {
|
|
|
* http
|
|
|
- * .authorizeHttpRequests((authorizeHttpRequests) ->
|
|
|
- * authorizeHttpRequests
|
|
|
- * .antMatchers("/admin/**").hasRole("ADMIN")
|
|
|
- * .antMatchers("/**").hasRole("USER")
|
|
|
- * )
|
|
|
- * .formLogin(withDefaults());
|
|
|
+ * .authorizeHttpRequests()
|
|
|
+ * .antMatchers("/admin").hasRole("ADMIN")
|
|
|
+ * .antMatchers("/**").hasRole("USER")
|
|
|
+ * .and()
|
|
|
+ * .formLogin();
|
|
|
* }
|
|
|
* }
|
|
|
* </pre>
|
|
@@ -1320,32 +1318,27 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
|
|
* @Configuration
|
|
|
* @EnableWebSecurity
|
|
|
* public class AuthorizeUrlsSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
- *HttpSecurity.java
|
|
|
+ *
|
|
|
* @Override
|
|
|
* protected void configure(HttpSecurity http) throws Exception {
|
|
|
* http
|
|
|
- * .authorizeHttpRequests((authorizeHttpRequests) ->
|
|
|
- * authorizeHttpRequests
|
|
|
- * .antMatchers("/**").hasRole("USER")
|
|
|
- * .antMatchers("/admin/**").hasRole("ADMIN")
|
|
|
- * );
|
|
|
+ * .authorizeHttpRequests()
|
|
|
+ * .antMatchers("/**").hasRole("USER")
|
|
|
+ * .antMatchers("/admin/**").hasRole("ADMIN")
|
|
|
+ * .and()
|
|
|
+ * .formLogin();
|
|
|
* }
|
|
|
* }
|
|
|
* </pre>
|
|
|
- * @param authorizeHttpRequestsCustomizer the {@link Customizer} to provide more
|
|
|
- * options for the {@link AuthorizationManagerRequestMatcherRegistry}
|
|
|
* @return the {@link HttpSecurity} for further customizations
|
|
|
* @throws Exception
|
|
|
- * @since 5.5
|
|
|
+ * @since 5.6
|
|
|
* @see #requestMatcher(RequestMatcher)
|
|
|
*/
|
|
|
- public HttpSecurity authorizeHttpRequests(
|
|
|
- Customizer<AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry> authorizeHttpRequestsCustomizer)
|
|
|
+ public AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry authorizeHttpRequests()
|
|
|
throws Exception {
|
|
|
ApplicationContext context = getContext();
|
|
|
- authorizeHttpRequestsCustomizer
|
|
|
- .customize(getOrApply(new AuthorizeHttpRequestsConfigurer<>(context)).getRegistry());
|
|
|
- return HttpSecurity.this;
|
|
|
+ return getOrApply(new AuthorizeHttpRequestsConfigurer<>(context)).getRegistry();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1366,10 +1359,11 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
|
|
* @Override
|
|
|
* protected void configure(HttpSecurity http) throws Exception {
|
|
|
* http
|
|
|
- * .authorizeHttpRequests()
|
|
|
- * .antMatchers("/**").hasRoles("USER")
|
|
|
- * .and()
|
|
|
- * .formLogin();
|
|
|
+ * .authorizeHttpRequests((authorizeHttpRequests) ->
|
|
|
+ * authorizeHttpRequests
|
|
|
+ * .antMatchers("/**").hasRole("USER")
|
|
|
+ * )
|
|
|
+ * .formLogin(withDefaults());
|
|
|
* }
|
|
|
* }
|
|
|
* </pre>
|
|
@@ -1386,10 +1380,11 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
|
|
* @Override
|
|
|
* protected void configure(HttpSecurity http) throws Exception {
|
|
|
* http
|
|
|
- * .authorizeHttpRequests()
|
|
|
- * .antMatchers("/**").hasRoles("USER")
|
|
|
- * .and()
|
|
|
- * .formLogin();
|
|
|
+ * .authorizeHttpRequests((authorizeHttpRequests) ->
|
|
|
+ * authorizeHttpRequests
|
|
|
+ * .antMatchers("/admin/**").hasRole("ADMIN")
|
|
|
+ * .antMatchers("/**").hasRole("USER")
|
|
|
+ * )
|
|
|
* .formLogin(withDefaults());
|
|
|
* }
|
|
|
* }
|
|
@@ -1407,24 +1402,27 @@ public final class HttpSecurity extends AbstractConfiguredSecurityBuilder<Defaul
|
|
|
* @Override
|
|
|
* protected void configure(HttpSecurity http) throws Exception {
|
|
|
* http
|
|
|
- * .authorizeHttpRequests()
|
|
|
- * .antMatchers("/**").hasRoles("USER")
|
|
|
- * .and()
|
|
|
- * .formLogin();
|
|
|
+ * .authorizeHttpRequests((authorizeHttpRequests) ->
|
|
|
+ * authorizeHttpRequests
|
|
|
+ * .antMatchers("/**").hasRole("USER")
|
|
|
+ * .antMatchers("/admin/**").hasRole("ADMIN")
|
|
|
+ * );
|
|
|
* }
|
|
|
* }
|
|
|
* </pre>
|
|
|
+ * @param authorizeHttpRequestsCustomizer the {@link Customizer} to provide more
|
|
|
+ * options for the {@link AuthorizationManagerRequestMatcherRegistry}
|
|
|
* @return the {@link HttpSecurity} for further customizations
|
|
|
* @throws Exception
|
|
|
* @since 5.5
|
|
|
* @see #requestMatcher(RequestMatcher)
|
|
|
*/
|
|
|
- public HttpSecurity authorizeHttpRequests() throws Exception {
|
|
|
- ApplicationContext applicationContext = getContext();
|
|
|
- Customizer<AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry> authorizeHttpRequestsCustomizer = Customizer
|
|
|
- .withDefaults();
|
|
|
+ public HttpSecurity authorizeHttpRequests(
|
|
|
+ Customizer<AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry> authorizeHttpRequestsCustomizer)
|
|
|
+ throws Exception {
|
|
|
+ ApplicationContext context = getContext();
|
|
|
authorizeHttpRequestsCustomizer
|
|
|
- .customize(getOrApply(new AuthorizeHttpRequestsConfigurer<>(applicationContext)).getRegistry());
|
|
|
+ .customize(getOrApply(new AuthorizeHttpRequestsConfigurer<>(context)).getRegistry());
|
|
|
return HttpSecurity.this;
|
|
|
}
|
|
|
|