grails - 使用基于 ldap 角色的授权进行身份验证后的 grails 应用程序访问
问题描述
我们的 grails 应用程序使用 ldap 身份验证,没有任何问题,现在我需要阻止对整个应用程序的访问,如果用户没有特定的 ldap 角色。
我可以看到角色并在我的 Config.groovy 注释中使用它或保护控制器中的操作,但我需要一种方案/方式来仅显示“Denied ...”消息并注销。(禁止发布 403)。
def filters = {
loginFilter(controller:'login', action:'ajaxSuccessSproutcore') {
before = {
switch(Environment.current.name) {
case { it == 'development' || it == 'hrm'}:
if (springSecurityService.isLoggedIn() && grails.plugin.springsecurity.SpringSecurityUtils.ifAnyGranted("ROLE_ADMIN, ROLE_SEA_HRM_LOGIN")){
} else {
if (springSecurityService.isLoggedIn()) {
render ([msg:''] as JSON)
session.invalidate()
return false
}
}
break
default:
if (springSecurityService.isLoggedIn() && grails.plugin.springsecurity.SpringSecurityUtils.ifAnyGranted("ROLE_ADMIN , ROLE_USER")){
} else {
if (springSecurityService.isLoggedIn()) {
render ([msg:''] as JSON)
session.invalidate()
return false
}
}
break
}
}
after = { Map model ->
}
afterView = { Exception e ->
}
}
}
解决方案
推荐阅读
- java - java.lang.ClassNotFoundException:升级库后的 java.lang.constant.Constable
- primefaces - Primefaces时间线排序同一日期的事件
- laravel - 为什么我在 yahoo.com 帐户上收不到 laravel 发送的电子邮件?
- android - APIGEE API 的“缺少必填字段”响应
- android - 带有 DigitsKeyListener 和 inputType 的 keyListener 不能以编程方式协同工作
- python - 如何分隔逗号分隔的字符串点
- python - 查找所有超链接 ( , ) 并创建一个列表
- reactjs - 通过 NavLink 传递道具
- thingsboard - 如何在 ThingsBoard 的小部件上显示我的所有客户?
- python - Plotly Scattermapbox 文本字体系列不会改变