General: Add SAML2 redirect URI support for external client authentication#12534
Draft
General: Add SAML2 redirect URI support for external client authentication#12534
General: Add SAML2 redirect URI support for external client authentication#12534Conversation
Add design specification for external client SSO support via redirect_uri parameter in the SAML2 authentication flow.
- Deduplicate URI.create() call in success handler - Add integration test for UserNotActivatedException → 403 - Update spec: feature-disabled + redirect_uri silently ignored (RelayState resolver cannot send HTTP error responses)
|
@Predixx Test coverage has been automatically updated in the PR description. |
|
@Predixx Test coverage has been automatically updated in the PR description. |
General: Add SAML2 redirect URI support for external client authentication
End-to-End Test Results
Test Strategy: Running all tests (configuration or infrastructure changes detected) Overall: ❌ E2E tests failed 🔗 Workflow Run · 📊 Test Report |
|
@Predixx Test coverage has been automatically updated in the PR description. |
|
@Predixx Test coverage has been automatically updated in the PR description. |
…uration Spring Boot 4 moved Saml2RelyingPartyAutoConfiguration to a separate module (spring-boot-security-saml2). Add the starter dependency so the RelyingPartyRegistrationRepository bean is auto-configured from spring.security.saml2.relyingparty.registration properties.
4e9fc46 to
0db273b
Compare
|
@Predixx Test coverage has been automatically updated in the PR description. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for external clients (VS Code extension, iOS/Android apps) to receive a JWT after SAML2 SSO login via an optional
redirect_uriparameter. After successful SAML2 authentication, Artemis redirects to the external client's custom URI scheme (e.g.,vscode://) with the JWT as a query parameter. Without the parameter, the existing web SAML2 flow is completely preserved.Also adds
spring-boot-starter-security-saml2dependency, which is required since Spring Boot 4 moved the SAML2 auto-configuration (Saml2RelyingPartyAutoConfiguration) to a separate module. Without this starter, theRelyingPartyRegistrationRepositorybean is not created and the SAML2 profile fails to start.Checklist
General
Server
Motivation and Context
Institutions using SAML2 SSO (e.g., Shibboleth, Keycloak) currently have no way for external clients to authenticate. Users on SAML2-only instances must use the "forgot password" workaround to set a password for API access. This change enables a standard OAuth2-like redirect flow for native clients using custom URI schemes.
Related issues: #10967, #10968
Description
Flow:
{artemisUrl}/saml2/authenticate/{registrationId}?redirect_uri=vscode://artemis/callbackAuthenticationSuccessHandlerlooks up the redirect_uri from Hazelcast, mints a JWT, redirects tovscode://artemis/callback?jwt=<token>redirect_uri, the existing web flow is completely unchangedSecurity:
saml2.allowed-redirect-schemes)http/httpsschemes are always blocked (prevents open redirects)New components:
SAML2ExternalClientAuthenticationSuccessHandler-- extendsSimpleUrlAuthenticationSuccessHandlerHazelcastSaml2RedirectUriRepository-- distributed nonce storeSAML2RedirectUriValidator-- URI validation logicSpring Boot 4 fix:
spring-boot-starter-security-saml2dependency (replaces directspring-security-saml2-service-providerdependency). Spring Boot 4 moved the SAML2 auto-configuration to a separate module; without the starter, theRelyingPartyRegistrationRepositorybean is not created and thesaml2profile fails to start.Configuration (disabled by default):
Deployers who want external client authentication must explicitly configure which URI schemes they trust. This is an opt-in feature following the same pattern as OAuth2 redirect URI allowlists.
Steps for Testing
Prerequisites:
Test 1: Integration Tests (automated)
Test 2: Manual SAML2 + Redirect URI (with Keycloak)
Start Keycloak:
Verify the admin console is reachable at http://localhost:9080 (admin/admin).
Generate SAML2 signing credentials:
openssl req -x509 -newkey rsa:2048 -keyout saml-key.pem -out saml-cert.crt -days 365 -nodes -subj "/CN=artemis" openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in saml-key.pem -out saml-key-pkcs8.pemAdd the following to your
application-local.yml:Replace
<ABSOLUTE_PATH_TO>with the actual absolute paths to the generated files.Start Artemis with the
saml2profile. Make suresaml2comes beforelocalin the profile list soapplication-local.ymloverridesapplication-saml2.yml:Note: Do not include the
buildagentprofile together withsaml2, asbuildagentexcludes the JPA auto-configuration.Test redirect flow: Open browser at
http://localhost:8080/saml2/authenticate/keycloak?redirect_uri=vscode://artemis/callback, log in assaml2user1/password. Verify the browser redirects tovscode://artemis/callback?jwt=<valid-jwt>.Test normal web flow: Open
http://localhost:8080/saml2/authenticate/keycloak(withoutredirect_uri), log in. Verify you are redirected to/(the Artemis dashboard), not to an external URI.Test invalid schemes: Open
http://localhost:8080/saml2/authenticate/keycloak?redirect_uri=https://evil.com/callback. Verify thehttpsscheme is rejected (no RelayState in the SAML request, user lands on/after login).Test password login: Verify normal password login (
artemis_admin/artemis_admin) still works.Testserver States
N/A (infrastructure/config change, no testserver deployment needed)
Review Progress
Code Review
Manual Tests
Test Coverage
Server
Last updated: 2026-04-16 11:10:16 UTC