I have implemented a WebService that use OAuth2 (using Spring) for authentication.
It works but, when i access the url authorize i have (sometime) different behaviour:
- I access to authorize and the service redirect me to Login Page
- After logged in the service redirect me on index.jsp page
The other behavior (that is the right):
- Access to autorize page and the service redirect me to Login Page
- After logged in, the service redirect me to authorize page where i can select "Accept" or "Decline", and after that i can access to the service (with given token)
I have seen that the behavior i have is this
- Acess to authorize -> Redirect to Login page
- After logged in -> i get redirected to index.jsp
- I close the browser
- Access to authorize -> Redirect to Login page
- After logged in -> I get redirected to authorize page (where i have Accept / Decline)
This is a part of my secdurityConfiguration.xml
Code:
<authentication-manager>
<authentication-provider ref="customAuthenticationProvider" />
</authentication-manager>
<authentication-manager id="oauthClientAuthenticationManager">
<authentication-provider user-service-ref="clientDetailsUserService">
<password-encoder ref="passwordEncoder" />
</authentication-provider>
</authentication-manager>
<oauth2:authorization-server token-services-ref="tokenServices"
client-details-service-ref="webServiceClientService"
user-approval-page="oauth/authorize" error-page="oauth/error">
<oauth2:authorization-code />
</oauth2:authorization-server>
<beans:bean id="resourceServerFilter"
class="it.dirimo.site.OAuthSigningTokenAuthenticationFilter">
<beans:property name="authenticationEntryPoint"
ref="oauthAuthenticationEntryPoint" />
<beans:property name="tokenServices" ref="tokenServices" />
<beans:property name="resourceId" value="SUPPORT" />
</beans:bean>
<global-method-security pre-post-annotations="enabled" order="0"
proxy-target-class="true">
<expression-handler ref="methodSecurityExpressionHandler" />
</global-method-security>
<http security="none" pattern="/resource/**" />
<http security="none" pattern="/favicon.ico" />
<http use-expressions="true" create-session="stateless"
authentication-manager-ref="oauthClientAuthenticationManager"
entry-point-ref="oauthAuthenticationEntryPoint" pattern="/oauth/token">
<intercept-url pattern="/oauth/token"
access="hasAuthority('OAUTH_CLIENT')" />
<http-basic />
<access-denied-handler ref="oauthAccessDeniedHandler" />
<expression-handler ref="webSecurityExpressionHandler" />
</http>
<http use-expressions="true" create-session="stateless"
entry-point-ref="oauthAuthenticationEntryPoint" pattern="/services/**">
<intercept-url pattern="/services/**"
access="hasAuthority('OWNER')" />
<custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
<expression-handler ref="webSecurityExpressionHandler" />
</http>
<http use-expressions="true">
<intercept-url pattern="/oauth/**" access="hasAuthority('OWNER')" />
<intercept-url pattern="/login/**" access="permitAll() "/>
<intercept-url pattern="/push/**" access="permitAll()" />
<intercept-url pattern="/logout" access="permitall()" />
<intercept-url pattern="/**" access="isFullyAuthenticated()" />
<form-login default-target-url="/" login-page="/login"
login-processing-url="/login/submit"
authentication-failure-url="/login?loginFailed"
username-parameter="username" password-parameter="password" />
<logout logout-url="/logout" logout-success-url="/login?loggedOut"
delete-cookies="JSESSIONID" invalidate-session="true" />
<session-management invalid-session-url="/login"
session-fixation-protection="changeSessionId">
<concurrency-control error-if-maximum-exceeded="true" max-sessions="1000"
session-registry-ref="sessionRegistry" />
</session-management>
<expression-handler ref="webSecurityExpressionHandler"/>
</http>
I have the same behaviour un Chapter 28. Sometime i get redirected to "Accept/Decline" page and sometime to Ticket Home(this is wrong).
The behaviour is totally random. Sometime i get redirected well for 10 times, and sometime to all query i get redirected wrong (in Ticket Home Page)