Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traits from the Update Registration API Flow payload with OIDC get lost #345

Open
6 tasks done
openscript opened this issue Aug 7, 2023 · 7 comments
Open
6 tasks done
Labels
bug Something is not working.

Comments

@openscript
Copy link

openscript commented Aug 7, 2023

Preflight checklist

Describe the bug

When a user registers via the self-service registration flow with OIDC and traits are provided, the user will be created, but the traits are missing.

image

Reproducing the bug

Steps to reproduce the behavior:

  1. Have a identity schema which has additional traits. (example below)
  2. Initialize registration flow:
    curl --request GET \
      --url 'https://example.com/.ory/kratos/public/self-service/registration/api?return_session_token_exchange_code=true&return_to=example%3A%2F%2Fregistration
    
  3. Submit registration flow:
    curl --request POST \
      --url 'https://example.com/.ory/kratos/public/self-service/login?flow=dac5c20f-20ba-4357-8163-edb2e60a5216' \
      --header 'content-type: application/json' \
      --data '{
      "method": "oidc",
      "provider": "google",
      "traits": {
        "lang": "de-CH",
        "tac": "1234",
        "dp": "4321"
      }
    }'
    
  4. Kratos redirects you to the OIDC provider. Open the provided link inside a browser.
  5. Authenticate successfully with an account
  6. Check via admin api if the new identity contains the traits

Relevant log output

No response

Relevant configuration

My identity schema looks like this:


{
  "$id": "https://example.com/identity.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Customer",
  "type": "object",
  "properties": {
    "traits": {
      "type": "object",
      "properties": {
        "lang": {
          "type": "string",
          "title": "Language"
        },
        "tac": {
          "type": "string",
          "title": "Terms and Conditions"
        },
        "dp": {
          "type": "string",
          "title": "Data Protection"
        },
        "email": {
          "type": "string",
          "format": "email",
          "title": "Email",
          "minLength": 3,
          "ory.sh/kratos": {
            "credentials": {
              "password": {
                "identifier": true
              }
            },
            "verification": {
              "via": "email"
            },
            "recovery": {
              "via": "email"
            }
          }
        }
      },
      "required": [
        "email"
      ],
      "additionalProperties": false
    }
  }
}

Version

1.0.0

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Docker Compose

Additional Context

This topic was discussed here too: ory/kratos#3413

It worked with 0.12 for many months, but it doesn't with version 1.0.0. We directly migrated from 0.12 to 1.0.0.

@openscript openscript added the bug Something is not working. label Aug 7, 2023
@aeneasr
Copy link
Member

aeneasr commented Aug 7, 2023

This should work as you have documented (which is also why it worked in 0.12). Looks like this is a regression - but it could have many reasons. Is there some way for you to pin-point why it isn't working or provide a reproducable case with e.g. your website? Thanks!

@openscript
Copy link
Author

openscript commented Aug 7, 2023

Thank you @aeneasr for your quick reaction.

I've reproduced the issue on Orys Network: https://silly-easley-16pa1lzvl4.projects.oryapis.com (UI)

If you need to look into the private instance details or modify the instance, go for it. I've created it just for this issue. The reproduction steps with this instance are:

  1. Initialize registration API flow:
    curl --request GET \
      --url 'https://silly-easley-16pa1lzvl4.projects.oryapis.com/self-service/registration/api?return_session_token_exchange_code=true&return_to=http%3A%2F%2Fopenscript.ch%2Fregistration'
    
  2. Update registration API flow:
    curl --request POST \
      --url 'https://silly-easley-16pa1lzvl4.projects.oryapis.com/self-service/registration?flow=08d22e2b-900b-476d-9931-a7f6877999dc' \
      --header 'content-type: application/json' \
      --data '{
      "method": "oidc",
      "provider": "google",
      "traits": {
        "lang": "de",
        "tac": "1234",
        "dp": "4321"
      }
    }'
    
  3. Follow the "redirect_browser_to" and authenticate.
  4. Get https://silly-easley-16pa1lzvl4.projects.oryapis.com/admin/identities to see if the traits are available

image

@openscript
Copy link
Author

Is something wrong with the data mapping I configured for the social login via Google?

local claims = {
  email_verified: true,
} + std.extVar('claims');

{
  identity: {
    traits: {
      [if 'email' in claims && claims.email_verified then 'email' else null]: claims.email
    },
  },
}

@aeneasr
Copy link
Member

aeneasr commented Aug 7, 2023

Thank you, that is very helpful!

@alnr
Copy link

alnr commented Aug 8, 2023

I've investigated this issue and can reproduce it. The issue is that the continuity container (which holds the "traits": { "lang": "de", "tac": "1234", "dp": "4321" } data) cannot be retrieved from the database without the ory_kratos_continuity cookie, which of course doesn't make sense in an API flow. See https://github.com/ory/kratos/blob/a0f2420ae74af2393d855aaab1b3bbfbe5f5e732/selfservice/strategy/oidc/strategy.go#L303-L318C3

We need a second implementation of continuity.Manager. Right now, there's only continuity.ManagerCookie, which looks inside a browser cookie to find the continuity container.

cc @hperl

@openscript
Copy link
Author

For us this is a show stopper. How can I support you to proceed with this bug?

@vinckr vinckr transferred this issue from ory/kratos Sep 29, 2023
@aeneasr
Copy link
Member

aeneasr commented Oct 2, 2023

A solution to this is not trivial, but possible. I think that we need to attach the continuity container which contains the previously submitted form payload to the state parameter for native flows. This should be fine since we validate the incoming state parameter with an expected state parameter from the API call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

3 participants