Grails Spring Security Rest - 403 Forbidden -
so started learning grails, , trying incorporate spring security rest plugin app, plugin installed in addition spring security core working. in rest client, when hit "api/login" able access token , says have role of "role_admin", when try hit using that, keep getting 403 forbidden. in postman, rest client using, have authorization header "bearer {key}", url of "http://localhost:8080/test/api/secret" , gives 403 error. trying setup log4j logging see other issues, know should into, appreciated. provided classes below if helps, used default values such urlmappings.
randomcontroller.groovy
package test import grails.plugin.springsecurity.annotation.secured @secured(['is_authenticated_anonymously']) class mycontroller { @secured(['role_admin']) def secret() { render "you have access!!!" } }
bootstrap.groovy
class bootstrap { def init = { servletcontext -> def adminrole = new secrole(authority: 'role_admin').save(flush: true) def testuser = new secuser(username: 'bob', password: 'test') testuser.save(flush: true) secusersecrole.create testuser, adminrole, true } def destroy = { } }
urlmappings.groovy
class urlmappings { static mappings = { "/$controller/$action?/$id?(.$format)?"{ constraints { // apply constraints here } } "/api/$controller/$action?/$id?(.$format)?"{ constraints { // apply constraints here } } "/"(view:"/index") "500"(view:'/error') } }
for can see code posted, if invoke url http://localhost:8080/test/api/secret, should execute default action (maybe index) in secretcontroller
controller posted called mycontroller.
to investigate further, should enable more verbose logging using log4j configuration suggested in doc http://alvarosanchez.github.io/grails-spring-security-rest/1.5.1/docs/guide/debugging.html
Comments
Post a Comment