나는 처음으로 grails 애플리케이션을 개발 중이며 일부 페이지는 관리자 만 볼 수 있도록 보호하고 다른 사용자에게는 일부 권한을 부여하려고합니다.grails에서 액세스 제어, 역할 및 권한
grails에 Apache Shiro 플러그인을 사용하고 있습니다.
이부트 스트랩에서 내 샘플 코드이
class BootStrap {
def init = { servletContext ->
def adminRole
if(ShiroRole.findByName("Admin".isEmpty())){
adminRole = new ShiroRole(name: "Administrator")
adminRole.addToPermissions("*:*")
adminRole.addToPermissions("admin")
adminRole.save()
// '사용자'처럼 보이는 이제 모든 관리자 권한 }
if (ShiroUser.findAllByUsername("user").isEmpty()) {
def user = new ShiroUser(username: "user", passwordHash: new Sha256Hash("pass").toHex())
user.addToPermissions("*:*")
user.addToRoles(adminRole)
user.save()
}
if (ShiroUser.findAllByUsername("Guest").isEmpty()) {
def user = new ShiroUser(username: "Guest", passwordHash: new Sha256Hash("pass").toHex())
user.addToPermissions("inventory:*")
user.save()
}
}
def destroy = {
}
}
내 ShiroSecurityFilters이
모양을 가지고class ShiroSecurityFilters {
def filters = {
all(uri: "/**") {
before = {
// Ignore direct views (e.g. the default main index page).
if (!controllerName) return true
// Access control by convention.
accessControl()
}
}
}
}
발판에만 '손님'액세스 권한을 부여하고 싶습니다. 그러나 내 응용 프로그램에서 일단 사용자 "Guest"가 로그인하여 다른 컨트롤러에 액세스 할 수 있지만 그럴 필요는 없습니다. 도와 주셔서 감사합니다.
시로 (Shiro) 역할, 액세스 제어 및/또는 권한을 사용하는 것이 더 나을 경우 알려 주시기 바랍니다.
고맙습니다.