mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-31 01:02:14 +00:00
Merge branch '6.0.x'
This commit is contained in:
commit
0fdcde2d6f
@ -50,7 +50,8 @@ import org.springframework.security.web.csrf.CsrfToken;
|
|||||||
*
|
*
|
||||||
* <h2>Shared Objects Created</h2>
|
* <h2>Shared Objects Created</h2>
|
||||||
*
|
*
|
||||||
* No shared objects are created. isLogoutRequest
|
* No shared objects are created.
|
||||||
|
*
|
||||||
* <h2>Shared Objects Used</h2>
|
* <h2>Shared Objects Used</h2>
|
||||||
*
|
*
|
||||||
* The following shared objects are used:
|
* The following shared objects are used:
|
||||||
|
@ -48,8 +48,9 @@ import org.springframework.util.Assert;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* protected void configure(HttpSecurity http) throws Exception {
|
* @Bean
|
||||||
* http.apply(new UrlAuthorizationConfigurer<HttpSecurity>()).getRegistry()
|
* public SecurityFilterChain filterChain(HttpSecurity http, ApplicationContext context) throws Exception {
|
||||||
|
* http.apply(new UrlAuthorizationConfigurer<HttpSecurity>(context)).getRegistry()
|
||||||
* .requestMatchers("/users**", "/sessions/**").hasRole("USER")
|
* .requestMatchers("/users**", "/sessions/**").hasRole("USER")
|
||||||
* .requestMatchers("/signup").hasRole("ANONYMOUS").anyRequest().hasRole("USER");
|
* .requestMatchers("/signup").hasRole("ANONYMOUS").anyRequest().hasRole("USER");
|
||||||
* }
|
* }
|
||||||
@ -201,24 +202,22 @@ public final class UrlAuthorizationConfigurer<H extends HttpSecurityBuilder<H>>
|
|||||||
setApplicationContext(context);
|
setApplicationContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #requestMatchers(HttpMethod, String...)} instead
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AuthorizedUrl requestMatchers(String... patterns) {
|
@Deprecated
|
||||||
return super.requestMatchers(patterns);
|
public MvcMatchersAuthorizedUrl mvcMatchers(HttpMethod method, String... mvcPatterns) {
|
||||||
|
return new MvcMatchersAuthorizedUrl(createMvcMatchers(method, mvcPatterns));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #requestMatchers(String...)} instead
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AuthorizedUrl requestMatchers(HttpMethod method, String... patterns) {
|
@Deprecated
|
||||||
return super.requestMatchers(method, patterns);
|
public MvcMatchersAuthorizedUrl mvcMatchers(String... patterns) {
|
||||||
}
|
return mvcMatchers(null, patterns);
|
||||||
|
|
||||||
@Override
|
|
||||||
public AuthorizedUrl requestMatchers(HttpMethod method) {
|
|
||||||
return super.requestMatchers(method);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AuthorizedUrl requestMatchers(RequestMatcher... requestMatchers) {
|
|
||||||
return super.requestMatchers(requestMatchers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -243,6 +242,32 @@ public final class UrlAuthorizationConfigurer<H extends HttpSecurityBuilder<H>>
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An {@link AuthorizedUrl} that allows optionally configuring the
|
||||||
|
* {@link MvcRequestMatcher#setMethod(HttpMethod)}
|
||||||
|
*
|
||||||
|
* @author Rob Winch
|
||||||
|
*/
|
||||||
|
public final class MvcMatchersAuthorizedUrl extends AuthorizedUrl {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance
|
||||||
|
* @param requestMatchers the {@link RequestMatcher} instances to map
|
||||||
|
*/
|
||||||
|
private MvcMatchersAuthorizedUrl(List<MvcRequestMatcher> requestMatchers) {
|
||||||
|
super(requestMatchers);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public AuthorizedUrl servletPath(String servletPath) {
|
||||||
|
for (MvcRequestMatcher matcher : (List<MvcRequestMatcher>) getMatchers()) {
|
||||||
|
matcher.setServletPath(servletPath);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps the specified {@link RequestMatcher} instances to {@link ConfigAttribute}
|
* Maps the specified {@link RequestMatcher} instances to {@link ConfigAttribute}
|
||||||
* instances.
|
* instances.
|
||||||
|
@ -248,7 +248,7 @@ public class TenantJWSKeySelector
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JWSKeySelector<SecurityContext> fromTenant(String tenant) {
|
private JWSKeySelector<SecurityContext> fromTenant(String tenant) {
|
||||||
return Optional.ofNullable(this.tenantRepository.findById(tenant)) <3>
|
return Optional.ofNullable(this.tenants.findById(tenant)) <3>
|
||||||
.map(t -> t.getAttrbute("jwks_uri"))
|
.map(t -> t.getAttrbute("jwks_uri"))
|
||||||
.map(this::fromUri)
|
.map(this::fromUri)
|
||||||
.orElseThrow(() -> new IllegalArgumentException("unknown tenant"));
|
.orElseThrow(() -> new IllegalArgumentException("unknown tenant"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user