Results 1 to 7 of 7

Thread: Change password

  1. #1
    Join Date
    Oct 2004
    Posts
    8

    Default Change password

    I have a problem in an application that is using Acegi for authentication. I have a Spring controller that allows the user to change their password in the database. When the password has been changed, the user keeps getting redirected back to the login page because I think the credentials they have in memory are different than what's in the database.

    What are we suppose to do with respect with Acegi after a process of changing a password to fix this situation?

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

    Default

    That shouldn't happen as DaoAuthenticationProvider will go back to the authentication repository to lookup the latest password if it does not match. Is your AuthenticationDao returning the updated password (try logging it in your AuthenticationDao)? Are you using the latest version of DaoAuthenticationProvider (from release 0.6.1)?

  3. #3
    Join Date
    Oct 2004
    Posts
    8

    Default

    Ben,

    Maybe I'm a bit confused on how exactly how to use the security framework. Is there already a module in Acegi decicated to changing a password for a database repository? If not, what is the best way to implement it for a web application.

    I have it right now as a Spring MVC controller that handles that request and calls a business manager/service class I wrote that changes the password in the database. But, I'm trying to figure out how to tell the Acegi Security System that such an event (change password) has occurred and have the Authentication object that is in the HttpSession be updated with the new password.

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

    Default

    There is no out-of-the-box approach to changing passwords. Your approach sounds fine. I think your problem is with caching. Are you using the NullUserCache or EhCacheBasedUserCache? Is your AuthenticationDao fronting an ORM layer that is caching? Did you try logging what the AuthenticationDao is retrieving from the database, to ensure it is even giving Acegi Security the new (changed) password for comparison purposes?

  5. #5
    Join Date
    Oct 2004
    Posts
    8

    Default

    I am using the NullUserCache for now and I'm using Hibernate as ORM layer and have a class that implements the AuthenticationDao interface.

    I am still having no luck with resetting the username/credential of the user in memory after changing the password.

    What I am doing is after my Controller (I am using the Spring MVC framework) handles the change password request by delegating the work to a service class which updates the user's password in the database. I create a new UsernamePasswordAuthenticationToken in the session under the key HttpSessionIntegrationFilter.ACEGI_SECURITY_AUTHEN TICATION_KEY with the new password and keep the username, details and permissions. But, when the controller forwards to the next page, the user's credentials are still showing the old password.

    Sorry for the many questions or if this is a very trivial question that I should understand right away, but I cannot figure out what I am doing wrong exactly.

    Do you any suggestions?

    Thanks,
    -ray

  6. #6
    Join Date
    Oct 2004
    Posts
    8

    Default

    I figured out my problem. Not only did i have to change the Authentication object in the Session but I also had to update the SecureContext.

    Thanks for all the help though.

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

    Default

    Just double-check you really need to edit the HttpSession.

    The AbstractIntegrationFilter is responsible for updating the HttpSession with the contents of the ContextHolder at the end of each request. Also, whenever you're needing access to the Authentication you should be obtaining it from the ContextHolder. As such the fact the HttpSession is being used to store the Authentication should be transparent to your application - just update the ContextHolder.

Similar Threads

  1. how to change password without logging out
    By pasha in forum Security
    Replies: 9
    Last Post: May 6th, 2008, 04:14 PM
  2. change password with dao not being refreshed
    By tractis_rectis in forum Security
    Replies: 6
    Last Post: Oct 26th, 2005, 03:14 PM
  3. Forgot password (e.g. secret question) using Acegi
    By lowerymb77 in forum Security
    Replies: 1
    Last Post: Oct 16th, 2005, 10:46 PM
  4. Change Password interim step
    By markstgodard in forum Security
    Replies: 5
    Last Post: Jul 19th, 2005, 02:59 AM
  5. Replies: 4
    Last Post: Jun 14th, 2005, 09:28 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
  •