0
votes

I have installed grails Spring security core plugin with RequestMap to retrieve URL from the database. I assume I have setup everything as its mentioned in the guide. When I start my application(http://localhost:8080/scadmin/index/) I get 'sorry, you are not authorized to view this page'. The admin user authenticated properly but RequestMap isnt allowing me to access the url. What's that I am doing wrong? please help.

config.groovy

grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.tx.sc.auth.User'
grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'com.tx.sc.auth.UserRole'
grails.plugin.springsecurity.authority.className = 'com.tx.sc.auth.Role'
grails.plugin.springsecurity.requestMap.className = 'com.tx.sc.auth.Requestmap'
grails.plugin.springsecurity.securityConfigType = 'Requestmap'

My controller -

class AdminController {
    def index() {
        List<Portal> pList = portalService.listAllPortalInfo()
        render(view: "admin", model:[portalList:pList])
    }
}

Setting Role

def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true)

Admin User

    def adminUser = new User(username: 'admin', password: '12345',email: '[email protected]',enabled: true, accountLocked: false, accountExpired: false, passwordExpired: false).save(flush: true)

Map user and role-

    if (!adminUser.authorities.contains(adminRole)) {
        UserRole.create(adminUser, adminRole, true)
    }

RequestMap-

 new Requestmap(url: '/scadmin/admin/index', configAttribute: 'ROLE_ADMIN').save(flush: true)
1

1 Answers

0
votes

/scadmin/admin/index should be /admin/index - don't include the context.