一般に、目的の動作を保証する方法は多数あります。
標準の grails フィルターと組み合わせて shiro を使用することをお勧めします。
class SecurityFilters {
def filters = {
all(uri: "/**") {
before = {
// Ignore direct views (e.g. the default main index page).
if (!controllerName) return true
accessControl {
// add your logic here to determine if user has access or not
// return true if user has access, false otherwise
// get current user
def user = yourService.getCurrentUser()
// get projects the user is allowed to access
def projects = yourService.getProjectsOfUser(user)
// get the project the user tries to access
def currentProject = Project.get(params.projectId)
// is current project in list of permitted projects?
return project.contains(currentProject)
}
}
}
}
}
または、独自に実装してPermission
使用することもできますSecurityUtils.subject.isPermitted()
。
最適な実装は、アプリのアーキテクチャによって異なります。さらにヘルプが必要な場合は、アプリの詳細を提供する必要があります。
それが役立つことを願っています!