Spring SAML Security Confirmation Expiration Application

I am confused with the expiration of the SAML approval and the expiration of the application.

In simple words, when we have an application deployed in a container, a session is created. The end of this session can be controlled using the following entry in web.xml

<session-config> <session-timeout>60</session-timeout> </session-config> 

Moving, when I have Spring Security with the SAML extension, obviously the same session concept applies. (I am deploying the application in WildFly 8.2, if that matters)

Also, when an application session expires, the logout behavior seems to be equivalent to the concept of Local Logout.

So far so good. Now let's say that SAML approval is good for 2 hours, and the user is active for 2 hours. What then should happen with the subsequent request? Should he re-login to the IDP? But is it really inconvenient for the user? If an application is redirected to IDP to log in after 2 hours with expiration, how should AJAX requests be handled?

This refers to the issue here.

+5
source share
1 answer

Spring SAML issues an ExpiringUsernameAuthenticationToken for authenticated users. The token begins to return false in its isAuthenticated() method as soon as the SAML Assertion used to authenticate the user reaches its sessionNotOnOrAfter time.

This behavior can be disabled by overriding SAMLAuthenticationProvider and changing the getExpirationDate(credential) method, which returns the time when the statement expires, or null if it never happens. Then the application will rely entirely on the expiration of the session configured in the container.

As soon as the ExpiringUsernameAuthenticationToken expires, Spring Security will pass the current token to the AuthenticationManager (configured in securityContext.xml under <security:authentication-manager> ).

You can influence what happens next by adding your own AuthenticationProvider capable of handling the ExpiringUsernameAuthenticationToken . Otherwise, the system crashes with a ProviderNotFoundException or some other AuthenticationException like BadCredentialsException (in case you are simultaneously using username and password authentication).

The exception is subsequently handled by an ExceptionTranslationFilter , which starts a new authentication process, invoking EntryPoint configured authentication, for example. SAMLEntryPoint , which either starts IDP default authentication or displays an IDP selection page. The process, as you say, will also perform a local logoff.

By default, the system behaves the same for all HTTP calls - AJAX or not. You can define other behavior by splitting your API and regular URLs into separate <security:http> elements and use different EntryPoints ( AuthenticationEntryPoint interface) for each of them. For example, Http403ForbiddenEntryPoint might be appropriate for your AJAX calls.

+5
source

All Articles