Skip to content

Commit 28d1dd9

Browse files
committed
Setup basic ORY Kratos + Oathkeeper apps
Signed-off-by: Federico Busetti <[email protected]>
1 parent bdec8fc commit 28d1dd9

File tree

8 files changed

+476
-1
lines changed

8 files changed

+476
-1
lines changed

.idea/dataSources.xml

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

auth_volumes/kratos/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
db.sqlite
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"$id": "https://schemas.ory.sh/presets/kratos/quickstart/email-password/identity.schema.json",
3+
"$schema": "http://json-schema.org/draft-07/schema#",
4+
"title": "Person",
5+
"type": "object",
6+
"properties": {
7+
"traits": {
8+
"type": "object",
9+
"properties": {
10+
"email": {
11+
"type": "string",
12+
"format": "email",
13+
"title": "E-Mail",
14+
"minLength": 3,
15+
"ory.sh/kratos": {
16+
"credentials": {
17+
"password": {
18+
"identifier": true
19+
}
20+
},
21+
"verification": {
22+
"via": "email"
23+
},
24+
"recovery": {
25+
"via": "email"
26+
}
27+
}
28+
},
29+
"name": {
30+
"type": "object",
31+
"properties": {
32+
"first": {
33+
"title": "First Name",
34+
"type": "string"
35+
},
36+
"last": {
37+
"title": "Last Name",
38+
"type": "string"
39+
}
40+
}
41+
}
42+
},
43+
"required": [
44+
"email"
45+
],
46+
"additionalProperties": false
47+
}
48+
}
49+
}

