-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java21+Spring6 upgrade, Keycloak removal #503
Java21+Spring6 upgrade, Keycloak removal #503
Conversation
- Upgrade API key and EGI auth to Spring Security 6.3. - Add -parameters compilation flag - Add @configuration annotation to @EnableWebSecurity classes - Move @order annotations to SecurityFilterChain methods - Port API key and EGI authentications to use the new Spring6 API, removing use of deprecated stuff. - Fully remove org.keycloak connector: this temporarily drops support for Keycloak authentication in VIP API, as this connector is deprecated and doesn't supprot Java21/Spring6. It will be replaced with a new Spring-based OIDC connector in an upcoming patch. - Also remove unused keycloak refreshtoken stuff, and the three related keycloak parameters in vip-api.conf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work.
Seems good globally.
We need to review the way GWT is imported.
Also, the tests are failing on github because it is still configured with java11, we need to update the workflow definition with the new one @ethaaalpha did. Do they run locally ?
vip-api/src/main/java/fr/insalyon/creatis/vip/api/security/ApiSecurityConfig.java
Outdated
Show resolved
Hide resolved
vip-api/src/main/java/fr/insalyon/creatis/vip/api/security/ApiSecurityConfig.java
Show resolved
Hide resolved
vip-api/src/main/java/fr/insalyon/creatis/vip/api/security/ApiSecurityConfig.java
Outdated
Show resolved
Hide resolved
- Add explicit comment on requestmatchers - Remove useless authmanager bean
- upgrade hibernate validator from 6.1.5.Final to 8.0.1.Final - remove direct import of jakarta.validation With this change, rest API objects validation now correctly happens at runtime, but still not in unit tests.
Summary of today's changes :
Known limitations listed in the first comment all remain, and ongoing conversations have to be sorted out with @axlbonnet. |
Was broken since the smartgwt and fileupload upgrades: - Backend fix: upgrade commons-io to 2.17.0 and pin version in top-level pom (needed for commons-fileupload2-jakarta-servlet6) - Front-end fix: Make gwt form submission synchronous with setCheckFileAccessOnSubmit(false), to workaround immediate destruction after submit (see smartgwt DynamicForm javadoc)
This was apparently needed along with the spring+hibernate upgrade, to have proper validator injection in integration tests.
Last two updates :
Remaining issues :
|
Excellent. |
- This provides support for OIDC Bearer token authentication with a Keycloak server, in a backwards-compatible way, but using Spring Security 6: - Support the same keycloak.json file as previously - Same network requests to Keycloak server - Same decoding of JWT claims for endpoints with role check - In addition to the backwards-compatible stuff: - Fix missing verification of locked account - Inner structures are ready to support multiple servers
ngeorges-cnrs@7970495 : restore Keycloak support, ready for review and candidate to merge. Notes for the review :
|
During some extra testing today, I found an issue with Keycloak support in the present PR, which has to do with how JWT claims get mapped to authorities ("roles") : the current PR assumed that roles were extracted from the This means that the resource name in keycloak.json is probably useless : I'll do some review of the existing Keycloak connector code to confirm that, if I can find it. And we can then decide whether to drop that configuration field. Edit: Keycloak adapter behaviour is confirmed (we were using 15.0.1) :
So depending on current and planned prod usage, we can either remove support for resource roles entirely, or keep a similar configuration possibility with a boolean flag + resource name. |
- Change default authorities parsing to realm_access, as in previous implementation - Add support for use-resource-role-mapping parameter in keycloak.json, to allow resource_access authorities to be configured
ngeorges-cnrs@79e825c : adjusted how roles are parsed from JWT to exactly match previous implementation (cf previous comment). As seen with Axel, All tests done on my side, so this PR is finally ready for review and merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent and elegant work.
I just have short remarks mainly about exception handling.
vip-api/src/main/java/fr/insalyon/creatis/vip/api/security/oidc/OidcConfig.java
Outdated
Show resolved
Hide resolved
vip-api/src/main/java/fr/insalyon/creatis/vip/api/security/oidc/OidcConfig.java
Outdated
Show resolved
Hide resolved
vip-api/src/main/java/fr/insalyon/creatis/vip/api/security/oidc/OidcConfig.java
Outdated
Show resolved
Hide resolved
vip-api/src/main/java/fr/insalyon/creatis/vip/api/security/oidc/OidcConfig.java
Outdated
Show resolved
Hide resolved
vip-api/src/main/java/fr/insalyon/creatis/vip/api/security/oidc/OidcResolver.java
Outdated
Show resolved
Hide resolved
vip-api/src/main/java/fr/insalyon/creatis/vip/api/security/ApiSecurityConfig.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work @ngeorges-cnrs!
I'm OK with merging the PR after taking into account Axel's suggestions.
- Improve keycloak.json file reading - Change OidcConfig from @configuration to @service - Shorten AntPathRequestMatcher.antMatcher with a static import
- In OidcConfig: let exceptions bubble up and rely on default logging, throw explicit BusinessException instead of implicit NullPointerException on missing mandatory fields in keycloak.json. - In OidcResolver.parseAuthorities: handle unknown resource name gracefully with logging, let other errors bubble up as they normally shouldn't happen with a Keycloak-generated JWT. - Also adjust some logs of abnormal cases to warning-level.
All comments above were addressed in today's commits :
Hopefully everything is now ready for merging. |
Great work, thanks @ngeorges-cnrs |
This pull request updates and replaces #496, which basically had VIP-portal building with Java21, but not running in a usable way.
In the present PR :
Known limitations :
These limitations along with the Keycloak connector removal make the patch usable for development/testing, but obviously not for production yet. Also do note that Tomcat must be upgraded to v10 or v11 in order to support jakarta.