Hi everyone, I’m experiencing an issue when tryin...
# ory-selfhosting
s
Hi everyone, I’m experiencing an issue when trying to set the recovery flow for the phone number field via
"sms"
. It throws an error stating that only
"email"
is a valid enum value, which doesn’t seem correct. Could you please take a look and share your suggestions on what might be causing this? Thanks in advance! Error:
Copy code
kratos                   | I[#] S[#/allOf/1] allOf failed
kratos                   |   I[#/properties/traits/properties/phone_number] S[#/allOf/1/properties/properties/properties/traits/properties/properties/patternProperties/.%2A/allOf/0] allOf failed             
kratos                   |     I[#/properties/traits/properties/phone_number] S[#/allOf/1/properties/properties/properties/traits/properties/properties/patternProperties/.%2A/allOf/0/$ref] doesn't validate with "<ory://identity-extension#>"                                                                                                                                                                                
kratos                   |       I[#/properties/traits/properties/phone_number] S[#/allOf/0] allOf failed
kratos                   |         I[#/properties/traits/properties/phone_number/ory.sh~1kratos/recovery/via] S[#/allOf/0/properties/ory.sh~1kratos/properties/recovery/properties/via/enum] value must be "email"
Schema:
Copy code
{
  "$schema": "<http://json-schema.org/draft-07/schema#>",
  "title": "Person",
  "type": "object",
  "properties": {
    "traits": {
      "type": "object",
      "properties": {
        "first_name": {
          "type": "string",
          "title": "First Name",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[a-zA-Z]+$"
        },
        "last_name": {
          "type": "string",
          "title": "Last Name",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[a-zA-Z]+$"
        },
        "email": {
          "type": [
            "string",
            "null"
          ],
          "format": "email",
          "title": "Email Address",
          "ory.sh/kratos": {
            "credentials": {
              "password": {
                "identifier": true
              },
              "webauthn": {
                "identifier": true
              },
              "totp": {
                "account_name": true
              },
              "code": {
                "identifier": true,
                "via": "email"
              },
              "passkey": {
                "display_name": true
              }
            },
            "recovery": {
              "via": "email"
            },
            "verification": {
              "via": "email"
            }
          },
          "maxLength": 320
        },
        "phone_number": {
          "type": [
            "string",
            "null"
          ],
          "format": "tel",
          "title": "Phone Number",
          "ory.sh/kratos": {
            "credentials": {
              "password": {
                "identifier": true
              },
              "webauthn": {
                "identifier": true
              },
              "totp": {
                "account_name": true
              },
              "code": {
                "identifier": true,
                "via": "sms"
              },
              "passkey": {
                "display_name": true
              }
            },
            "recovery": {
              "via": "sms"
            },
            "verification": {
              "via": "sms"
            }
          }
        },
        "avatar": {
          "type": [
            "string",
            "null"
          ],
          "title": "Avatar URL",
          "maxLength": 2048,
          "readOnly": true
        },
        "type": {
          "type": "string",
          "title": "Type",
          "default": "professional",
          "enum": [
            "client",
            "professional"
          ]
        }
      },
      "required": [
        "first_name",
        "last_name",
        "type"
      ],
      "anyOf": [
        {
          "required": [
            "email"
          ]
        },
        {
          "required": [
            "phone_number"
          ]
        }
      ],
      "additionalProperties": false
    }
  }
}
Config will be attached in next message due to limits.
Config:
Copy code
log:
    level: warning
    format: json

serve:
    public:
        base_url: <http://localhost:4433>
        cors:
            enabled: true
            allowed_origins:
                - <http://localhost:9109> # Auth App
                - <http://localhost:9192> # Main App
    admin:
        base_url: <http://localhost:4434>

cookies:
    domain: ""
    path: /
    same_site: Lax

session:
    cookie:
        same_site: Lax # Important for OAuth flows
        path: /
        domain: "" # Leave empty for localhost
        persistent: true # Keep the session across browser restarts

selfservice:
    default_browser_return_url: <http://localhost:9192/>
    allowed_return_urls:
        - <http://localhost:9109> # Auth App
        - <http://localhost:9192> # Main App

    methods:
        password:
            enabled: true
        totp:
            enabled: true
            config:
                issuer: App
        lookup_secret:
            enabled: true
        oidc:
            enabled: true
            config:
                providers:
                    - id: google
                      provider: google
                      client_id: CLIENT_ID
                      client_secret: CLIENT_SECRET
                      mapper_url: file:///etc/config/kratos/google.jsonnet
                      scope:
                          - email
                          - profile
                          - openid
                    - id: facebook
                      provider: facebook
                      client_id: CLIENT_ID
                      client_secret: CLIENT_SECRET
                      mapper_url: file:///etc/config/kratos/facebook.jsonnet
                      scope:
                          - email
                          - profile
                          - openid
                    - id: microsoft
                      provider: microsoft
                      microsoft_tenant: consumers
                      client_id: CLIENT_ID
                      client_secret: CLIENT_SECRET
                      mapper_url: file:///etc/config/kratos/microsoft.jsonnet
                      scope:
                          - email
                          - profile
                          - openid
        webauthn:
            enabled: true
            config:
                passwordless: false
                rp:
                    display_name: App
                    id: localhost
                    # icon: <https://www.ory.sh/an-icon.png>
        passkey:
            enabled: false
            config:
                rp:
                    display_name: App
                    id: localhost
                    origins:
                        - <http://localhost:9109>

    flows:
        error:
            ui_url: <http://localhost:9109/error>

        settings:
            ui_url: <http://localhost:9192/account>
            privileged_session_max_age: 15m
            required_aal: highest_available
            after:
                default_browser_return_url: "<http://localhost:9192/account>"
                hooks:
                    - hook: web_hook
                      config:
                          #   response:
                          #       ignore: true
                          url: <http://host.docker.internal:9999/v1/integrations/core/identity>
                          method: POST
                          auth:
                              type: api_key
                              config:
                                  name: Ory-Integrations-API-Key
                                  value: SECURE_HEADER_VALUE
                                  in: header
                          body: file:///etc/config/kratos/webhooks/settings.jsonnet

        recovery:
            enabled: true
            ui_url: <http://localhost:9109/recovery>

        verification:
            enabled: true
            ui_url: <http://localhost:9109/verification>
            after:
                hooks:
                    - hook: web_hook
                      config:
                          #   response:
                          #       ignore: true
                          url: <http://host.docker.internal:9999/v1/integrations/core/identity>
                          method: POST
                          auth:
                              type: api_key
                              config:
                                  name: Ory-Integrations-API-Key
                                  value: SECURE_HEADER_VALUE
                                  in: header
                          body: file:///etc/config/kratos/webhooks/verification.jsonnet

        login:
            ui_url: <http://localhost:9109/login>
            lifespan: 10m
            after:
                default_browser_return_url: "<http://localhost:9192>"
                hooks:
                    - hook: require_verified_address

        registration:
            lifespan: 10m
            ui_url: <http://localhost:9109/registration>
            after:
                default_browser_return_url: "<http://localhost:9192>"
                password:
                    hooks:
                        - hook: session
                        - hook: web_hook
                          config:
                              #   response:
                              #       ignore: true
                              url: <http://host.docker.internal:9999/v1/integrations/core/identity>
                              method: POST
                              auth:
                                  type: api_key
                                  config:
                                      name: Ory-Integrations-API-Key
                                      value: SECURE_HEADER_VALUE
                                      in: header
                              body: file:///etc/config/kratos/webhooks/registration.jsonnet
                hooks:
                    - hook: web_hook
                      config:
                          #   response:
                          #       ignore: true
                          url: <http://host.docker.internal:9999/v1/integrations/core/identity>
                          method: POST
                          auth:
                              type: api_key
                              config:
                                  name: Ory-Integrations-API-Key
                                  value: SECURE_HEADER_VALUE
                                  in: header
                          body: file:///etc/config/kratos/webhooks/registration.jsonnet

secrets:
    cookie:
        - CHANGE_ME_TO_REAL_SECRET
    cipher:
        - 32-LONG-SECRET-NOT-SECURE-AT-ALL

identity:
    default_schema_id: default
    schemas:
        - id: default
          url: file:///etc/config/kratos/identity.schema.json

courier:
    smtp:
        connection_uri: <smtps://test:test@mailslurper:1025/?skip_ssl_verify=true>
    sms:
        enabled: true
        request_config:
            url: <http://host.docker.internal:9999/v1/integrations/core/identity>
            method: POST
            headers:
                Content-Type: application/json
                Ory-Integrations-API-Key: SECURE_HEADER_VALUE
            body: file:///etc/config/kratos/webhooks/sms-courier.jsonnet
            auth:
                type: api_key
                config:
                    name: Ory-Integrations-API-Key
                    value: SECURE_HEADER_VALUE
                    in: header
    channels:
    - id: sms
      type: http
      request_config:
        url: <http://host.docker.internal:9999/v1/integrations/core/identity>
        method: POST
        headers:
            Content-Type: application/json
            Ory-Integrations-API-Key: SECURE_HEADER_VALUE
        body: file:///etc/config/kratos/webhooks/sms-courier.jsonnet
        auth:
            type: api_key
            config:
                name: Ory-Integrations-API-Key
                value: SECURE_HEADER_VALUE
                in: header
oauth2_provider:
    override_return_to: false
    url: <http://hydra:4445/>
c
I think you're missing self-service/methods/code in your config file
no idea if that's actually the problem, but you do reference code credentials when definine your phone number trait
s
I reference those code details in identity just so I not forget how to define it once I need it because documentation of OSS version is not that good, but it is not related to the via: sms issue I am having
Here I found out that via: sms for recovery flow is not supported in OSS version: https://ory-community.slack.com/archives/C0522079BS5/p1755704858941009