Search code examples
grailsspring-security

Grails+SpringSecurityCore: how to respond custom HTTP staus when not authorized?


How to respond any http status error (403 for example) when user not logged in?

AS IS: there is an implemented user authentication using spring security core. User is able to log in with username and password. When user tries to access any resource before authentocation, system redirects to log in page and respond 200 OK HTTP status.

Implemented on Grails 2.4.3 + SpringSecurityCore 2.0-RC4

TO BE: 200 OK status should be changed to any error (like 403)


Solution

  • The solution was found (much thanks to @Koloritnij): add to resources.groovy

    authenticationEntryPoint(org.springframework.security.web.authentication.Http403ForbiddenEntryPoint)
    

    This question happens related to Grails, SpringSecurity - disable redirect if not logged