Skip to content
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

9228 - add OIDC development setup for OIDC login feature testing #9234

Merged
merged 10 commits into from
Jan 9, 2023

Conversation

GPortas
Copy link
Contributor

@GPortas GPortas commented Dec 16, 2022

What this PR does / why we need it:

As stated in #9228, developers currently don't have a way to test the login with OIDC feature of Dataverse.

This PR includes a dockerized Keycloak setup with OIDC support for development purposes, as well as its associated documentation.

TODOs.

Which issue(s) this PR closes:

Closes #9228

Special notes for your reviewer:
Not yet.

Suggestions on how to test this:

Follow the next steps:

  1. (Positioned in /conf/keycloak/) Run Keycloak docker container: You can use docker-compose file or run-keycloak.sh script.
  2. Verify that Keycloak is running on http://localhost:8090/.
  3. Verify that Dataverse is locally running
  4. (Positioned in /conf/keycloak/) Execute the following API call which enables the Keycloak OIDC client as an authentication provider for Dataverse: curl -X POST -H 'Content-type: application/json' --upload-file oidc-keycloak-auth-provider.json http://localhost:8080/api/admin/authenticationProviders
  5. Test that the new OIDC auth flow works. A new option "OIDC-Keycloak" should appear on the login screen. The credentials for the Keycloak test user are: kcuser / kcpassword (usr/pwd).

Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No.

Is there a release notes update needed for this change?:
Not sure.

Additional documentation:
Not yet.

@GPortas GPortas marked this pull request as ready for review December 19, 2022 14:00
@pdurbin pdurbin added Feature: Account & User Info Size: 3 A percentage of a sprint. 2.1 hours. labels Dec 19, 2022
@pdurbin
Copy link
Member

pdurbin commented Dec 19, 2022

I gave this a size of 3. As long as a developer has Docker installed, it should be pretty easy to spin up Keycloak, add the config, and to a quick test. The docs @GPortas wrote are excellent.

@mreekie
Copy link

mreekie commented Jan 4, 2023

Prioritization note:
@siacus This is work that is coming out of the re-architecture work.
We haven't discussed yet how we're going to priortize these so for now I've added it directly to the ordered backlog.

@mreekie mreekie added the NIH OTA: 1.7.2 7 | 1.7.2 | Implementation of UI modules to improve the dataset landing page and access to remote... label Jan 4, 2023
@mreekie
Copy link

mreekie commented Jan 4, 2023

Prioritization note: @siacus This is work that is coming out of the re-architecture work. We haven't discussed yet how we're going to priortize these so for now I've added it directly to the ordered backlog.

Corrected. This is part of: "NIH OTA: 1.7.1" and so is part of the NIH Backlog items.
Put it at the top.

@mreekie mreekie added NIH OTA: 1.7.1 (reArchitecture) 7 | 1.7.1 | Research & architecture for separating backend and frontend to enable a flexible, sca... and removed NIH OTA: 1.7.2 7 | 1.7.2 | Implementation of UI modules to improve the dataset landing page and access to remote... labels Jan 4, 2023
@GPortas GPortas requested a review from qqmyers January 5, 2023 11:42
@pdurbin pdurbin self-assigned this Jan 6, 2023
Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and it works amazingly well. Thank you, @GPortas!! I've wanted something like this for over three years, when OIDC support was added in PR #6433 by @poikilotherm and I never had an easy way to test it myself.

It's inconvenient to add screenshots and details in the review box but I'll add another comment in a minute. I did make a couple tiny doc tweaks.

Approved. Thanks again! 🎉 🚀

IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) automation moved this from Ready for Review to QA ✅ Jan 6, 2023
@pdurbin
Copy link
Member

pdurbin commented Jan 6, 2023

This pull request is a dream come true. Just works!

I did make a couple tiny tweaks to the docs (formatting stuff and a security warning not to run this config it prod since the client secret is in GitHub).

The Bash option was listed first so I tried it first. Worked great. Here's the output:

$ cd conf/keycloak
$ ./run-keycloak.sh
Unable to find image 'jboss/keycloak:16.1.1' locally
16.1.1: Pulling from jboss/keycloak
ac10f00499d5: Pull complete
96d53117c12e: Pull complete
1d929376eb7f: Pull complete
93e1e1b6d192: Pull complete
f353ba0db29e: Pull complete
Digest: sha256:abdb1aea6c671f61a594af599f63fbe78c9631767886d9030bc774d908422d0a
Status: Downloaded newer image for jboss/keycloak:16.1.1
cc78453726bb8292e241472b3d30351e651d8a35a431ad5ea4c7f7063787842b
INFO - Keycloak container created and running

