Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6207759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:41:23+00:00 2026-05-24T05:41:23+00:00

I installed SpringSecurity Successfully, Upon user registration and verifying the user using Spring Security

  • 0

I installed SpringSecurity Successfully, Upon user registration and verifying the user using Spring Security UI’ RegisterController closures, I can see the user is successfully logged in using the springSecurityService.reauthenticate.

However if I logout and try logging in using the auth screen provided by the spring security I always get the http://:port/spoofsecurity/login/auth?login_error=1

I can see in the database that the user is there and unlocked, and enabled.

Appreciate any thoughts as why I get that login failure.

Thanks

My Config.groovy entry

    grails.plugins.springsecurity.userLookup.userDomainClassName = 'com.srisris.spoofsecurity.auth.SchemeUser'
grails.plugins.springsecurity.userLookup.authorityJoinClassName = 'com.srisris.spoofsecurity.auth.SchemeUserRole'
grails.plugins.springsecurity.authority.className = 'com.srisris.spoofsecurity.auth.SchemeRole'
//grails.plugins.springsecurity.password.algorithm='SHA-512'
grails.plugins.springsecurity.securityConfigType = SecurityConfigType.Annotation
//grails.plugins.springsecurity.securityConfigType = SecurityConfigType.Requestmap
//grails.plugins.springsecurity.requestMap.className = 'com.srisris.spoofsecurity.auth.Requestmap' 
//grails.plugins.springsecurity.useSwitchUserFilter = true
grails.plugins.springsecurity.securityConfigType = SecurityConfigType.Annotation

LoginController.groovy

    import grails.converters.JSON

import javax.servlet.http.HttpServletResponse

import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils

import org.springframework.security.authentication.AccountExpiredException
import org.springframework.security.authentication.CredentialsExpiredException
import org.springframework.security.authentication.DisabledException
import org.springframework.security.authentication.LockedException
import org.springframework.security.core.context.SecurityContextHolder as SCH
import org.springframework.security.web.WebAttributes
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter

class LoginController {

    /**
     * Dependency injection for the authenticationTrustResolver.
     */
    def authenticationTrustResolver

    /**
     * Dependency injection for the springSecurityService.
     */
    def springSecurityService

    /**
     * Default action; redirects to 'defaultTargetUrl' if logged in, /login/auth otherwise.
     */
    def index = {
        if (springSecurityService.isLoggedIn()) {
            redirect uri: SpringSecurityUtils.securityConfig.successHandler.defaultTargetUrl
        }
        else {
            redirect action: auth, params: params
        }
    }

    /**
     * Show the login page.
     */
    def auth = {

        def config = SpringSecurityUtils.securityConfig

        if (springSecurityService.isLoggedIn()) {
            redirect uri: config.successHandler.defaultTargetUrl
            return
        }

        String view = 'auth'
        String postUrl = "${request.contextPath}${config.apf.filterProcessesUrl}"
        render view: view, model: [postUrl: postUrl,
                                   rememberMeParameter: config.rememberMe.parameter]
    }

    /**
     * The redirect action for Ajax requests. 
     */
    def authAjax = {
        response.setHeader 'Location', SpringSecurityUtils.securityConfig.auth.ajaxLoginFormUrl
        response.sendError HttpServletResponse.SC_UNAUTHORIZED
    }

    /**
     * Show denied page.
     */
    def denied = {
        if (springSecurityService.isLoggedIn() &&
                authenticationTrustResolver.isRememberMe(SCH.context?.authentication)) {
            // have cookie but the page is guarded with IS_AUTHENTICATED_FULLY
            redirect action: full, params: params
        }
    }

    /**
     * Login page for users with a remember-me cookie but accessing a IS_AUTHENTICATED_FULLY page.
     */
    def full = {
        def config = SpringSecurityUtils.securityConfig
        render view: 'auth', params: params,
            model: [hasCookie: authenticationTrustResolver.isRememberMe(SCH.context?.authentication),
                    postUrl: "${request.contextPath}${config.apf.filterProcessesUrl}"]
    }

    /**
     * Callback after a failed login. Redirects to the auth page with a warning message.
     */
    def authfail = {

        def username = session[UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY]
        String msg = ''
        def exception = session[WebAttributes.AUTHENTICATION_EXCEPTION]
        if (exception) {
            if (exception instanceof AccountExpiredException) {
                msg = SpringSecurityUtils.securityConfig.errors.login.expired
            }
            else if (exception instanceof CredentialsExpiredException) {
                msg = SpringSecurityUtils.securityConfig.errors.login.passwordExpired
            }
            else if (exception instanceof DisabledException) {
                msg = SpringSecurityUtils.securityConfig.errors.login.disabled
            }
            else if (exception instanceof LockedException) {
                msg = SpringSecurityUtils.securityConfig.errors.login.locked
            }
            else {
                msg = SpringSecurityUtils.securityConfig.errors.login.fail
            }
        }

        if (springSecurityService.isAjax(request)) {
            render([error: msg] as JSON)
        }
        else {
            flash.message = msg
            redirect action: auth, params: params
        }
    }

