Is there an example of how I can use the data mapp...
# ory-network
b
Is there an example of how I can use the data mapping to copy across the
name.first
and
name.last
traits from an OIDC connection on another Ory instance?
Copy code
local claims = {
  email_verified: false,
} + std.extVar('claims');

{
  identity: {
    traits: {
      // Allowing unverified email addresses enables account
      // enumeration attacks,  if the value is used for
      // verification or as a password login identifier.
      //
      // Therefore we only return the email if it (a) exists and (b) is marked verified.
      [if 'email' in claims && claims.email_verified then 'email' else null]: claims.email,
      [if 'name' in claims then 'name' else null]: claims.name,
    },
  },
}
m
You have existing identities with name first and last on an Ory instance and you want to migrate them to another one?
b
My OAuth2 Client settings had to have the following scopes
openid
,
email
and
profile
, found in this docs page https://www.ory.com/docs/oauth2-oidc/openid-connect-claims-scope-custom Then my OpenID Connect provider was set to Ory OAuth2, (when the docs say it should be Generic https://www.ory.com/blog/run-sso-oauth2-enterprise-server-open-source) with the same scopes and the following data mapping.
Copy code
local claims = {
  email_verified: false,
} + std.extVar('claims');

{
  identity: {
    traits: {
      // Allowing unverified email addresses enables account
      // enumeration attacks,  if the value is used for
      // verification or as a password login identifier.
      //
      // Therefore we only return the email if it (a) exists and (b) is marked verified.
      [if 'email' in claims && claims.email_verified then 'email' else null]: claims.email,
      [if 'given_name' in claims || 'family_name' in claims then 'name' else null]: {
        [if 'given_name' in claims then 'first' else null]: claims.given_name,
        [if 'family_name' in claims then 'last' else null]: claims.family_name,
      },
    },
  },
}
My Laravel project then used the following to set the traits so they would be the same as my standard Ory Kratos user.
Copy code
$identity = $session->getIdentity();
$traits = $identity ? $identity->getTraits() : null;

$user = [
  'email' => $traits->email ?? null,
  'name' => [
    'first' => $traits->name?->first ?? null,
    'last' => $traits->name?->last ?? null
  ],
];
It feels like there is ALOT missing from the docs, and usable examples.
My use case is, app.com has an Ory instance, manages users normally. Then there is parent-company.com which has its own site, services and login, but I want to be able to "Sign in with Parent Company" and login to app.com
I'm not sure how I can easily test this with all domains running on localhost on different ports, and the ory_session id being shared on that domain. But that'll be a me problem to solve
m
there is parent-company.com which has its own site, services and login, but I want to be able to "Sign in with Parent Company" and login to app.com
and the OIDC provider from parent-company is also running on Ory? we have a blogpost for that use case here: https://www.ory.com/blog/run-sso-oauth2-enterprise-server-open-source
Ah sorry you already posted that 😅
we have since added an "Ory OAuth2" provider so you can also use that - but I think it shouldn't make a difference really
We should probably update the blogpost or better add this as a dedicated doc to the official docs. I think your jsonnet mapping looks good though.
b
The instructions in that blog post are very unclear, also add examples of the data mapping
My only issue with Ory over something like WorkOS at the moment is the lack of examples for even basic use cases. Ory is very much made by developers for developers that already have very good knowledge of these concepts
Using the CLI is it possible to pull a config for the whole instance, and then push the config to an instance?
m
yes - what is it you are trying to do?
b
I have not tried it yet