|
@@ -30,6 +30,7 @@ import org.springframework.security.authorization.AuthorityAuthorizationManager;
|
|
|
import org.springframework.security.authorization.AuthorizationDecision;
|
|
|
import org.springframework.security.authorization.AuthorizationEventPublisher;
|
|
|
import org.springframework.security.authorization.AuthorizationManager;
|
|
|
+import org.springframework.security.authorization.AuthorizationManagers;
|
|
|
import org.springframework.security.authorization.ObservationAuthorizationManager;
|
|
|
import org.springframework.security.authorization.SpringAuthorizationEventPublisher;
|
|
|
import org.springframework.security.config.annotation.ObjectPostProcessor;
|
|
@@ -244,11 +245,14 @@ public final class AuthorizeHttpRequestsConfigurer<H extends HttpSecurityBuilder
|
|
|
* {@link RequestMatcher}s.
|
|
|
*
|
|
|
* @author Evgeniy Cheban
|
|
|
+ * @author Josh Cummings
|
|
|
*/
|
|
|
public class AuthorizedUrl {
|
|
|
|
|
|
private final List<? extends RequestMatcher> matchers;
|
|
|
|
|
|
+ private boolean not;
|
|
|
+
|
|
|
/**
|
|
|
* Creates an instance.
|
|
|
* @param matchers the {@link RequestMatcher} instances to map
|
|
@@ -261,6 +265,16 @@ public final class AuthorizeHttpRequestsConfigurer<H extends HttpSecurityBuilder
|
|
|
return this.matchers;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Negates the following authorization rule.
|
|
|
+ * @return the {@link AuthorizedUrl} for further customization
|
|
|
+ * @since 6.3
|
|
|
+ */
|
|
|
+ public AuthorizedUrl not() {
|
|
|
+ this.not = true;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Specify that URLs are allowed by anyone.
|
|
|
* @return the {@link AuthorizationManagerRequestMatcherRegistry} for further
|
|
@@ -382,7 +396,9 @@ public final class AuthorizeHttpRequestsConfigurer<H extends HttpSecurityBuilder
|
|
|
public AuthorizationManagerRequestMatcherRegistry access(
|
|
|
AuthorizationManager<RequestAuthorizationContext> manager) {
|
|
|
Assert.notNull(manager, "manager cannot be null");
|
|
|
- return AuthorizeHttpRequestsConfigurer.this.addMapping(this.matchers, manager);
|
|
|
+ return (this.not)
|
|
|
+ ? AuthorizeHttpRequestsConfigurer.this.addMapping(this.matchers, AuthorizationManagers.not(manager))
|
|
|
+ : AuthorizeHttpRequestsConfigurer.this.addMapping(this.matchers, manager);
|
|
|
}
|
|
|
|
|
|
}
|