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

  • SEARCH
  • Home
  • 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 5848515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:52:11+00:00 2026-05-22T12:52:11+00:00

In grails I can set the password field to have a minimum size constraint

  • 0

In grails I can set the password field to have a minimum size constraint of 5 (arbitrary). The problem is that I use spring security service to encode my password and the encoded/encrypted password is much longer than 5 characters almost no matter what value I put in.

Another forum response suggested doing that validation in the save method. Has anyone else tackled this problem and knows a way around it?

Spring security does not provide a decode method (probably for security purposes)… so I guess one idea would be to get a different password encoder that could decode the password for validation purposes… but my instinct says that spring security leaves this out for a good reason and maybe I should too…

static constraints = {
    username(blank: false, unique: true)
    password(minSize: 5, blank: false, unique: true,
        validator: { passwd, user ->
            return passwd != user.username
    })
    passwordRepeat(nullable: false,
    validator: { passwd2, user ->
        return passwd2 == user.password 
    })
}

So I’m using the static constraints to validate as most other variables are validated this way.

My apologies for the unreadable comment.

Thank you,
-Asaf

Edit: I think a simple fix is as mentioned above, doing the validation in the save method (before encryption), but I just feel like someone somewhere must have had to deal with this issue before. I mean there’s so many websites that require passwords and that yell at you if it’s too short, if it doesn’t contain both lowercase and uppercase letters, if it doesn’t have a symbol… How do all of them do the various validation methods they use?

  • 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-22T12:52:12+00:00Added an answer on May 22, 2026 at 12:52 pm

    you can’t decode what Spring Security encodes… That’s md5 or sha-256 !!! That’s exactly the purpose of the crypting process. Then, you can’t know what’s the password even if the databases files are stolen

    To validate passwords, you need to prompt the user for a clear one, (transmit in https, please) and then encode it with the same algorithm. Then, you have to compare it to the encoded password you stored

    Use the class DigestUtils to encode your received password with the same algorithm used the first time. This is a Spring Security Config grails.plugins.springsecurity.password.algorithm

    And yes, you have to validate before saving… For that we have added a metaclass in Bootstrap

    String.metaClass.validateAsPassword
    

    to have a unique point from which validating our passwords before saving them

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

Sidebar

Related Questions

In a Grails domain class, how do I set the constraint for a String
I'm still learning Grails and seem to have hit a stumbling block. Here are
I have not seen much support for Grails to develop facebook apps.I was just
Grails vs Rails. Which has better support? And which one is a better choice
Grails makes it very easy to configure datasources for different environments (development, test, production)
I'm using Grails 1.1 beta2. I need to import a large amount of data
I did a grails clean and afterwards when I run via grails run-app the
I'm learning Grails/GORM and as I've understood it the current best practice is not
I'm new to grails. I'd like to give it a whirl by implementing a
I'm currently working with Groovy and Grails. While Groovy is pretty straight-forward since it's

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.