-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Burtey
committed
Jun 4, 2023
1 parent
d6cb79b
commit cc16259
Showing
11 changed files
with
211 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
serve: | ||
cookies: | ||
same_site_mode: Lax | ||
|
||
urls: | ||
self: | ||
issuer: http://127.0.0.1:4444 | ||
consent: http://127.0.0.1:3000/consent | ||
login: http://127.0.0.1:3000/login | ||
logout: http://127.0.0.1:3000/logout | ||
|
||
secrets: | ||
system: | ||
- youReallyNeedToChangeThis | ||
|
||
oidc: | ||
subject_identifiers: | ||
supported_types: | ||
- pairwise | ||
- public | ||
pairwise: | ||
salt: youReallyNeedToChangeThis |
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 |
---|---|---|
|
@@ -87,3 +87,7 @@ services: | |
fulcrum: | ||
ports: | ||
- "50001:50001" | ||
hydra: | ||
ports: | ||
- "4444:4444" # Public port | ||
- "4445:4445" # Admin port |
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,116 @@ | ||
|
||
Make sure you have `hydra` command line installed | ||
|
||
```sh | ||
brew install ory-hydra | ||
``` | ||
|
||
# run the experiment: | ||
|
||
Follow the instructions below | ||
|
||
|
||
On console 1: | ||
|
||
launch the hydra login consent node, which will provide the authentication (interactive with kratos API) and consent page. | ||
|
||
```sh | ||
hydra-login-consent-node % yarn start | ||
``` | ||
|
||
On console 2: | ||
```sh | ||
galoy % make start-deps | ||
``` | ||
|
||
On console 3: | ||
Follow the instructions below | ||
|
||
|
||
## create a OAuth2 client | ||
|
||
Think of the client as the service that need to get the delegation access | ||
|
||
If you use concourse currently, you'll login with Google Workspace. | ||
|
||
When you login through concourse you'll use google workspace. The client is concourse in this example. | ||
|
||
For the galoy stack, some examples of clients could be Alby, a boltcard service, a nostr wallet connect service, an accountant that access the wallet in read only. | ||
|
||
|
||
```sh | ||
code_client=$(hydra create client \ | ||
--endpoint http://127.0.0.1:4445 \ | ||
--grant-type authorization_code,refresh_token \ | ||
--response-type code,id_token \ | ||
--format json \ | ||
--scope openid --scope offline \ | ||
--redirect-uri http://127.0.0.1:5555/callback | ||
) | ||
|
||
code_client_id=$(echo $code_client | jq -r '.client_id') | ||
code_client_secret=$(echo $code_client | jq -r '.client_secret') | ||
``` | ||
|
||
## Initiate the request | ||
|
||
this simulate the front end client. | ||
would be mobile app for adding a boltcard | ||
|
||
```sh | ||
hydra perform authorization-code \ | ||
--client-id $code_client_id \ | ||
--client-secret $code_client_secret \ | ||
--endpoint http://127.0.0.1:4444/ \ | ||
--port 5555 \ | ||
--scope openid --scope offline | ||
``` | ||
|
||
do the login and consent | ||
|
||
copy the Access token to the mobile app. | ||
|
||
you are now connect through Hydra. | ||
|
||
|
||
### limitations | ||
|
||
as both settings in Oathkeeper: | ||
|
||
``` | ||
- handler: oauth2_introspection | ||
config: | ||
introspection_url: http://hydra:4445/admin/oauth2/introspect | ||
``` | ||
|
||
and | ||
|
||
``` | ||
- handler: bearer_token | ||
config: | ||
check_session_url: http://kratos:4433/sessions/whoami | ||
preserve_path: true | ||
preserve_query: true | ||
subject_from: identity.id | ||
extra_from: identity.traits | ||
``` | ||
|
||
rely on Authorization header, currency if hydra fails for the oauth2_introspection, Oathkeeper return an Unauthorized response | ||
|
||
so the bearer_token is not be tested. | ||
|
||
To mitigate this issue, either: | ||
- Hydra token should have a different header (not Authorization) than Kratos token | ||
- All requests should come through Hydra | ||
|
||
### debug | ||
|
||
hydra introspect token \ | ||
--format json-pretty \ | ||
--endpoint http://127.0.0.1:4445/ \ | ||
TOKEN | ||
# OR | ||
curl -X POST http://localhost:4445/admin/oauth2/introspect -d token=ory_at_TOKEN | ||
|
||
curl -I -X POST http://localhost:4456/decisions/graphql -H 'Authorization: Bearer ory_at_TOKEN' | ||
|
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 |
---|---|---|
|
@@ -57,6 +57,7 @@ scalar AuthToken | |
type AuthTokenPayload { | ||
authToken: AuthToken | ||
errors: [Error!]! | ||
id: ID! | ||
} | ||
|
||
""" | ||
|
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 |
---|---|---|
|
@@ -97,6 +97,7 @@ scalar AuthToken | |
type AuthTokenPayload { | ||
authToken: AuthToken | ||
errors: [Error!]! | ||
id: ID! | ||
} | ||
|
||
""" | ||
|
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