简体   繁体   English

Grails 3 Spring安全性插件

[英]Grails 3 Spring Security Plugin

I am using Grails 3 and the Spring Security Plugin for authentication. 我正在使用Grails 3和Spring Security插件进行身份验证。

When I hit the following url manually, in my browser: 当我在浏览器中手动点击以下网址时:

http://localhost:8080/cool-0.1/ http:// localhost:8080 / cool-0.1 /

I get the login page, and I can authenticate successfully, inferring that I type my username / password combo correctly. 我得到了登录页面,我可以成功进行身份验证,这表明我正确输入了用户名/密码组合。

Problem: 问题:

If I navigate to my page by using the original link, without the forward slash (IE: http://localhost:8080/cool-0.1 and not http://localhost:8080/cool-0.1/ ) I completely bypass the security, and am able to see the home page without authenticating. 如果我使用原始链接导航到我的页面,而没有正斜杠(即: http:// localhost:8080 / cool-0.1而不是http:// localhost:8080 / cool-0.1 / ),我将完全绕过安全性,并且无需身份验证即可查看主页。 (Yes, I clear my cache, close all windows, etc) (是的,我清除了缓存,关闭了所有窗口,等等)

My url mappings contain the following code: 我的网址映射包含以下代码:

"/"(controller: "home", action: "index")

My spring security groovy file contains the following code: 我的spring security groovy文件包含以下代码:

grails.plugin.springsecurity.controllerAnnotations.staticRules = [
    [pattern: '/login/**', access: ['permitAll']],
    [pattern: '/error', access: ['permitAll']],
    [pattern: '/**', access: 'isAuthenticated()']
]
grails.plugin.springsecurity.filterChain.chainMap = [
    [pattern: '/assets/**', filters: 'none'],
    [pattern: '/**/js/**', filters: 'none'],
    [pattern: '/**/css/**', filters: 'none'],
    [pattern: '/**/images/**', filters: 'none'],
    [pattern: '/**/favicon.ico', filters: 'none'],
    [pattern: '/**', filters: 'JOINED_FILTERS']
]

I do not see what I am missing here. 我看不到我在这里想念的东西。 Why do the two scenarios cause issues? 为什么这两种情况都会引起问题? The documentation for Spring Security Grails 3 mentions nothing useful to solve this. Spring Security Grails 3的文档中没有提到解决此问题的有用信息。

The solution was to use the ** pattern: 解决方案是使用**模式:

[pattern: '**', access: 'isAuthenticated()'],

The documentation provided said that the use of /** and ** is identical, however, by doing the experiment using both, it clearly is not. 提供的文档说/ **和**的用法是相同的,但是,通过同时使用两者进行实验,显然不是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM