【发布时间】:2013-11-29 08:21:06
【问题描述】:
您好,我使用 Grails 构建的后端和 AngularJS 构建的前端构建应用程序。我想使用 Grails Spring Security Plugin 为我的应用程序提供一些安全性,但我遇到了一些问题。首先,我不知道如何只允许具有指定角色的用户访问专用 URL。
例如我有 3 种类型的 URL
/userspace/** - (eg. http://localhost:8080/MyApp/#/userspace/settings -displays view with user's profile settings)
/adminspace/** - (eg. http://localhost:8080/MyApp/#/adminspace/usersManagement - displays view with registered users)
/rest/** - (eg. http://localhost:8080/MyApp/rest/book - returns JSON list of books, http://localhost:8080/MyApp/book/123 - returns book as JSON with id=123.
我想为ROLE_USER 提供/userspace/ 的访问权限,为ROLE_ADMIN 提供/adminspace/ 的访问权限。
我不知道我应该在Config.goovy 中设置哪些属性才能使其成为可能? url中有angular的#吗?
我也不知道应该如何保护/rest/**。这些 url 用于与后端通信,有时它们由 angular 的 $http 服务从 Angular 的所有人可见的视图控制器调用,但有时它们从受保护的视图中调用。也许方法是让 /rest/** url 可供所有人使用并使用指定的注释,例如。 @Secured(['ROLE_USER']) 在 grails 控制器中?
我会很感激你的帮助
【问题讨论】:
标签: rest angularjs grails spring-security