Skip to content

Commit 17cc2dd

Browse files
committed
Create a separate staff schema based on email domain and add support for impersonation header
Signed-off-by: Federico Busetti <[email protected]>
1 parent 961355c commit 17cc2dd

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

.idea/dataSources.xml

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

auth_volumes/kratos/identity.schema.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"$id": "https://schemas.ory.sh/presets/kratos/quickstart/email-password/identity.schema.json",
32
"$schema": "http://json-schema.org/draft-07/schema#",
43
"title": "Person",
54
"type": "object",

auth_volumes/kratos/kratos.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ hashers:
107107
cost: 8
108108

109109
identity:
110-
default_schema_id: default
110+
default_schema_id: staff
111111
schemas:
112+
- id: staff
113+
url: file:///etc/config/kratos/staff.schema.json
112114
- id: default
113115
url: file:///etc/config/kratos/identity.schema.json
114116

auth_volumes/kratos/staff.schema.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Staff",
4+
"type": "object",
5+
"properties": {
6+
"traits": {
7+
"type": "object",
8+
"properties": {
9+
"email": {
10+
"type": "string",
11+
"format": "email",
12+
"title": "E-Mail",
13+
"minLength": 3,
14+
"pattern": "^.*@staffdomain\\.com$",
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/oathkeeper/oathkeeper.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,10 @@ mutators:
9696
jwks_url: file:///etc/config/oathkeeper/id_token.jwks.json
9797
claims: |
9898
{
99+
{{ if eq .Extra.identity.schema_id "staff" }}
100+
{{ if .MatchContext.Header.Get "x-impersonate" }}
101+
"impersonate": {{ .MatchContext.Header.Get "x-impersonate" | toJson }},
102+
{{ end }}
103+
{{ end }}
99104
"session": {{ .Extra | toJson }}
100105
}

0 commit comments

Comments
 (0)