You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shiro.apache.org by "dstutz (via GitHub)" <gi...@apache.org> on 2024/03/23 17:39:04 UTC
[I] [Bug] Cannot login with Shiro2 hashed password from IniRealm [shiro]
dstutz opened a new issue, #1385:
URL: https://github.com/apache/shiro/issues/1385
### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/shiro/issues?q=is%3Aissue) and found no similar issues.
### Environment
JDK 21
### Shiro version
Shiro 2.0.0 jakarta
### What was the actual outcome?
I created a hashed password using the command line util as per: https://shiro.apache.org/v2/command-line-hasher.html then I set that as the password in the ini which yields something like (also setting the credentials matcher on the inirealm as mentioned in above page):
```
[users]
...
user1 = $shiro2$argon2id$v=19$t=1,m=65536,p=4$H5z81Jpr4ntZr3MVtbOUBw$fJDgZCLZjMC6A2HhnSpxULMmvVdW3su+/GCU3YbxfFQ
[main]
...
passwordMatcher = org.apache.shiro.authc.credential.PasswordMatcher
iniRealm.credentialsMatcher = $passwordMatcher
...
```
As best as I can tell, what is happening is that the commas in the new shiro2 hash format are confusing something along the way because the ini file is supposed to be (https://shiro.apache.org/configuration.html#Configuration-INIConfiguration-Sections-users)
`username = password, role1, role2, roleN...`
in fact, the example on the above page shows the new style example as:
```
user1 = $shiro2$argon2id$v=19$t=1,m=65536,p=4$H5z81Jpr4ntZr3MVtbOUBw$fJDgZCLZjMC6A2HhnSpxULMmvVdW3su+/GCU3YbxfFQ, role1, role2, ...
```
I used a debugger and confirmed that Shiro2CryptFormat.parse is only getting supplied the string `$shiro2$argon2id$v=19$t=1` which is the content of the password line before the first comma.
Below is actual error and trace starting from first shiro item:
```
WARN [org.apa.shi.aut.AbstractAuthenticator] (executor-thread-3) Authentication failed for token submission [org.apache.shiro.authc.UsernamePasswordToken - user, rememberMe=true]. Possible unexpected error? (Typical or expected login exceptions should extend from AuthenticationException).: java.lang.IllegalArgumentException: Did not found memory parameter 'm='. Got: [t=1].
at org.apache.shiro.crypto.support.hashes.argon2.Argon2Hash.lambda$parseMemory$5(Argon2Hash.java:183)
at java.base/java.util.Optional.orElseThrow(Optional.java:403)
at org.apache.shiro.crypto.support.hashes.argon2.Argon2Hash.parseMemory(Argon2Hash.java:183)
at org.apache.shiro.crypto.support.hashes.argon2.Argon2Hash.fromString(Argon2Hash.java:151)
at org.apache.shiro.crypto.support.hashes.argon2.Argon2HashProvider.fromString(Argon2HashProvider.java:58)
at org.apache.shiro.crypto.support.hashes.argon2.Argon2HashProvider.fromString(Argon2HashProvider.java:47)
at org.apache.shiro.crypto.hash.format.Shiro2CryptFormat.parse(Shiro2CryptFormat.java:134)
at org.apache.shiro.authc.credential.DefaultPasswordService.passwordsMatch(DefaultPasswordService.java:175)
at org.apache.shiro.authc.credential.PasswordMatcher.doCredentialsMatch(PasswordMatcher.java:58)
at org.apache.shiro.realm.AuthenticatingRealm.assertCredentialsMatch(AuthenticatingRealm.java:598)
at org.apache.shiro.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:579)
at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:182)
at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:275)
at org.apache.shiro.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:198)
at org.apache.shiro.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:106)
at org.apache.shiro.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:277)
at org.apache.shiro.subject.support.DelegatingSubject.login(DelegatingSubject.java:262)
```
I assume I'm missing some small piece of configuration? I'm using Shiro 2.0.0 in another application with a JDBC Realm with the new password format and everything is fine but this application is extremely simple and I only have 2 users I want to support so just wanted to use the ini file configuration.
### What was the expected outcome?
Successful login.
### How to reproduce
Attempt to login with a Shiro2 hashed password specified in shiro.ini.
### Debug logs
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For additional commands, e-mail: issues-help@shiro.apache.org
Re: [I] [Bug] Cannot login with Shiro2 hashed password from IniRealm [shiro]
Posted by "lprimak (via GitHub)" <gi...@apache.org>.
lprimak commented on issue #1385:
URL: https://github.com/apache/shiro/issues/1385#issuecomment-2016585035
Agree. Docs should he updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For additional commands, e-mail: issues-help@shiro.apache.org
Re: [I] [Bug] Cannot login with Shiro2 hashed password from IniRealm [shiro]
Posted by "lprimak (via GitHub)" <gi...@apache.org>.
lprimak closed issue #1385: [Bug] Cannot login with Shiro2 hashed password from IniRealm
URL: https://github.com/apache/shiro/issues/1385
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For additional commands, e-mail: issues-help@shiro.apache.org
Re: [I] [Bug] Cannot login with Shiro2 hashed password from IniRealm [shiro]
Posted by "lprimak (via GitHub)" <gi...@apache.org>.
lprimak commented on issue #1385:
URL: https://github.com/apache/shiro/issues/1385#issuecomment-2016571416
You can surround the full hash by double quotes to get around the comma issue.
However, having hashes in the INI file is not recommended approach, and thus is not publicized in the docs.
I am going to close this issue. Please reopen if you have any other questions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For additional commands, e-mail: issues-help@shiro.apache.org
Re: [I] [Bug] Cannot login with Shiro2 hashed password from IniRealm [shiro]
Posted by "dstutz (via GitHub)" <gi...@apache.org>.
dstutz commented on issue #1385:
URL: https://github.com/apache/shiro/issues/1385#issuecomment-2016583864
Thank you for the workaround. That did indeed work. I completely agree with the idea that using the users in the ini file is by no means a production solution but I disagree a bit with not publicizing that you should quote the strings because (as I linked in the original) it is mentioned/shown at least twice in the existing docs with the new format as an example, but it absolutely will not work as shown. So I think it makes sense to either remove the examples or update them to show the quotes because otherwise users are just getting confused. Thank you again for the solution and I appreciate your time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@shiro.apache.org
For additional commands, e-mail: issues-help@shiro.apache.org