Results 1 to 4 of 4

Thread: Remember Me & CredentialsExpiredException

  1. #1
    Join Date
    Dec 2004
    Location
    New York
    Posts
    17

    Default Remember Me & CredentialsExpiredException

    Hi,

    I use UserDetails.isCredentialsNonExpired(), which causes a CredentialsExpiredException, to force the user to change their passwords when they expire. I have a custom AuthenticationProcessingFilterEntryPoint that redirects to a special page so they can change their password.

    This does not work with the default implementation of Remember Me because it doesn't call isCredentialsNonExpired after it authenticates the user.

    I could write my own implementation of Remember Me that does this, but it seems to make more sense that there should be a common system that does these kinds of checks. So after any sort of authentication, it should check the UserDetails object for its various conditions and then redirect the user accordingly. That way each authentication ProcessingFilter won't have to handle this on its own. (say you use form, basic, and remember me, thats 3 authentication places where you have to know what to do if the user's credentials expired).

    Any thoughts on this? Maybe all the ProcessingFilters should extend a base class that handle this stuff.

    --Alex

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default Re: Remember Me & CredentialsExpiredException

    Quote Originally Posted by aburgel
    Any thoughts on this? Maybe all the ProcessingFilters should extend a base class that handle this stuff.
    AbstractProcessingFilter is the shared authentication base. If a CredentialsExpiredException is thrown, it will redirect to the AbstractProcessingFilter.credentialsExpiredFailure Url. Would that mechanism allow you to catch expired passwords and force a password change? Recall AuthenticationException is available from the HttpSession attribute AbstractProcessingFilter.ACEGI_SECURITY_LAST_EXCEP TION_KEY and this in turn contains AuthenticationException.getAuthentication() (ie the Authentication that caused the exception). This would allow you to know who the user was, and populate the change password form. It would presumably post to a custom controller that can change the underlaying authentication repository's password, and then set the ContextHolder with the fully authenticated Authentication.

    Just a thought...

  3. #3
    Join Date
    Dec 2004
    Location
    New York
    Posts
    17

    Default

    Hi,

    Looks like some of this stuff is still in CVS, like AbstractProcessingFilter.credentialsExpiredFailure Url.

    What would be useful for me is if RememberMeProcessingFilter also extended AbstractProcessingFilter. This is not in CVS yet... is there a plan to do this? That way it could have the same behavior if the user's credentials are expired.

    --Alex

  4. #4
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    Quote Originally Posted by aburgel
    What would be useful for me is if RememberMeProcessingFilter also extended AbstractProcessingFilter..... That way it could have the same behavior if the user's credentials are expired.
    The trouble with this is AbstractProcessingFilter imposes some abstract methods that don't fit nicely in with the RememberMeProcessingFilter model. This is also the case with BASIC and Digest authentication processing filters.

    The other issue is RememberMeServices don't usually through exceptions, such as CredentialsExpiredException. What I have done for you is add the folowing to TokenBasedRememberMeServices:

    Code:
                            // Immediately reject if the user is not allowed to login
                            if (!userDetails.isAccountNonExpired()
                                || !userDetails.isCredentialsNonExpired()
                                || !userDetails.isEnabled()) {
                                cancelCookie(request, response,
                                    "Cookie token[0] contained username '"
                                    + cookieTokens[0]
                                    + "' but account has expired, credentials have expired, or user is disabled");
    
                                return null;
                            }
    Thus the expired credentials will cause the remembered token to be invalidated, and then the user will presumably attempt to login manually and be handled by the normal expired credentials process.

Similar Threads

  1. Replies: 2
    Last Post: Sep 20th, 2005, 12:59 AM
  2. Spring code remarks
    By Alarmnummer in forum Architecture
    Replies: 18
    Last Post: Apr 7th, 2005, 07:17 AM
  3. Triggering Remember Me
    By matthewdfleming in forum Security
    Replies: 1
    Last Post: Mar 17th, 2005, 05:57 PM
  4. Remember Me vs. Anonymous Authentication
    By eisenb in forum Security
    Replies: 2
    Last Post: Mar 11th, 2005, 01:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •