Skip to content

SEC-2419: Allow setting the publish authz success flag #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import org.springframework.security.access.AccessDecisionManager;
import org.springframework.security.access.AccessDecisionVoter;
import org.springframework.security.access.event.AuthorizationFailureEvent;
import org.springframework.security.access.event.AuthorizedEvent;
import org.springframework.security.access.vote.AffirmativeBased;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.SecurityConfigurer;
Expand Down Expand Up @@ -64,6 +66,7 @@
abstract class AbstractInterceptUrlConfigurer<C extends AbstractInterceptUrlConfigurer<C,H>, H extends HttpSecurityBuilder<H>> extends
AbstractHttpConfigurer<C, H>{
private Boolean filterSecurityInterceptorOncePerRequest;
private Boolean filterSecurityPublishAuthorizationSuccess;

private AccessDecisionManager accessDecisionManager;

Expand All @@ -77,6 +80,9 @@ public void configure(H http) throws Exception {
if(filterSecurityInterceptorOncePerRequest != null) {
securityInterceptor.setObserveOncePerRequest(filterSecurityInterceptorOncePerRequest);
}
if(filterSecurityPublishAuthorizationSuccess != null) {
securityInterceptor.setPublishAuthorizationSuccess(filterSecurityPublishAuthorizationSuccess);
}
securityInterceptor = postProcess(securityInterceptor);
http.addFilter(securityInterceptor);
http.setSharedObject(FilterSecurityInterceptor.class, securityInterceptor);
Expand Down Expand Up @@ -134,6 +140,21 @@ public R filterSecurityInterceptorOncePerRequest(
return getSelf();
}

/**
* Allows setting if the {@link FilterSecurityInterceptor} should send events when authorization is successful.
* By default only {@link AuthorizationFailureEvent}s will be published. If you set this property to true,
* {@link AuthorizedEvent}s will also be published.
*
* @param filterSecurityPublishAuthorizationSuccess if the {@link FilterSecurityInterceptor} should send events
* when authorization is successful
* @return the {@link AbstractInterceptUrlConfigurer} for further customization
*/
public R filterSecurityPublishAuthorizationSuccess(
boolean filterSecurityPublishAuthorizationSuccess) {
AbstractInterceptUrlConfigurer.this.filterSecurityPublishAuthorizationSuccess = filterSecurityPublishAuthorizationSuccess;
return getSelf();
}

/**
* Returns a reference to the current object with a single suppression of
* the type
Expand Down