grailsspring-security-rest

set url to refresh token JWT in grails using spring security rest


I´m using spring security rest. Actually to refresh token im using this url: /oauth/access_token?grant_type=refresh_token&refresh_token=token

However i'm using api rest and I want to use /api/oauth to refresh token instead of /oauth.

I tried redirect in urlMappings, but response 404 not found.

"/api/oauth"(redirect: '/oauth')

Solution

  • "/api/oauth"(redirect: '/oauth')

    As you found, that mapping won't work but there may not be a good reason to use a redirect anyway. The plugin provides a mapping like this:

    "/oauth/access_token"(controller: 'restOauth', action: 'accessToken')
    

    (see https://github.com/alvarosanchez/grails-spring-security-rest/blob/d5940921b4aea466a961957e0599321d01e4c6de/spring-security-rest/grails-app/controllers/grails/plugin/springsecurity/rest/RestOauthUrlMappings.groovy#L24)

    You can map whatever url you like to that controller. You could do this...

    "/api/oauth"(controller: 'restOauth', action: 'accessToken')