I got a working Keycloak instance at http://localhost:8090 which looked like this:

Screen Shot 2023-01-06 at 2 54 34 PM

Then I loaded up the auth provider:

$ curl -X POST -H 'Content-type: application/json' --upload-file oidc-keycloak-auth-provider.json http://localhost:8080/api/admin/authenticationProviders
{"status":"OK","data":{"id":"oidc-keycloak","factoryAlias":"oidc","title":"OIDC-Keycloak","subtitle":"OIDC-Keycloak","factoryData":"type: oidc | issuer: http://localhost:8090/auth/realms/oidc-realm | clientId: oidc-client | clientSecret: ss6gE8mODCDfqesQaSG3gwUwZqZt547E","enabled":true}}

Here are screenshots of the login process:

Screen Shot 2023-01-06 at 2 55 51 PM
Screen Shot 2023-01-06 at 2 56 05 PM
Screen Shot 2023-01-06 at 2 56 34 PM
Screen Shot 2023-01-06 at 2 56 56 PM
Screen Shot 2023-01-06 at 2 57 31 PM
Screen Shot 2023-01-06 at 2 57 47 PM
Screen Shot 2023-01-06 at 2 58 11 PM
Screen Shot 2023-01-06 at 2 58 47 PM

One thing to note above is that no username was prepopulated (given name, family name, and email were). @poikilotherm already wrote this bug up here:

This PR means that issue will be MUCH easier for a developer to work on! 🎉

During the auth meeting today I said I was curious what gets stored as a persistentUserId for an Keycloak user. It turns out that it's a UUID, like this: "persistentUserId": "47411075-985b-4587-bbde-167e3fd8c949"

Here's the full output of a dump of this keycloak user:

$ curl -s http://localhost:8080/api/admin/authenticatedUsers/kcuser | jq .
{
  "status": "OK",
  "data": {
    "id": 2,
    "identifier": "@kcuser",
    "displayName": "Test Test",
    "firstName": "Test",
    "lastName": "Test",
    "email": "test@test.com",
    "superuser": false,
    "deactivated": false,
    "persistentUserId": "47411075-985b-4587-bbde-167e3fd8c949",
    "createdTime": "2023-01-06T19:57:37Z",
    "lastLoginTime": "2023-01-06T19:57:37Z",
    "authenticationProviderId": "oidc-keycloak"
  }
}

I also tested the rm-keycloak.sh script and the docker compose option. It all worked great. Thanks again, @GPortas!

@GPortas
Copy link
Contributor Author

GPortas commented Jan 9, 2023

Very nice step-by-step guide with screenshots and good information about persistentUserId.

Thank you @pdurbin!

@mreekie
Copy link

mreekie commented Jan 9, 2023

Updated information.

  • This was an add-on from Phil for the "free for all" sprint

@kcondon kcondon self-assigned this Jan 9, 2023
@kcondon kcondon merged commit 03afc7f into IQSS:develop Jan 9, 2023
IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) automation moved this from QA ✅ to Done 🚀 Jan 9, 2023
@pdurbin
Copy link
Member

pdurbin commented Jan 9, 2023

I said I would pick this up during the auth meeting last week as we discussed the Dataverse - SPA Authentication V1 doc.

It seemed absolutely ready to merge. High value (extremely useful for ongoing auth work). Zero risk. So I went ahead and moved it to QA. Next time, I'm happy to simply merge it if that's better. I was certainly tempted! 😄

@pdurbin pdurbin added this to the 5.13 milestone Jan 23, 2023
@mreekie mreekie added pm.GREI-d-1.7.1 NIH, yr1, aim7, task1: Research & architecture for separating backend and frontend pm.GREI-d-1.7.2 NIH, yr1, aim7, task2: Improve the dataset landing page labels Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Account & User Info NIH OTA: 1.7.1 (reArchitecture) 7 | 1.7.1 | Research & architecture for separating backend and frontend to enable a flexible, sca... pm.GREI-d-1.7.1 NIH, yr1, aim7, task1: Research & architecture for separating backend and frontend pm.GREI-d-1.7.2 NIH, yr1, aim7, task2: Improve the dataset landing page Size: 3 A percentage of a sprint. 2.1 hours.
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

As a developer, I'd like Keycloak or similar so I can test OIDC login
5 participants