Repository navigation
[GEODE-10699] Upgrade Shiro to 3.0.2 from 3.0.0 - #8153
hesitationkills wants to merge 2 commits into
Conversation
JinwooHwang
left a comment
There was a problem hiding this comment.
Welcome to Apache Geode, @hesitationkills, and congratulations on your first contribution! Thank you for picking this up.
Keeping Shiro current matters a lot for a security-sensitive dependency, and this is a clean, well-scoped upgrade: the version constraint in DependencyConstraints.groovy and the expected classpath listings all move together in a single commit, with the JIRA ticket referenced in the title. That is exactly how we like to see dependency upgrades done.
I especially appreciate that you caught the stale shiro-core entry in boms/geode-all-bom/src/test/resources/expected-pom.xml. It was still at 1.13.0, left behind by an earlier upgrade, and it’s the kind of detail that is easy to overlook even for people who have been in this codebase for years. Fixing it here leaves the project in better shape than you found it.
One small thing before merge: geode-assembly/src/integrationTest/resources/assembly_content.txt still lists lib/shiro-lang-3.0.0.jar (line 1051). The gfsh and server-all classpath files already have shiro-lang-3.0.2.jar, so this one just slipped through, which is easy to do in files this long. Could you update it to 3.0.2 so the assembly content check stays consistent?
Approving with that one-line fix. Thank you again for the care you put into this. We’d love to see more from you, and if you have questions about the codebase or are looking for a next ticket, please reach out on dev@geode.apache.org. Welcome aboard!
3150699 to
3d6c417
Compare
@JinwooHwang Thanks for pointing that out. I've updated the commit to upgrade to shiro-lang-3.0.2.jar in assembly_content.txt as well. |
|
You are very welcome @hesitationkills. We appreciate your prompt fix! |
|
Hi @hesitationkills. The CI failures come from two side effects of Shiro 3.0.2, and both are small to address in this PR:
Shiro 3.0.2 no longer matches empty credentials in its default matcher. In Geode the SecurityManager has already validated the login at that point, so CustomAuthRealm should set its matcher explicitly. In geode-core/src/main/java/org/apache/geode/internal/security/shiro/CustomAuthRealm.java: import org.apache.shiro.authc.credential.AllowAllCredentialsMatcher;
...
public CustomAuthRealm(SecurityManager securityManager) {
this.securityManager = securityManager;
setAuthenticationTokenClass(GeodeAuthenticationToken.class);
setCredentialsMatcher(new AllowAllCredentialsMatcher());
}
Shiro 3.0.2 brings in slf4j-api 2.0.20, so the distribution ends up with two copies. Please bump it from 2.0.18 to 2.0.20 in:
Happy to help if anything is unclear. Thanks again for the contribution! |
gouthamaenugu
left a comment
There was a problem hiding this comment.
I checked out commit 3d6c417418 locally under Temurin JDK 17 and reproduced the CI failures across :geode-web-management:integrationTest and :geode-assembly:integrationTest. There are two distinct root causes behind the failing jobs:
1. Shiro 3.0.2 rejects empty credentials in SimpleCredentialsMatcher (RequestWithAuthTokenTest.pingWithValidToken fails with 401)
- Reproduced failure:
:geode-web-management:integrationTest(67 tests, 1 failed) fails atRequestWithAuthTokenTest.java:58(Status expected:<200> but was:<401>).SimpleSecurityManager.authenticate()logsToken authentication SUCCESS - returning principal: Bearer FOO_BAR, immediately followed byIntegratedSecurityService.java:179loggingerror logging in:. - Root cause: Comparing
org.apache.shiro.authc.credential.SimpleCredentialsMatcher.equals(Object, Object)bytecode (javap -c) betweenshiro-core-3.0.0.jarandshiro-core-3.0.2.jar, Shiro3.0.2added a guard at offsets0..22returningfalsewheneveraccountCredentials == nullorisByteSource(accountCredentials) && toBytes(accountCredentials).length == 0. - Because
GeodeAuthenticationToken(geode-core/src/main/java/org/apache/geode/internal/security/shiro/GeodeAuthenticationToken.java:30-35) defaults a missingsecurity-password(e.g., Bearer token or passwordless customSecurityManagerauth) to""(char[0]), andCustomAuthRealm(geode-core/src/main/java/org/apache/geode/internal/security/shiro/CustomAuthRealm.java:44-55) inheritsAuthorizingRealm's defaultSimpleCredentialsMatcherdespite already authenticating viasecurityManager.authenticate(authToken.getProperties())at line 53, every token/passwordless login now fails credential matching. - Verified 1-line fix: Set
AllowAllCredentialsMatcherinCustomAuthRealm's constructor (CustomAuthRealm.java:46-47):Verified locally onimport org.apache.shiro.authc.credential.AllowAllCredentialsMatcher; ... setAuthenticationTokenClass(GeodeAuthenticationToken.class); setCredentialsMatcher(new AllowAllCredentialsMatcher());
3d6c417418:RequestWithAuthTokenTestflips from401failure to2/2passing (BUILD SUCCESSFUL).
2. Transitive slf4j-api version bump (2.0.18 -> 2.0.20) breaks assembly & gfsh classpath checks
- Reproduced failures:
AssemblyContentsIntegrationTest.verifyAssemblyContents(AssemblyContentsIntegrationTest.java:67): unexpected["lib/slf4j-api-2.0.20.jar"]vsgeode-assembly/src/integrationTest/resources/assembly_content.txt:1052(lib/slf4j-api-2.0.18.jar).GfshDependencyJarIntegrationTest.verifyManifestClassPath(GfshDependencyJarIntegrationTest.java:67): missing["slf4j-api-2.0.18.jar"], unexpected["slf4j-api-2.0.20.jar"]vsgeode-assembly/src/integrationTest/resources/gfsh_dependency_classpath.txt:118.
- Root cause: Shiro
3.0.2pulls inorg.slf4j:slf4j-api:2.0.20, overriding the soft BOM constraintdeps.put("slf4j-api.version", "2.0.18")(DependencyConstraints.groovy:60,:234) ingeode-assembly. Meanwhile:geode-server-allusesenforcedPlatform(geode-server-all/build.gradle:33), leavinggeode-assembly(2.0.20) andgeode-server-all(2.0.18) out of sync. - Fix: Either bump
slf4j-api.versionto2.0.20inDependencyConstraints.groovy:60and updateboms/geode-all-bom/src/test/resources/expected-pom.xml:423,assembly_content.txt:1052,gfsh_dependency_classpath.txt:118, andgeode-server-all/src/integrationTest/resources/dependency_classpath.txt:119, or strictly pinslf4j-apito2.0.18.
(:boms:geode-all-bom:check and :geode-core:integrationTest --tests "*Shiro*" already pass locally.)
|
Thanks @gouthamaenugu, I really appreciate you taking the time to reproduce this locally on JDK 17. Independent confirmation of both root causes, and that On slf4j-api, I'd prefer bumping to 2.0.20 across the affected files rather than pinning to 2.0.18, so we stay aligned with what Shiro 3.0.2 brings in. @hesitationkills, once those two changes are pushed, I'll be happy to re-review. Thanks again to you both! |
… align with Shiro's dependency version, and setting AllowAllCredentialsMatcher for CustomAuthRealm
Upgraded Shiro from 3.0.0 to 3.0.2, bumped slf4j-api to 2.0.20 as required by Shiro, and fixed a previous missing upgrade of shiro-core in boms/geode-all-bom/src/test/resources/expected-pom.xml
For all changes, please confirm:
develop)?gradlew buildrun cleanly?