【问题标题】:Where did 'Sorry, you're not authorized to view this page' come from?“对不起,您无权查看此页面”来自哪里?
【发布时间】:2015-02-21 23:12:23
【问题描述】:

我正在为 Grails 使用 spring 安全插件。我可以通过 LDAP 身份验证并查看授权是否正常工作。授权失败时,我会看到“抱歉,您无权查看此页面”。这个错误是从哪里来的?

我的 SecureController 代码如下。

package com.testapp

import grails.plugin.springsecurity.annotation.Secured
import org.springframework.web.context.request.RequestContextHolder

class SecureController {


   @Secured(['ROLE_USER'])
   def showUser()  {
        def msg = ' ROLE_USER users see this'

        render view: 'enter', model: [msg: msg]
   }

   @Secured(['ROLE_ADMIN'])
   def showAdmin() {
      def msg = ' ROLE_ADMIN users see this'
      render view: 'enter', model: [msg: msg]
   }
}

【问题讨论】:

    标签: grails spring-security authorization grails-plugin


    【解决方案1】:

    该页面是 Spring 安全核心插件中的 denied.gsp 视图/页面。当访问请求的资源被拒绝(例如,@Secured 检查失败)时,会显示此视图。

    如果您想用自己的视图替换它,请创建一个新视图/页面grails-app/views/login/denied.gsp

    【讨论】:

    • 谢谢 是的。我很可能会有一个自定义的 denied.gsp。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-02
    • 2014-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多