-
Notifications
You must be signed in to change notification settings - Fork 16
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
OIDC integration PoC #516
Draft
GPortas
wants to merge
24
commits into
develop
Choose a base branch
from
poc/oidc_pkce
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
OIDC integration PoC #516
Conversation
This file contains 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
…tibility with bearer auth feature flag
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.
What this PR does / why we need it:
This PR establishes a PoC for the new OIDC authentication, following the approach of using an OIDC-PKCE library on the client side (SPA) for user login and tokens retrieval, and the existing BearerTokenAuthMechanism (with some minor modifications) on the server side for API auth.
Changes in the SPA
We are using https://www.npmjs.com/package/react-oauth2-code-pkce, which is a lightweight package that easily integrates our SPA with an OIDC identity provider using PKCE. The library syncs with the OIDC provider to manage token refresh and expiration, as well as allowing us to restrict access to certain routes based on whether they are protected or not.
We have added a containerized Keycloak to the dev-env network with some pre-created built-in users to test the flow. Nginx reverse proxy remains the only entry point for the users (port 8000) but now redirecting authentication-related routes to the Keycloak instance.
Changes in js-dataverse
In js-dataverse, we have implemented a new authentication mechanism to send the generated bearer token (after successful OIDC login) in each API request. This implementation is very simple (~10 lines of code), since the package easily allows extending new authentication mechanisms as required.
The changes are implemented in this PR: IQSS/dataverse-client-javascript#201 (The PR generated npm tag is used in the SPA)
Changes in Dataverse
The only changes made on the Dataverse side involve the current BearerTokenAuthMechanism. Specifically, we have enabled the creation of users when a valid bearer token is sent, but does not correspond to an existing Dataverse user.
Now in such case, the user is created within the BearerTokenAuthMechanism, transparently to the calling user, ensuring that this user exists in Dataverse for subsequent requests for that calling user.
The changes are present in this PR: IQSS/dataverse#10910
These changes are not intended to be final; given that this is a PoC, the implementation may appear somewhat rough. The information needed to create the user is extracted from the JWT itself, as Keycloak includes the necessary claims for user identification. However, as noted in a TODO comment within the PR, it will be necessary to supplement this information—possibly by calling the IdP—when the claims are insufficient for identification.
Demo
Screen.Recording.2024-10-15.at.12.30.42.mov
Suggestions on how to test this:
Make sure your dev-env/.env file is filled with the appropriate data. For the
REGISTRY
variable, please set ghcr.io, as we will use a PR-generated dataverse image.Navigate with
cd packages/design-system && npm run build
to build the design system.Now you can run the entire PoC by navigating with
cd dev-env
simply executing the following command:./run-env.sh poc-oidc-spa-integration
OIDC login credentials
Aditional resources
Diagram from the auth redesign docs
PoC diagram