Get started with Workforce Identity
Connect your first app to your realm, so your users sign in to it with a passkey and the app learns who they are.
AvailableDashboard and APIRFC 6749, RFC 7636, OpenID Connect Core 1.0, WebAuthn Level 2
In this guide you connect an app at https://app.example.com to your realm, and your user maya signs in to it with
a passkey: a fingerprint, a face or a PIN on her own device, with nothing to type and no password to steal. The app
never sees a credential. It gets an ID token that says who signed in, and an access token for its API.
A new realm is ready for this from the start. It offers passkeys, and its default sign-in takes a passkey alone, or a password followed by a code from an authenticator app. What you add is the app.
Before you begin
Section titled “Before you begin”- A realm administrator’s session in
$CVYUH_SESSION: you’re in a group that holdsRealmOwner. Call the API shows how to get one. Every step below is an API call. - A user to sign in as. Here it’s
maya, with a password. To add her, see Add users and groups. - An app that speaks OpenID Connect, with a route at
https://app.example.com/callbackfor the browser to return to. Any OpenID Connect library does the app’s half of the steps below for you; they’re shown here as plain calls so you can see what happens.
Connect the app
Section titled “Connect the app”-
Check that passkeys are on. Read the realm’s passkey settings:
Terminal window curl https://foobar.cvyuh.com/api/v0/am/objects/v1/webauthnSettings/webauthnSettings \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"rpIdis the domain passkeys are bound to. A realm created with a host name has that host, herefoobar.cvyuh.com, and passkeys work at once. If it’s empty, set it before anyone adds a passkey, as in Sign-in methods: changing it later orphans every passkey the realm holds. -
Register the app. The id you choose,
example-app, is its client ID:Terminal window curl -X POST "https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client?id=example-app" \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "status": "active","clientName": "Example App","tokenEndpointAuthMethod": "client_secret_basic","clientSecret": "<a long random secret>","grantTypes": ["authorization_code", "refresh_token"],"redirectUris": ["https://app.example.com/callback"],"postLogoutRedirectUris": ["https://app.example.com/"],"scopes": ["openid", "profile", "email", "offline_access"],"defaultScopes": ["openid"],"allowedResources": ["https://app.example.com/api"],"defaultAudience": "https://app.example.com/api" }'The realm answers
201. The secret is stored hashed and never shown again, so keep a copy for the app. Give the app its client ID, its secret and the issuer,https://foobar.cvyuh.com/oauth2; a library reads every other address from the Discovery document. -
Maya adds a passkey. She signs in to the dashboard once with her password, and sets up an authenticator app when the realm asks for one. Right after, the dashboard offers to add a passkey, and her device asks for her fingerprint, face or PIN. She can add one later from Add a passkey in her user menu.
-
The app sends Maya to sign in. When she clicks Sign in, the app sends her browser to the realm, with a fresh
stateand a PKCE challenge, theS256hash of a random verifier it keeps:https://foobar.cvyuh.com/oauth2/authorize?response_type=code&client_id=example-app&redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback&scope=openid%20profile%20email&state=<random>&code_challenge=<S256 of the verifier>&code_challenge_method=S256Maya enters her username, and her device asks for her passkey. Nothing else is asked: a passkey alone is enough. The first time, a consent page names Example App and what it asks for, and she clicks Allow. Her browser returns to
https://app.example.com/callbackwith a one-timecode, thestatethe app sent, and the realm’siss. -
The app exchanges the code for tokens, proving itself with its secret and the PKCE verifier:
Terminal window curl https://foobar.cvyuh.com/oauth2/token \-u "example-app:<secret>" \-d grant_type=authorization_code \-d code=<code> \-d redirect_uri=https://app.example.com/callback \-d code_verifier=<verifier>{"access_token": "eyJ…","token_type": "Bearer","expires_in": 300,"id_token": "eyJ…","scope": "openid profile email"}The ID token names Maya as
sub, is addressed toexample-app, and is signed by the realm. The access token is forhttps://app.example.com/api, and lives five minutes by default.
Check it worked
Section titled “Check it worked”Ask the realm who the access token is about:
curl https://foobar.cvyuh.com/oauth2/userinfo \ -H "Authorization: Bearer <access token>"{ "sub": "9d4e2a71-0c3b-4f5e-8a6d-1b7c9e2f0a34", "preferred_username": "maya", "email": "maya@example.com" }Then sign out of the dashboard and sign in to the app again: Maya’s device asks for her passkey, and she’s back in the app without typing a password.