Hello I have an identity schema that has some fields defined and i want all those fields to also be available in the jwt token how to do that
my schema:{
"$id": "
https://example.com/registration.schema.json",
"$schema": "
http://json-schema.org/draft-07/schema#",
"title": "Person",
"type": "object",
"properties": {
"traits": {
"type": "object",
"properties": {
"phone_number": {
"type": "string",
"format": "tel",
"title": "Phone number",
"minLength": 10,
"maxLength": 15,
"ory.sh/kratos": {
"credentials": {
"code": {
"identifier": true,
"via": "sms"
}
},
"recovery": {
"via": "sms"
},
"verification": {
"via": "sms"
}
}
},
"email": {
"type": "string",
"format": "email",
"title": "E-Mail",
"minLength": 3,
"ory.sh/kratos": {
"credentials": {
"password": {
"identifier": true
}
},
"recovery": {
"via": "email"
},
"verification": {
"via": "email"
}
}
},
"role": {
"type": "string",
"title": "Role",
"enum": ["user", "admin", "moderator"],
"default": "user"
},
"name": {
"type": "object",
"properties": {
"first": {
"type": "string",
"title": "First Name",
"minLength": 1
},
"last": {
"type": "string",
"title": "Last Name",
"minLength": 1
}
},
"required": ["first", "last"]
}
},
"required": ["name", "role"],
"oneOf": [
{
"properties": {
"email": { "type": "string" }
},
"required": ["email"],
"not": {
"required": ["phone_number"]
}
},
{
"properties": {
"phone_number": { "type": "string" }
},
"required": ["phone_number"],
"not": {
"required": ["email"]
}
}
],
"additionalProperties": false
}
}
}
kratos.yml
version v25.4.0
dsn:
postgres://kratos:kratos-secret@kratos-db:5432/kratos?sslmode=disable
serve:
public:
base_url:
http://127.0.0.1:4433/
cors:
enabled: true
admin:
base_url:
http://127.0.0.1:4434/
log:
level: debug
leak_sensitive_values: true
identity:
default_schema_id: default
schemas:
- id: default
url: file:///etc/config/kratos/identity.schema.json
selfservice:
default_browser_return_url:
http://127.0.0.1:4455/
allowed_return_urls:
-
http://127.0.0.1:4455/
methods:
password:
enabled: true
code:
enabled: true
passwordless_enabled: true
config:
lifespan: 15m
flows:
login:
ui_url:
http://127.0.0.1:4455/login
lifespan: 10m
registration:
ui_url:
http://127.0.0.1:4455/registration
lifespan: 10m
after:
default_browser_return_url:
http://127.0.0.1:4455/welcome
password:
hooks:
- hook: session
code:
hooks:
- hook: session
recovery:
enabled: true
ui_url:
http://127.0.0.1:4455/recovery
lifespan: 10m
verification:
enabled: true
ui_url:
http://127.0.0.1:4455/verification
lifespan: 10m
courier:
channels:
- id: sms
type: http
request_config:
url:
https://api.twilio.com/2010-04-01/Accounts/REDACTED/Messages.json
method: POST
# We are using twilio sms sending service not otp service
# The logic of sending otp is handled by kratos itself
# Jsonnet function that returns an object with To, From, and Body fields
body:
REDACTED
headers:
Content-Type: application/x-www-form-urlencoded
auth:
type: basic_auth
config:
user:
REDACTED
password:
REDACTED
templates:
registration_code:
valid:
sms:
body:
plaintext:
base64://WW91ciByZWdpc3RyYXRpb24gY29kZSBpczoge3sgLlJlZ2lzdHJhdGlvbkNvZGUgfX0=
email:
subject:
base64://Tm90aGluZyB0byBzZW5k
body:
plaintext:
base64://Tm90aGluZyB0byBzZW5k
html:
base64://PGgxPk5vdGhpbmcgdG8gc2VuZDwvaDE+
login_code:
valid:
sms:
body:
plaintext:
base64://WW91ciBsb2dpbiBjb2RlIGlzOiB7eyAuTG9naW5Db2RlIH19
email:
subject:
base64://Tm90aGluZyB0byBzZW5k
body:
plaintext:
base64://Tm90aGluZyB0byBzZW5k
html:
base64://PGgxPk5vdGhpbmcgdG8gc2VuZDwvaDE+
verification_code:
valid:
sms:
body:
plaintext:
base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0=
email:
subject:
base64://Tm90aGluZyB0byBzZW5k
body:
plaintext:
base64://Tm90aGluZyB0byBzZW5k
html:
base64://PGgxPk5vdGhpbmcgdG8gc2VuZDwvaDE+
recovery_code:
valid:
sms:
body:
plaintext:
base64://WW91ciByZWNvdmVyeSBjb2RlIGlzOiB7eyAuUmVjb3ZlcnlDb2RlIH19
email:
subject:
base64://Tm90aGluZyB0byBzZW5k
body:
plaintext:
base64://Tm90aGluZyB0byBzZW5k
html:
base64://PGgxPk5vdGhpbmcgdG8gc2VuZDwvaDE+