Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: pass ip address to authentication provider

  1. #1
    Join Date
    May 2005
    Posts
    23

    Default pass ip address to authentication provider

    i have a requirement that i need to pass the source ip address to the backend when authenticating a user.

    i've already had to write a custom PasswordAuthenticationDao implementation b/c i am authenticating against a web service call, but the interface only allows for a username and password, and no other information. i'm not seeing anything that would allow me to get at the source ip.

    am i going to need to write a whole bunch of custom code to accomplish this, or is there already existing code that i can leverage?
    -jae

  2. #2
    Join Date
    Sep 2005
    Posts
    10

    Default Very hacky, but...

    If you are implementing your own form based login you could concat the ip onto the username, then strip it off in your PasswordAuthenticationDAO impl.

  3. #3
    Join Date
    May 2005
    Posts
    23

    Default

    no - i'm just using the standard acegi mechanisms and not rolling my own.

    i'm thinking that i could pass this information around as "details" in the Authentication object, and then extend the PasswordAuthenticationDao to allow for an additional object to be passed in that contains any extra information and then extend the PasswordDaoAuthenticationProvider to pass the object when it makes the call do the authentication dao.

    of course, if there's an easier way to do this already, i'd love to hear about it.
    -jae

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

    Default

    Use ((WebAuthenticationDetails)authentication.getDetai ls()).getRemoteAddress() within your DaoAuthenticationProvider subclass.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  5. #5
    Join Date
    May 2005
    Posts
    23

    Default

    thx for the reply - i take it that means i'm still going to have to extend the PasswordAuthenticationDao to allow passing of the ip address though.

    if there is other interest in this, i'd be happy to share the implementation when it's done.
    -jae

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

    Default

    I wouldn't recommend using PasswordAuthenticationDao, as it's likely to be removed in a future version of Acegi Security because it's only used by the LDAP DAO and I will probably refactor the LDAP DAO into a fully-fledged AuthenticationProvider.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  7. #7
    Join Date
    May 2005
    Posts
    23

    Default

    could you provide an approach that you would use?

    if PasswordAuthenticationDao is going to removed, what mechanism will be left to ppl who need to write custom password authentication code? tapping into the LDAP dao instead?
    -jae

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

    Default

    Subclass DaoAuthenticationProvider and override isPasswordCorrect(Authentication, UserDetails). The Authentication will contain the IP address as discussed above, and the UserDetails will have been obtained from your AuthenticationDao. Would that meet your needs?
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  9. #9
    Join Date
    May 2005
    Posts
    23

    Default

    thx for the response.

    i'm not 100% sure if that will meet my needs or not. the current interface i am working with requires that the ip address be sent as part of the request, so it would have to be an input parameter on the PasswordAuthenticationDao.

    i could just create my own implementation of the AuthenticationProvider, but then i'd have to duplicate all the "if user enabled" type code since i am leveraging that already to block users from the site, etc.

    it seems this could be more easily acheived with some refactoring of the AuthenticationProvider classes (which both have duplicate code) to add in this type of functionality. i would actually think this type of thing would be somewhat common for custom authentication mechanisms - and perhaps a future revision could just include the WebAuthenticationDetails (or an AuthenicationDetails object that needs to be cast) so this type of additional information could be accessed.

    i've managed to push off this requirement for now, but i will have to circle back to it at some point. i'd be very happy to continue this discussion, and help implement a usable solution for all to use when the time comes.
    -jae

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

    Default

    Quote Originally Posted by jgangemi
    the current interface i am working with requires that the ip address be sent as part of the request, so it would have to be an input parameter on the PasswordAuthenticationDao.
    I don't understand. The WebAuthenticationDetails will be part of the request to the DaoAuthenticationProvider, available from inside the Authentication object. Could you please expand?
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

Similar Threads

  1. EJB implemented Data Access Object Authentication Provider
    By ameriquestspring in forum Security
    Replies: 8
    Last Post: Jul 24th, 2006, 09:52 AM
  2. Replies: 2
    Last Post: Oct 13th, 2005, 02:47 PM
  3. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  4. Replies: 8
    Last Post: Dec 7th, 2004, 06:13 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
  •