forked from IQSS/dataverse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merged OIDC implementeation from IQSS#10905
- Loading branch information
Showing
32 changed files
with
677 additions
and
950 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
New OpenID Connect implementation including new log in scenarios (see [the guides](https://dataverse-guide--10905.org.readthedocs.build/en/10905/installation/oidc.html#choosing-provisioned-providers-at-log-in)) for the current JSF frontend, the new Single Page Application (SPA) frontend, and a generic API usage. The API scenario using Bearer Token authorization is illustrated with a Python script that can be found in the `doc/sphinx-guides/_static/api/bearer-token-example` directory. This Python script prompts you to log in to the Keycloak in a new browser window using selenium. You can run that script with the following commands: | ||
|
||
```shell | ||
cd doc/sphinx-guides/_static/api/bearer-token-example | ||
./run.sh | ||
``` | ||
|
||
This script is safe for production use, as it does not require you to know the client secret or the user credentials. Therefore, you can safely distribute it as a part of your own Python script that lets users run some custom tasks. | ||
|
||
The following settings become deprecated with this change and can be removed from the configuration: | ||
- `dataverse.auth.oidc.pkce.enabled` | ||
- `dataverse.auth.oidc.pkce.method` | ||
- `dataverse.auth.oidc.pkce.max-cache-size` | ||
- `dataverse.auth.oidc.pkce.max-cache-age` | ||
|
||
The following settings new: | ||
- `dataverse.auth.oidc.issuer-identifier` | ||
- `dataverse.auth.oidc.issuer-identifier-field` | ||
- `dataverse.auth.oidc.subject-identifier-field` | ||
|
||
Also, the bearer token authentication is now always enabled. Therefore, the `dataverse.feature.api-bearer-auth` feature flag is no longer used and can be removed from the configuration as well. | ||
|
||
The new implementation relies now on the builtin OIDC support in our application server (Payara). With this change the Nimbus SDK is no longer used and is removed from the dependencies. |
28 changes: 28 additions & 0 deletions
28
doc/sphinx-guides/_static/api/bearer-token-example/get_session.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import contextlib | ||
import selenium.webdriver as webdriver | ||
import selenium.webdriver.support.ui as ui | ||
import re | ||
import json | ||
import requests | ||
|
||
with contextlib.closing(webdriver.Firefox()) as driver: | ||
driver.get("http://localhost:8080/oidc/login?target=API&oidcp=oidc-mpconfig") | ||
wait = ui.WebDriverWait(driver, 100) # timeout after 100 seconds | ||
wait.until(lambda driver: "accessToken" in driver.page_source) | ||
driver.get("view-source:http://localhost:8080/api/v1/oidc/session") | ||
result = wait.until( | ||
lambda driver: ( | ||
driver.page_source if "accessToken" in driver.page_source else False | ||
) | ||
) | ||
m = re.search("<pre>(.+?)</pre>", result) | ||
if m: | ||
found = m.group(1) | ||
session = json.loads(found) | ||
|
||
token = session["data"]["accessToken"] | ||
endpoint = "http://localhost:8080/api/v1/users/:me" | ||
headers = {"Authorization": "Bearer " + token} | ||
|
||
print() | ||
print(requests.get(endpoint, headers=headers).json()) |
2 changes: 2 additions & 0 deletions
2
doc/sphinx-guides/_static/api/bearer-token-example/requirements.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
selenium | ||
requests |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
python3 -m venv run_env | ||
source run_env/bin/activate | ||
python3 -m pip install -r requirements.txt | ||
python3 get_session.py | ||
rm -rf run_env |
22 changes: 22 additions & 0 deletions
22
doc/sphinx-guides/_static/frontend/PKCE-example/PKCE-example.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!doctype html> | ||
<html> | ||
|
||
<body> | ||
<script src="http://unpkg.com/keycloak-js@25.0.6/dist/keycloak-authz.js"></script> | ||
<script src="http://unpkg.com/keycloak-js@25.0.6/dist/keycloak.js"></script> | ||
|
||
<script> | ||
const kc = new Keycloak({ | ||
url: 'http://keycloak.mydomain.com:8090', | ||
realm: 'test', | ||
clientId: 'test' | ||
}); | ||
kc.init({ | ||
pkceMethod: 'S256', | ||
redirectUri: 'http://localhost:8080/api/v1/users/:me' | ||
}); | ||
kc.login(); | ||
</script> | ||
</body> | ||
|
||
</html> |
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
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
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
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
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
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
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
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
Oops, something went wrong.