Continued issues with trying to integrate @Secured into a Dropwizard app, which is basically embedded Jetty + JAX-RS.
I import my security XML file via my Spring config class
The XML config is enabled with @Secured supportCode:@Configuration @ImportResource("classpath:pros-schedule-security.xml") @ComponentScan(basePackageClasses = ScheduleService.class)
A @DELETE method on my JAX-RS class is configured to explicitly disallow access unless you have delete permissionsCode:<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> <global-method-security secured-annotations="enabled" mode="aspectj" authentication-manager-ref="prosAuthenticationManager"/> <http use-expressions="true" create-session="stateless" realm="PROS" authentication-manager-ref="prosAuthenticationManager" auto-config="true"> <http-basic /> <intercept-url pattern="/**" access="isAuthenticated()"/> </http> </beans:beans>
Yes, when I call a DELETE HTTP command with a user which does not have this permission it goes through.Code:@DELETE @Secured("ROLE_DELETE") @Path("/{countryCode}") public Response delete(@PathParam("countryCode") String countryCode) {
The log clearly shows that user only has ROLE_READ authority, but not ROLE_DELETE, yet is still able to successfully reach the method:
What am I doing wrong here? How come the @Secured annotation is getting totally ignored?Code:DEBUG [2012-11-11 20:20:22,871] org.springframework.security.web.FilterChainProxy: /schedule/services/rest/country/23 at position 1 of 9 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter' DEBUG [2012-11-11 20:20:22,877] org.springframework.security.web.FilterChainProxy: /schedule/services/rest/country/23 at position 2 of 9 in additional filter chain; firing Filter: 'LogoutFilter' DEBUG [2012-11-11 20:20:22,877] org.springframework.security.web.FilterChainProxy: /schedule/services/rest/country/23 at position 3 of 9 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter' DEBUG [2012-11-11 20:20:22,877] org.springframework.security.web.FilterChainProxy: /schedule/services/rest/country/23 at position 4 of 9 in additional filter chain; firing Filter: 'DefaultLoginPageGeneratingFilter' DEBUG [2012-11-11 20:20:22,877] org.springframework.security.web.FilterChainProxy: /schedule/services/rest/country/23 at position 5 of 9 in additional filter chain; firing Filter: 'BasicAuthenticationFilter' DEBUG [2012-11-11 20:20:22,883] org.springframework.security.web.authentication.www.BasicAuthenticationFilter: Basic Authentication Authorization header found for user 'read' DEBUG [2012-11-11 20:20:22,888] org.springframework.security.web.authentication.www.BasicAuthenticationFilter: Authentication success: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@ca27776: Principal: read; Credentials: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: ROLE_READ DEBUG [2012-11-11 20:20:22,888] org.springframework.security.web.FilterChainProxy: /schedule/services/rest/country/23 at position 6 of 9 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter' DEBUG [2012-11-11 20:20:22,889] org.springframework.security.web.FilterChainProxy: /schedule/services/rest/country/23 at position 7 of 9 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter' DEBUG [2012-11-11 20:20:22,890] org.springframework.security.web.authentication.AnonymousAuthenticationFilter: SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@ca27776: Principal: read; Credentials: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: ROLE_READ' DEBUG [2012-11-11 20:20:22,890] org.springframework.security.web.FilterChainProxy: /schedule/services/rest/country/23 at position 8 of 9 in additional filter chain; firing Filter: 'ExceptionTranslationFilter' DEBUG [2012-11-11 20:20:22,890] org.springframework.security.web.FilterChainProxy: /schedule/services/rest/country/23 at position 9 of 9 in additional filter chain; firing Filter: 'FilterSecurityInterceptor' DEBUG [2012-11-11 20:20:22,902] org.springframework.security.web.access.intercept.FilterSecurityInterceptor: Secure object: FilterInvocation: URL: /schedule/services/rest/country/23; Attributes: [isAuthenticated()] DEBUG [2012-11-11 20:20:22,902] org.springframework.security.web.access.intercept.FilterSecurityInterceptor: Previously Authenticated: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@ca27776: Principal: read; Credentials: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: ROLE_READ DEBUG [2012-11-11 20:20:22,926] org.springframework.security.access.vote.AffirmativeBased: Voter: org.springframework.security.web.access.expression.WebExpressionVoter@273abfd5, returned: 1 DEBUG [2012-11-11 20:20:22,926] org.springframework.security.web.access.intercept.FilterSecurityInterceptor: Authorization successful DEBUG [2012-11-11 20:20:22,926] org.springframework.security.web.access.intercept.FilterSecurityInterceptor: RunAsManager did not change Authentication object DEBUG [2012-11-11 20:20:22,927] org.springframework.security.web.FilterChainProxy: /schedule/services/rest/country/23 reached end of additional filter chain; proceeding with original chain DEBUG [2012-11-11 20:20:23,339] org.springframework.security.web.access.ExceptionTranslationFilter: Chain processed normally DEBUG [2012-11-11 20:20:23,339] org.springframework.security.web.context.SecurityContextPersistenceFilter: SecurityContextHolder now cleared, as request processing completed


Reply With Quote