Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何定制Spring Security Shiro Grails插件登录注销功能?_Grails_Spring Security - Fatal编程技术网

如何定制Spring Security Shiro Grails插件登录注销功能?

如何定制Spring Security Shiro Grails插件登录注销功能?,grails,spring-security,Grails,Spring Security,这看起来应该很简单,但我无法定制预先构建的SpringSecurityShrio的登录(登录/验证)和注销功能 我想做一些事情,比如添加一个登录计数器,或者登录日志,这样当用户登录时,我就可以记录他们是谁以及其他信息,比如ip地址 另外,我找到了源代码,找到了LoginController,复制了它,但注意到该控制器中没有身份验证方法 我正在将一个应用程序从GrailsVersion2.4.4升级到Grails3+。生成的代码在哪里?任何指导都将不胜感激。不是特定于Shiro,但您可以在视图中添

这看起来应该很简单,但我无法定制预先构建的SpringSecurityShrio的登录(登录/验证)和注销功能

我想做一些事情,比如添加一个登录计数器,或者登录日志,这样当用户登录时,我就可以记录他们是谁以及其他信息,比如ip地址

另外,我找到了源代码,找到了LoginController,复制了它,但注意到该控制器中没有身份验证方法


我正在将一个应用程序从GrailsVersion2.4.4升级到Grails3+。生成的代码在哪里?任何指导都将不胜感激。

不是特定于Shiro,但您可以在视图中添加登录目录,然后添加您自己的auth.gsp以处理登录

请注意,许多参数名称从Grails2更改为3,例如从j_username更改为username see

这是我最近从Grails 2到3应用程序转换而来的一个引导样式:

<html>
<head>
   <meta name='layout' content='main'/>
   <title><g:message code="springSecurity.login.title"/></title>
</head>

<body>
<div id='login' class="maincontentdiv">

      <g:render template="/templates/alerts"/>

      <form action='${postUrl}' method='POST' id='loginForm' class='form-horizontal' autocomplete='off'>

         <fieldset>
            <legend><g:message code="springSecurity.login.header"/></legend>

            <div class="form-group">
               <label class="col-md-4 control-label" for="username">
                  <g:message code="springSecurity.login.username.label" default="Username" />
                  <span class="required-indicator">*</span>
               </label>
               <div class="col-md-4"> 
                  <input type='text' class='form-control' name='username' id='username'/>
               </div>
            </div>

            <div class="form-group">
               <label class="col-md-4 control-label" for="password">
                  <g:message code="springSecurity.login.password.label" default="Password" />
                  <span class="required-indicator">*</span>
               </label>
               <div class="col-md-4"> 
                  <input type='password' class='form-control' name='password' id='password'/>
               </div>
            </div>

            <div class="form-group">
               <label class="col-md-4 control-label" for="submit"></label>
               <div class="col-md-4">
                  <input type='submit' id="submit" class='btn btn-primary' value='${message(code: "springSecurity.login.button")}'/>
               </div>
            </div>
         </fieldset>
      </form>
</div>
<script type='text/javascript'>
   <!--
   (function() {
      document.forms['loginForm'].elements['username'].focus();
   })();
   // -->
</script>
</body>
</html>

*
*

在grails2下工作的shiro给人留下了深刻印象,但在3年内一直处于破产状态。是的,目前在3年内不受支持。不过,我正在使用的Grails3中有一个连接shiro和spring安全性的插件。