Grails 애플리케이션에서 spring-security-core : 2.0.0을 사용 중입니다. 그러나 성공적인 인증 후에도 페이지에는 '죄송합니다.이 페이지를 볼 권한이 없습니다.'라는 메시지가 표시됩니다. ROLE_ADMIN (으)로 로그인 했으므로 역할에 따라 두 페이지로 리디렉션하고 싶습니다. 관리자 역할에 대해서는 관리자 페이지로 이동해야하며 사용자 역할에 대해서는 사용자 페이지로 이동하려고합니다.spring-security-core의 인증 문제 : 2.0.0
가 여기 내 UrlMappings.groovy입니다
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
/* get "/"(controller:"book", action:"index")
get "/books/create"(controller:"book", action:"create")
post "/books"(controller:"book", action:"save")
get "/books/$id"(controller:"book", action:"show")
get "/books/$id/edit"(controller:"book", action:"edit")
put "/books/$id"(controller:"book", action:"update")
delete "/books/$id"(controller:"book", action:"delete")
*/
"/"(view:'auth',controller:'login')
"/admin"(view:'adminPage')
"500"(view:'/error')
}
}
LoginController.groovy는
package com.standout.utilityapplication
import grails.plugin.springsecurity.annotation.Secured
class LoginController {
def springSecurityService
@Secured(['ROLE_ADMIN', 'ROLE_USER'])
def index() {
println "INDEX PAGE RENDER FROM MY CONTROLLER";
def roles = springSecurityService.getPrincipal().getAuthorities()
println roles;
if(roles.toString().contains("ROLE_ADMIN"))
{
println "admin"
redirect(uri: "/admin")
}
else
{
println "not admin"
redirect(uri: "/dataentry")
}
}
@Secured('ROLE_USER')
def nonadmin()
{
println("===notadmin")
}
@Secured('ROLE_ADMIN')
def admin()
{
println("====admin")
}
}