Skip to content

Commit bd494da

Browse files
committed
Add example web_hook configuration after registration
Signed-off-by: Federico Busetti <[email protected]>
1 parent 17cc2dd commit bd494da

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

auth_volumes/kratos/kratos.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,21 @@ selfservice:
8585
password:
8686
hooks:
8787
- hook: session
88+
- hook: web_hook
89+
config:
90+
url: http://dev:8000/user_registered/
91+
method: "POST"
92+
# headers: { }
93+
# https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#jsonnet-templating
94+
body: file:///etc/config/kratos/user_registered.jsonnet
95+
can_interrupt: false
96+
emit_analytics_event: false
97+
# auth:
98+
# type: api_key
99+
# config:
100+
# name: ""
101+
# value: ""
102+
# in: header
88103
# - hook: show_verification_ui
89104

90105
log:
@@ -107,7 +122,7 @@ hashers:
107122
cost: 8
108123

109124
identity:
110-
default_schema_id: staff
125+
default_schema_id: default
111126
schemas:
112127
- id: staff
113128
url: file:///etc/config/kratos/staff.schema.json
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function(ctx) {
2+
user_id: ctx.identity.id,
3+
traits: {
4+
email: ctx.identity.traits.email,
5+
name: ctx.identity.traits.name,
6+
}
7+
}

src/http_app/routes/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from fastapi import FastAPI
22

3-
from http_app.routes import api, events, graphql, hello, ping
3+
from http_app.routes import api, events, graphql, hello, ping, user_registered_hook
44

55

66
def init_routes(app: FastAPI) -> None:
77
app.include_router(api.router)
88
app.include_router(ping.router)
99
app.include_router(hello.router)
1010
app.include_router(events.router)
11+
app.include_router(user_registered_hook.router)
1112
app.include_router(graphql.router, prefix="/graphql")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import logging
2+
3+
from fastapi import APIRouter, Request
4+
5+
router = APIRouter(prefix="/user_registered")
6+
7+
8+
@router.post("/")
9+
async def user_registered(request: Request):
10+
logging.info("User registered", extra={"body": await request.json()})
11+
return {"user_registered": "OK"}

0 commit comments

Comments
 (0)