Results 1 to 7 of 7

Thread: how to do ip access control

  1. #1
    Join Date
    Jan 2007
    Location
    Taipei, Taiwan
    Posts
    3

    Default how to do ip access control

    Hi there,

    I wonder to know if it is possible to use acegi security to control which ip address can access my system? I am very new to acegi, and I spend a lot of time to look up every acegi filters but couldn't find a suitable one to do the job. Any idea will be appreciated.

    Regards,
    Liang

  2. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I think you'll have to write this code yourself. It should be very straight forward though to extend on the existing filters. You could for instance overide AuthenticationProcessingFilter.attemptAuthenticati on, check if the IP address is invalid. If it is, throw an AuthenticationException. If not super.attemptAuthentication.

    I'm sure there are lots of other ways of doing it, this is just one example.

  3. #3
    Join Date
    Jan 2007
    Location
    Taipei, Taiwan
    Posts
    3

    Default

    Thank you karldmoore, I followed your instruction, and it worked.

  4. #4
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    The remote address is also contained in the authentication details object which is set in the authentication request token by AuthenticationProcessingFilter:

    http://acegisecurity.org/multiprojec...ilter.html#120

    So you can access it at any point during the authentication process (e.g. in your authentication provider).

  5. #5
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Its a fair point! To be honest I've used both approaches. When the user had IP restrictions, there was a check in DaoAuthenticationProvider.additionalAuthentication Check (if memory serves). We had another product which had general IP restrictions, that was done in the filter. Both worked fine, not sure if either is better or worse.

  6. #6
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    I guess it depends on the context. For example, if users are required to login from particular terminals and the terminal infromation is loaded with the rest of the user data, then it probably makes more sense to do it in the provider.

  7. #7
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Agreed. That was the case in the previous example, user specific settings vs. system configuration. We went with provider for user specific and filter for system configuration.

Posting Permissions

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