auth_volumes/kratos/kratos.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
serve:
2+
public:
3+
# This URL has to match the one in oathkeeper rules config
4+
# we'll probably want to remove references to ory and kratos
5+
base_url: http://127.0.0.1:8080/.ory/kratos/public/
6+
# We're proxying the requests through oathkeeper, need CORS
7+
cors:
8+
enabled: true
9+
allowed_origins:
10+
- http://127.0.0.1:8080
11+
allowed_methods:
12+
- POST
13+
- GET
14+
- PUT
15+
- PATCH
16+
- DELETE
17+
allowed_headers:
18+
- Authorization
19+
- Cookie
20+
- Content-Type
21+
exposed_headers:
22+
- Content-Type
23+
- Set-Cookie
24+
admin:
25+
# This is the internal URL, we'll be accessing using docker network
26+
# mainly to get the JWKS endpoint and do token validation
27+
base_url: http://kratos:4434/
28+
29+
selfservice:
30+
# URLs are using the Oathkeeper
31+
default_browser_return_url: http://127.0.0.1:8080/
32+
allowed_return_urls:
33+
- http://127.0.0.1:8080
34+
- http://localhost:19006/Callback
35+
- exp://localhost:8081/--/Callback
36+
37+
methods:
38+
password:
39+
enabled: true
40+
# totp:
41+
# config:
42+
# issuer: Kratos
43+
# enabled: true
44+
# lookup_secret:
45+
# enabled: true
46+
# link:
47+
# enabled: true
48+
# code:
49+
# enabled: true
50+
51+
flows:
52+
error:
53+
ui_url: http://127.0.0.1:8080/error
54+
55+
settings:
56+
ui_url: http://127.0.0.1:8080/settings
57+
privileged_session_max_age: 15m
58+
required_aal: highest_available
59+
60+
# If we enable recovery or verification we need also
61+
# MailSlurper in the docker-compose file
62+
recovery:
63+
enabled: false
64+
ui_url: http://127.0.0.1:8080/recovery
65+
use: code
66+
verification:
67+
enabled: false
68+
ui_url: http://127.0.0.1:8080/verification
69+
use: code
70+
after:
71+
default_browser_return_url: http://127.0.0.1:8080/
72+
73+
logout:
74+
after:
75+
default_browser_return_url: http://127.0.0.1:8080/login
76+
77+
login:
78+
ui_url: http://127.0.0.1:8080/login
79+
lifespan: 10m
80+
81+
registration:
82+
lifespan: 10m
83+
ui_url: http://127.0.0.1:8080/registration
84+
after:
85+
password:
86+
hooks:
87+
- hook: session
88+
# - hook: show_verification_ui
89+
90+
log:
91+
level: info
92+
format: text
93+
leak_sensitive_values: true
94+
95+
secrets:
96+
cookie:
97+
- PLEASE-CHANGE-ME-I-AM-VERY-INSECURE
98+
cipher:
99+
- 32-LONG-SECRET-NOT-SECURE-AT-ALL
100+
101+
ciphers:
102+
algorithm: xchacha20-poly1305
103+
104+
hashers:
105+
algorithm: bcrypt
106+
bcrypt:
107+
cost: 8
108+
109+
identity:
110+
default_schema_id: default
111+
schemas:
112+
- id: default
113+
url: file:///etc/config/kratos/identity.schema.json
114+
115+
courier:
116+
smtp:
117+
connection_uri: smtps://test:test@mailslurper:1025/?skip_ssl_verify=true
118+
119+
feature_flags:
120+
use_continue_with_transitions: true
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Kratos public API for authorized and unauthorized traffic
2+
- id: "ory:kratos:public"
3+
upstream:
4+
preserve_host: true
5+
url: "http://kratos:4433"
6+
strip_path: /.ory/kratos/public
7+
match:
8+
# This URL has to match serve.public.base_url in kratos config
9+
# we'll probably want to remove references to ory and kratos
10+
url: "http://127.0.0.1:8080/.ory/kratos/public/<**>"
11+
methods:
12+
- GET
13+
- POST
14+
- PUT
15+
- DELETE
16+
- PATCH
17+
authenticators:
18+
- handler: noop
19+
authorizer:
20+
handler: allow
21+
mutators:
22+
- handler: noop
23+
24+
# UI Access for anonymous traffic (Home page)
25+
- id: "ory:auth-ui:anonymous"
26+
upstream:
27+
preserve_host: true
28+
url: "http://auth-ui:3000"
29+
match:
30+
url: "http://127.0.0.1:8080/"
31+
methods:
32+
- GET
33+
authenticators:
34+
- handler: anonymous
35+
authorizer:
36+
handler: allow
37+
mutators:
38+
- handler: noop
39+
40+
# UI Access for anonymous traffic (Other pages)
41+
- id: "ory:auth-ui-home:anonymous"
42+
upstream:
43+
preserve_host: true
44+
url: "http://auth-ui:3000"
45+
match:
46+
url: "http://127.0.0.1:8080/<{registration,welcome,recovery,verification,login,error,health/{alive,ready},**.css,**.js,**.png,**.svg,**.woff*}>"
47+
methods:
48+
- GET
49+
authenticators:
50+
- handler: anonymous
51+
authorizer:
52+
handler: allow
53+
mutators:
54+
- handler: noop
55+
56+
# UI Access for logged-in only pages
57+
- id: "ory:kratos-selfservice-ui-node:protected"
58+
upstream:
59+
preserve_host: true
60+
url: "http://auth-ui:3000"
61+
match:
62+
url: "http://127.0.0.1:8080/<{sessions,settings}>"
63+
methods:
64+
- GET
65+
authenticators:
66+
- handler: cookie_session
67+
authorizer:
68+
handler: allow
69+
mutators:
70+
- handler: id_token
71+
errors:
72+
- handler: redirect
73+
config:
74+
to: http://127.0.0.1:8080/login
75+
76+
# Dev container access to protected /hello endpoint
77+
- id: "http_app:protected"
78+
upstream:
79+
preserve_host: true
80+
url: "http://dev:8000"
81+
match:
82+
url: "http://127.0.0.1:8080/hello<{,/,/**}>"
83+
methods:
84+
- GET
85+
authenticators:
86+
# Get opaque token from cookie
87+
- handler: cookie_session
88+
89+
# Or from bearer token
90+
# Note this is not a secure way to do authentication but
91+
# but we can use it for local development (i.e. Postman)
92+
# Refer to: https://www.ory.sh/docs/kratos/self-service/flows/user-login#login-for-api-clients-and-clients-without-browsers
93+
- handler: bearer_token
94+
authorizer:
95+
handler: allow
96+
mutators:
97+
- handler: id_token
98+
errors:
99+
- handler: redirect
100+
config:
101+
to: http://127.0.0.1:8080/login
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"keys": [
3+
{
4+
"use": "sig",
5+
"kty": "RSA",
6+
"kid": "a2aa9739-d753-4a0d-87ee-61f101050277",
7+
"alg": "RS256",
8+
"n": "zpjSl0ySsdk_YC4ZJYYV-cSznWkzndTo0lyvkYmeBkW60YHuHzXaviHqonY_DjFBdnZC0Vs_QTWmBlZvPzTp4Oni-eOetP-Ce3-B8jkGWpKFOjTLw7uwR3b3jm_mFNiz1dV_utWiweqx62Se0SyYaAXrgStU8-3P2Us7_kz5NnBVL1E7aEP40aB7nytLvPhXau-YhFmUfgykAcov0QrnNY0DH0eTcwL19UysvlKx6Uiu6mnbaFE1qx8X2m2xuLpErfiqj6wLCdCYMWdRTHiVsQMtTzSwuPuXfH7J06GTo3I1cEWN8Mb-RJxlosJA_q7hEd43yYisCO-8szX0lgCasw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