我正在查看grails spring安全核心v3的文档。 Grails Spring Security Plugin v3我的目标是在yml文件中配置url映射,而不是分散在整个代码中。他们的文档说,要做到这一点,我们必须做两件事。首先,设置
securityConfigType: 'InterceptUrlMap'
然后按以下格式概述我们的模式:
grails.plugin.springsecurity.interceptUrlMap = [
[pattern: '/', access: ['permitAll']]
]
所以我在下面的代码中做到了这一点:(注意,这是来自他们的文档,复制和粘贴)
grails:
plugin:
springsecurity:
securityConfigType: 'InterceptUrlMap'
interceptUrlMap: [
[pattern: '/', access: ['permitAll']],
[pattern: '/error', access: ['permitAll']],
[pattern: '/index', access: ['permitAll']],
[pattern: '/index.gsp', access: ['permitAll']],
[pattern: '/shutdown', access: ['permitAll']],
[pattern: '/assets/**', access: ['permitAll']],
[pattern: '/**/js/**', access: ['permitAll']],
[pattern: '/**/css/**', access: ['permitAll']],
[pattern: '/**/images/**', access: ['permitAll']],
[pattern: '/**/favicon.ico', access: ['permitAll']],
[pattern: '/login/**', access: ['permitAll']],
[pattern: '/logout/**', access: ['permitAll']]
]
但是,在尝试使用新构建的war文件访问我的网页时,我收到一条错误消息:
groovy.lang.MissingMethodException: No signature of method: grails.plugin.springsecurity.ReflectionUtils$_splitMap_closure5.doCall() is applicable for argument types: (java.util.ArrayList) values: [[[pattern:/], [access:[permitAll]]]]
Possible solutions: doCall(java.util.Map), findAll(), findAll(), isCase(java.lang.Object), isCase(java.lang.Object)
我不确定这里的问题是什么。如果我使用grails 3.0使用s2-quickstart生成的groovy脚本,一切都按预期工作。但是,考虑到我的其他配置的100%都在YML文件中,我当然不想走那条路。
我在这里错过了一些明显的属性,需要设置吗?
答案 0 :(得分:3)
在查看该错误后,我所做的是尝试使用地图列表创建映射。 所以你的代码会变成这样的东西:
interceptUrlMap: [
{pattern: '/', access: ['permitAll']},
{pattern: '/error', access: ['permitAll']},
{pattern: '/index', access: ['permitAll']},
{pattern: '/index.gsp', access: ['permitAll']},
{pattern: '/shutdown', access: ['permitAll']},
{pattern: '/assets/**', access: ['permitAll']},
{pattern: '/**/js/**', access: ['permitAll']},
{pattern: '/**/css/**', access: ['permitAll']},
{pattern: '/**/images/**', access: ['permitAll']},
{pattern: '/**/favicon.ico', access: ['permitAll']},
{pattern: '/login/**', access: ['permitAll']},
{pattern: '/logout/**', access: ['permitAll']}
]
我在我当地的Grails 3.0应用程序中使用了它,它似乎工作正常。
答案 1 :(得分:0)
在3.2.4中,由于某些原因,这对我不起作用。这是做了什么:
interceptUrlMap:
- {pattern: '/password/change**', access: ['IS_AUTHENTICATED_REMEMBERED']}
- {pattern: '/user/create', access: ['IS_AUTHENTICATED_ANONYMOUSLY']}
- {pattern: '/user/save', access: ['IS_AUTHENTICATED_ANONYMOUSLY']}
- {pattern: '/user/**', access: ['IS_AUTHENTICATED_REMEMBERED']}
- {pattern: '/my/**', access: ['IS_AUTHENTICATED_REMEMBERED']}
- {pattern: '/j_spring_security_exit_user', access: ['IS_AUTHENTICATED_REMEMBERED']}
- {pattern: '/j_spring_security_switch_user', access: ['ROLE_ADMIN', 'ROLE_SWITCH_USER']}
- {pattern: '/admin/**', access: ['ROLE_ADMIN']}
答案 2 :(得分:0)
改变这个:
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#Startseite {
position:relative;
}
#Startseite .its-background {
width:100% !important;
height:auto !important;
max-width:100% !important;
}
.CentermiddleStart {
position:absolute;
top:50%;
left:50%;
-webkit-transform:translate(-50%,-50%);
-ms-transform:translate(-50%,-50%);
transform:translate(-50%,-50%);
z-index:1;
text-align:center;
}
到此:
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div id="Startseite">
<img src="http://qnimate.com/wp-content/uploads/2014/03/images2.jpg" alt="" class="its-background"/ >
<div class="container CentermiddleStart">
<div class="row">
<div class="col-12">
<h1>Header</h1>
<h3>Subheader</h3>
</div>
</div>
<div class="row">
<div class="col-xs-6" id="button-right">
<a href="#" class="btn btn-default btn-lg">Get started</a>
</div>
<div class="col-xs-6" id="button-left">
<a href="#" class="btn btn-default btn-lg">Get started</a>
</div>
</div>
</div>
</div>
</body>