-
Notifications
You must be signed in to change notification settings - Fork 23
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
docs: add multitenancy keycloak integration tutorials #793
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
73b3c5f
docs: multitenancy phase 2 doc wip
ea82a57
docs: complete onboarding tut
52a7f2b
docs: minor adjustment
43e5dd3
docs: self-service doc wip
f0c9437
docs: self-service onboarding docs
fb21e91
docs: keycloak jwt migration tutorial
3b34172
docs: fix script to make tut work
8b24d18
docs: clean up
5ac5558
docs: fix typo in script
d32a9a2
docs: no ci commit [skip ci]
6632bdd
Merge branch 'main' into docs/mt-keycloak-tuts
cbdfa4d
docs: no ci commit [skip ci]
84cc78b
docs: correct http method
f17fa6a
docs: add keycloak convention
a078a06
docs: link tutorials to glossary
02cc1f7
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
petevielhaber aa21943
Update docs/docusaurus/multitenancy/tenant-migration.md
petevielhaber 8ee3d04
docs: reference UMA in glossary
e9d59ce
Update docs/docusaurus/multitenancy/tenant-migration.md
354d059
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
4d84dfa
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
208ba3f
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
4bf45ed
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
25dfc7a
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
7f0844f
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
ef79aff
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
c1b5944
Update docs/docusaurus/multitenancy/tenant-migration.md
16e0a93
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
a61a4fc
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
c0a1abe
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
411bb4d
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
9272e2e
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
841c5f4
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
ba43863
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
8aabde3
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
3aa0035
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
acd27e9
Update docs/docusaurus/multitenancy/tenant-onboarding-self-service.md
ee69483
Apply suggestions from code review
835faa3
Update docs/docusaurus/multitenancy/tenant-onboarding-ext-iam.md
dffbe69
docs: reference RPT in glossary
92f2a02
Update docs/docusaurus/multitenancy/tenant-migration.md
petevielhaber 70f0d24
Update docs/docusaurus/multitenancy/tenant-migration.md
petevielhaber a258118
Update docs/docusaurus/multitenancy/tenant-migration.md
petevielhaber e1ba578
Update docs/docusaurus/multitenancy/tenant-migration.md
petevielhaber 13a31fa
Update docs/docusaurus/multitenancy/tenant-migration.md
petevielhaber 493b06f
Update docs/docusaurus/multitenancy/tenant-migration.md
petevielhaber 32f90b7
Update docs/docusaurus/multitenancy/tenant-migration.md
petevielhaber e404e9b
Update docs/docusaurus/multitenancy/tenant-migration.md
petevielhaber 9d6c712
Merge branch 'main' into docs/mt-keycloak-tuts
yshyn-iohk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,175 @@ | ||||||
# Migration from `apikey` to `JWT` authentication | ||||||
|
||||||
PRISM Agent authentication supports multiple authentication methods simultaneously, which means the user can seamlessly use any available credentials including `apikey` or `JWT` to access the wallet. | ||||||
The agent's [UMA](/docs/concepts/glossary#uma) permission resource also exposes self-service permission endpoint, allowing users to manage the permissions for their wallets. | ||||||
It allows users to transition from `apikey` to `JWT` authentication without admin intervention.intervention. | ||||||
|
||||||
## Roles | ||||||
|
||||||
In the migration process from `apikey` to `JWT`, there is only one role: | ||||||
|
||||||
1. Tenant | ||||||
|
||||||
## Prerequisites | ||||||
|
||||||
1. Keycloak up and running | ||||||
2. Keycloak is configured the same as in [Tenant Onboarding Self-Service](./tenant-onboarding-self-service.md) | ||||||
3. PRISM Agent up and running | ||||||
4. PRISM Agent is configured the same as in [Tenant Onboarding Self-Service](./tenant-onboarding-self-service.md) | ||||||
5. The user has access to the wallet using `apikey`. (See [Tenant Onboarding](./tenant-onboarding.md)) | ||||||
6. The user has an account registered on Keycloak | ||||||
|
||||||
## Overview | ||||||
|
||||||
This tutorial outlines the steps to transition from `apikey` to `JWT` authentication. | ||||||
Initially, users have wallet access through the `apikey` method. | ||||||
To migrate to `JWT` authentication, users can create a new UMA permission for their wallet and grant permission to their Keycloak account. | ||||||
|
||||||
## Endpoints | ||||||
|
||||||
### Agent endpoints | ||||||
| Endpoint | Description | Role | | ||||||
|--------------------------------------------|--------------------------------------|--------| | ||||||
| `GET /wallets` | List the wallets on PRISM Agent | Tenant | | ||||||
| `POST /wallets` | Create a new wallet on PRISM Agent | Tenant | | ||||||
| `POST /wallets/{walletId}/uma-permissions` | Create a uma-permission for a wallet | Tenant | | ||||||
| `GET /did-registrar/dids` | List the DIDs inside the wallet | Tenant | | ||||||
|
||||||
### Keycloak endpoints | ||||||
| Endpoint | Description | Role | | ||||||
|------------------------------------------------------|-----------------------|--------| | ||||||
| `POST /realms/{realm}/protocol/openid-connect/token` | Issue a new JWT token | Tenant | | ||||||
|
||||||
## Tenant interactions | ||||||
|
||||||
### 1. Check the existing wallets using `apikey` | ||||||
|
||||||
This tutorial assumes the tenant can access the wallet using `apikey`. | ||||||
Before granting more permission to the wallet, the `walletId` must be identified. | ||||||
To find the wallet, list them using `apikey`. | ||||||
|
||||||
```bash | ||||||
curl -X 'GET' \ | ||||||
'http://localhost:8080/prism-agent/wallets' \ | ||||||
-H 'accept: application/json' \ | ||||||
-H "apikey: my-tenant-token" | ||||||
``` | ||||||
|
||||||
Make sure to use the correct `apikey` from the pre-requisite. | ||||||
|
||||||
Response Example: | ||||||
|
||||||
```json | ||||||
{ | ||||||
"self": "/wallets", | ||||||
"kind": "WalletPage", | ||||||
"pageOf": "/wallets", | ||||||
"contents": [ | ||||||
{ | ||||||
"id": "99734c87-5c9d-4697-b5fd-dea4e9590ba7", | ||||||
"name": "my-wallet", | ||||||
"createdAt": "2023-01-01T00:00:00Z", | ||||||
"updatedAt": "2023-01-01T00:00:00Z" | ||||||
} | ||||||
] | ||||||
} | ||||||
``` | ||||||
|
||||||
### 2. Get the access token on keycloak | ||||||
|
||||||
Run this command to log in and get the access token | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```bash | ||||||
curl -X 'POST' \ | ||||||
'http://localhost:9980/realms/my-realm/protocol/openid-connect/token' \ | ||||||
-d "grant_type=password" \ | ||||||
-d "client_id=admin-cli" \ | ||||||
-d "username=alice" \ | ||||||
-d "password=1234" | ||||||
``` | ||||||
|
||||||
Make sure to use the correct username and password. | ||||||
Special attention on the `client_id`; this should be the actual `client_id` of the frontend application that logs the user in. | ||||||
For this tutorial, it is OK to use `admin-cli` | ||||||
|
||||||
Example token response (some fields omitted for readability) | ||||||
|
||||||
```json | ||||||
{ | ||||||
"access_token": "eyJhbGciOi...7ocDHofUDQ", | ||||||
"refresh_token": "eyJhbGciOi...otsEEi4eQA", | ||||||
... | ||||||
} | ||||||
``` | ||||||
|
||||||
### 3. Extract the subject ID from JWT | ||||||
|
||||||
When creating a UMA permission, it is important to provide the subject ID to grant permission. | ||||||
To get the subject ID of the tenant, one can inspect the JWT payload `sub` claim. | ||||||
|
||||||
Run this command to extract the `sub` claim of the token from previous step. | ||||||
|
||||||
```bash | ||||||
echo 'eyJhbGciOi...7ocDHofUDQ' | cut --delimiter='.' --fields=2 | base64 --decode | jq -r '.sub' | ||||||
``` | ||||||
|
||||||
Example result | ||||||
|
||||||
```log | ||||||
4a5c6ac9-12f5-4d1e-b8f2-667525c083fd | ||||||
``` | ||||||
|
||||||
### 4. Grant the user permission to the wallet | ||||||
|
||||||
UMA permission can be added to the current wallet, giving Keycloak users access. | ||||||
To do this, invoke the `POST /wallets/{walletId}/uma-permissions` endpoint on the agent. | ||||||
|
||||||
```bash | ||||||
curl -X 'POST' \ | ||||||
'http://localhost:8080/prism-agent/wallets/99734c87-5c9d-4697-b5fd-dea4e9590ba7/uma-permissions' \ | ||||||
-v \ | ||||||
-H 'accept: */*' \ | ||||||
-H "apikey: my-tenant-token" \ | ||||||
-H 'Content-Type: application/json' \ | ||||||
-d '{ | ||||||
"subject": "205e04b7-0158-41b0-89c3-f91c3a09f89b" | ||||||
}' | ||||||
``` | ||||||
|
||||||
Make sure to use the correct `subject` for the user and the correct `walletId` from the step earlier. | ||||||
|
||||||
The response should return the status `200 OK` in case of successful permission creation. | ||||||
|
||||||
### 5. Perform a simple action to verify access to PRISM Agent | ||||||
|
||||||
After successful UMA permission creation, the user should be able to use the `JWT` token to authenticate the wallet. | ||||||
List the wallet using a new `Authorization` header. The listed wallets should contain the wallet with the same ID in step 1. | ||||||
|
||||||
```bash | ||||||
curl -X 'GET' \ | ||||||
'http://localhost:8080/prism-agent/wallets' \ | ||||||
-H 'accept: application/json' \ | ||||||
-H 'Authorization: Bearer eyJhbGciOi...7ocDHofUDQ' | ||||||
``` | ||||||
|
||||||
Make sure to use the correct `JWT` from step 2. | ||||||
|
||||||
Response Example: | ||||||
|
||||||
```json | ||||||
{ | ||||||
"self": "/wallets", | ||||||
"kind": "WalletPage", | ||||||
"pageOf": "/wallets", | ||||||
"contents": [ | ||||||
{ | ||||||
"id": "99734c87-5c9d-4697-b5fd-dea4e9590ba7", | ||||||
"name": "my-wallet", | ||||||
"createdAt": "2023-01-01T00:00:00Z", | ||||||
"updatedAt": "2023-01-01T00:00:00Z" | ||||||
} | ||||||
] | ||||||
} | ||||||
``` | ||||||
|
||||||
This response indicates that the user should be able to perform any wallet interaction with the `JWT` and `apikey` interchangeably. |
Oops, something went wrong.
Oops, something went wrong.
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.
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.