Results 1 to 6 of 6

Thread: access-denied-page & url

  1. #1
    Join Date
    May 2009
    Location
    Rus
    Posts
    87

    Default access-denied-page & url

    I put this at security context
    Code:
    <http auto-config='true' access-denied-page="/home.action">
    When access is denied for user, it redirects him to home page, but the url address in address bar at browser doesn't change for /home.action. What should I do to correct this? The controller, which processes requests to home.action, extends AbstractController.

  2. #2

    Default

    you could try to add "redirect:" before your url (so it becomes "redirect:/home.action")

  3. #3
    Join Date
    May 2009
    Location
    Rus
    Posts
    87

    Default

    Nope, IllegalArgumentException will throw then. It should begin with "/".

  4. #4

    Default

    you are right.

    The <http>-tag creates a ExceptionTranslationFilter and this filter uses by default a org.springframework.security.ui .AccessDeniedHandlerImpl

    The javadoc of that AccessDeniedHandler states:

    This implementation sends a 403 (SC_FORBIDDEN) HTTP error code. In addition, if a errorPage is defined, the implementation will perform a request dispatcher "forward" to the specified error page view
    So to have the behaviour that you want, you could implement your own AccessDeniedHandler

    And then declare an ExceptionTranslationFilter that uses your AccessDeniedHandler.

    An inconvenience is that the <http>-tag doesn't let you specify another ExceptionHandlerFilter this means you need to manually create you security configuration (filterchain, etc)

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

    Default

    Alternatively just use an MVC controller which handles the URL and does whatever you want.

    Support for a custom AccessDeniedHandler is already part of completed roadmap for Spring Security 3.0:

    http://jira.springsource.org/browse/SEC-1100
    Spring - by Pivotal
    twitter @tekul

  6. #6
    Join Date
    May 2009
    Location
    Rus
    Posts
    87

    Default

    Thanks for answers!

Posting Permissions

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