You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shiro.apache.org by "SIMJIYEON93 (via GitHub)" <gi...@apache.org> on 2025/04/05 01:49:34 UTC
[I] [Bug] Fix potential NPE when principal is null in DefaultLdapRealm#getLdapPrincipal [shiro]
SIMJIYEON93 opened a new issue, #2069:
URL: https://github.com/apache/shiro/issues/2069
### 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
Java 17
Apache Tomcat 9
Apache Shiro (latest master branch)
OS: Windows 11
Build tool: Maven
Tested against: master branch (after 1.13.0 release)
### Shiro version
Apache Shiro (latest master branch, after 1.13.0 release)
### What was the actual outcome?
If the principal in the AuthenticationToken is null, a NullPointerException could occur when calling `DefaultLdapRealm#getLdapPrincipal`.
### What was the expected outcome?
An `AuthenticationException` should be thrown when the principal is null to prevent unexpected NPE.
### How to reproduce
```java
@Test
void testGetLdapPrincipalNullPrincipal() {
AuthenticationToken token = new AuthenticationToken() {
@Override
public Object getPrincipal() {
return null;
}
@Override
public Object getCredentials() {
return "secret";
}
};
assertThrows(AuthenticationException.class, () -> {
realm.getLdapPrincipal(token);
});
}
### Debug logs
No response
### Additional Information
All changes were tested locally with `mvn verify` to ensure no regressions.
--
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] Fix potential NPE when principal is null in DefaultLdapRealm#getLdapPrincipal [shiro]
Posted by "SIMJIYEON93 (via GitHub)" <gi...@apache.org>.
SIMJIYEON93 commented on issue #2069:
URL: https://github.com/apache/shiro/issues/2069#issuecomment-2781293748
Thank you very much for the detailed review and thoughtful discussion!
After carefully considering your feedback and reviewing the LDAP Realm codebase, I fully agree that allowing a `null` principal is consistent with the existing design and expected behavior.
Since there was no actual failing use case, and maintaining API consistency is important, I agree that this change is unnecessary.
I will close this PR accordingly.
Thank you again for your time and guidance throughout the review process — it helped me better understand the importance of respecting existing project design and preserving API contracts.
I truly appreciate the opportunity to learn from this experience and look forward to contributing again in the future!
--
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] Fix potential NPE when principal is null in DefaultLdapRealm#getLdapPrincipal [shiro]
Posted by "lprimak (via GitHub)" <gi...@apache.org>.
lprimak commented on issue #2069:
URL: https://github.com/apache/shiro/issues/2069#issuecomment-2781041110
It sounds like you have some code that failed in connection to this.
Can you share your failing use case?
In general, when there is no one authenticated, there should not be any attempt to call other methods with unauthenticated user.
This is why I doubt that this issue is solved in the way the PR attempts to solve it.
--
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] Fix potential NPE when principal is null in DefaultLdapRealm#getLdapPrincipal [shiro]
Posted by "lprimak (via GitHub)" <gi...@apache.org>.
lprimak commented on issue #2069:
URL: https://github.com/apache/shiro/issues/2069#issuecomment-2781042325
@bdemers What do you think? Does this fix make the API inconsistent with the rest of the API? Or is this an actual improvement?
--
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] Fix potential NPE when principal is null in DefaultLdapRealm#getLdapPrincipal [shiro]
Posted by "lprimak (via GitHub)" <gi...@apache.org>.
lprimak commented on issue #2069:
URL: https://github.com/apache/shiro/issues/2069#issuecomment-2781533470
Thanks for your feedback as well.
Since there is no failing use case, I will proceed to close the issue.
--
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] Fix potential NPE when principal is null in DefaultLdapRealm#getLdapPrincipal [shiro]
Posted by "lprimak (via GitHub)" <gi...@apache.org>.
lprimak commented on issue #2069:
URL: https://github.com/apache/shiro/issues/2069#issuecomment-2781043000
Cursory inspection of the rest of the LDAP Realm code yields that it fully expects that Principal may be null, so my initial guess is that null principal is ok and the code should stay and there is...
Let me know what you think
--
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] Fix potential NPE when principal is null in DefaultLdapRealm#getLdapPrincipal [shiro]
Posted by "lprimak (via GitHub)" <gi...@apache.org>.
lprimak closed issue #2069: [Bug] Fix potential NPE when principal is null in DefaultLdapRealm#getLdapPrincipal
URL: https://github.com/apache/shiro/issues/2069
--
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