    /**
     * The Ajax success redirect url.
     */
    def ajaxSuccess = {
        render([success: true, username: springSecurityService.authentication.name] as JSON)
    }

    /**
     * The Ajax denied redirect url.
     */
    def ajaxDenied = {
        render([error: 'access denied'] as JSON)
    }
}

auth.jsp

 <head>
    <meta name='layout' content='main'/>
    <title>Login</title>
    <style type='text/css' media='screen'>

    #auth .flashMessage {
        text-align: center;
        margin: 5px 0 0 0;
    }

    #auth {
        padding: 5px 10px;
        text-align: left;
        width: 300px;
        border-width: 1px;
        border-style: dashed none;
        border-color: #49d;
    }

    #auth table {
        width: 100%;
    }

    #auth table tr:first-child td {
        border: 0;
    }

    #auth h1 {
        font-size: 1.4em;
        margin-bottom: 0;
        text-align: center;
    }

    #auth td {
        border-top: 1px dashed gray;
        vertical-align: middle;
        padding: 5px 0;
    }

    #auth label {
        font-weight: bold;
    }

    #auth input[type="submit"] {
        font-size: 1em;
        width: 100px;
        height: 2em;
    }

    #auth .submit {
        text-align: center;
    }

    .forgot{
        margin: 0;
        text-align: center;
    }
    </style>
</head>

<body>
    <div id='auth'>
        <cap:flashMessage/>
        <form action='${postUrl}' method='POST' id='loginForm' autocomplete='off' onsubmit="return formSubmit();">
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td colspan="2"><h1>Please Login</h1></td>
                </tr>
                <tr>
                    <td><label for='username'>Email</label></td>
                    <td><input type='text' name='j_username' id='username'/></td>
                </tr>
                <tr>
                    <td><label for='password'>Password</label></td>
                    <td><input type='password' name='j_password' id='password'/></td>
                </tr>
                <tr>
                    <td><label for='remember_me'>Remember Me</label></td>
                    <td><input type='checkbox' name='${rememberMeParameter}'
                            id='remember_me' ${hasCookie ? "checked='checked'" : ''}/></td>
                </tr>
                <tr>
                    <td colspan="2" class="submit"><input type='submit' value='Login'/></td>
                </tr>
            </table>
        </form>
        <p class="forgot"><g:link action="forgotPassword">Forgot your password?</g:link></p>
    </div>
    <script type='text/javascript'>

        (function() {
            document.forms['loginForm'].elements['j_username'].focus();
        })();
        function formSubmit() {
            var e = document.getElementById("username");
            e.value = e.value.toLowerCase();
            return true;
        }
    </script>
</body>

UPDATE 1:

Alright when I debugged this is what I see in my stacktrace. Fail to understand I am using the same password that I stored while registering the user.

2011-07-31 10:09:55,463 [http-8090-1] DEBUG dao.DaoAuthenticationProvider  - Authentication failed: password does not match stored value 
2011-07-31 10:09:55,463 [http-8090-1] DEBUG rememberme.TokenBasedRememberMeServices  - Interactive login attempt was unsuccessful. 
2011-07-31 10:09:55,463 [http-8090-1] DEBUG rememberme.TokenBasedRememberMeServices  - Cancelling cookie 
2011-07-31 10:09:55,504 [http-8090-1] DEBUG web.DefaultRedirectStrategy  - Redirecting to '/wr/login/authfail?login_error=1' 
2011-07-31 10:09:55,504 [http-8090-1] DEBUG context.SecurityContextPersistenceFilter  - SecurityContextHolder now cleared, as request processing completed 
2011-07-31 10:09:55,537 [http-8090-1] DEBUG web.FilterChainProxy  - Converted URL to lowercase, from: '/login/authfail'; to: '/login/authfail' 
2011-07-31 10:09:55,537 [http-8090-1] DEBUG web.FilterChainProxy  - Candidate is: '/login/authfail'; pattern is /**; matched=true 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:41:24+00:00Added an answer on May 24, 2026 at 5:41 am

    I found my mistake, I wish I knew how to use those debug in log4j. It was such a trivial but costed me lot of time and effort.

    The issue was I encrypted the password using springSecurityService.encrypt(password), but didnt set that in the User object that I created and hence there was a mismatch in password comparisions and fails.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just installed springsecurity core and spring security openId plugins. I am able to
I have just started using grails and installed the spring-security and spring-security-ui plugins. I
I have installed spring-security-core in a grails project, but for some reason, IDEA didn't
I am trying to get a Java app using spring-security to talk to a
I have installed spring security plug in to grails project.i have made my default
Grails 1.3.5 and have selenium-rc, easyb, and spring-security-core plugins installed. Everything seems to work
I'm using Grails Spring Security Core plugin and I need to perform a few
I installed the opencv-android plugin successfully and I can build and run the cvcamera
I installed VS10 side-by-side with VS9 and created a very simple application using it:
I installed the wrong version of pysvn in my system using the .dmg. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.