Skip to main content

Reach another app with no consent screen

An assistant in one enterprise app gets a token for a second app, through the identity provider that both trust.

RecipeDraftView source
This page is a draft. The code exists, and not all of it has been run for this page yet. The page says what was checked.
Works with
Plain HTTP

What it shows​

  1. A person signs in to "Acme Assistant" in the organization acme-corp, which acts as the identity provider. The assistant holds the ID token of the person.
  2. The assistant exchanges the ID token for an identity assertion (an ID-JAG) for the wiki. A policy in acme-corp allows this pair and caps the scopes.
  3. The organization northwind-wiki trusts acme-corp. The wiki application redeems the assertion for an access token, with the JWT bearer grant.
  4. The wiki finds its own account of the person by the verified email address. The person sees no second sign-in and no consent screen.

Before you start​

  • Two organizations. The examples call them acme-corp (identity provider) and northwind-wiki (resource side).
  • A person with an account in both, with the same email address, verified in both. A redemption does not create an account.
  • Check that your plan includes Cross App Access in the plans matrix, for both organizations.

In northwind-wiki, first create a confidential application for the wiki, for example with the scope wiki:read. Its client ID is the "client ID at the target" below.

In acme-corp, run the setup script. It registers "Acme Assistant". Then open AI Agents, Agent rules, Cross-app access, and work through the steps:

  1. In Step 1 · Roles, turn on Issue identity assertions, and click Save switches.
  2. In Step 3 · Applications, turn on Can obtain assertions in the row of "Acme Assistant".
  3. In Step 4, click Add your first policy. Select "Acme Assistant" as Application. Enter the issuer of northwind-wiki as Target authorization server, the client ID of the wiki application as Client ID at the target, and wiki:read as Allowed scopes. Click Add policy.

In northwind-wiki, open the same page:

  1. In Step 1 · Roles, turn on Accept identity assertions, and click Save switches.
  2. In Step 3 · Applications, turn on Can redeem assertions in the row of the wiki application.
  3. In Step 2, click Register your first provider. Enter the issuer of acme-corp as Issuer URL, for example https://app.lumoauth.dev/orgs/acme-corp/api/v1. Leave Keys (JWKS URL) empty, and click Register provider.
VariableValue
LUMOAUTH_URLThe address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev.
LUMOAUTH_ORG_IDThe organization of the identity provider, where the person signs in, for example acme-corp.
LUMOAUTH_API_KEYFor the setup script only: an API key of the identity provider with the scopes admin:clients:read and admin:clients:write.
ASSISTANT_CLIENT_IDThe client ID of the requesting application "Acme Assistant" at the identity provider. The setup script prints it.
ASSISTANT_CLIENT_SECRETThe client secret of "Acme Assistant". The setup script prints it.
USER_ID_TOKENThe ID token that "Acme Assistant" received when the person signed in to it.
WIKI_ISSUERThe issuer of the organization of the wiki, as its discovery document shows it, for example https://app.lumoauth.dev/orgs/northwind-wiki/api/v1.
WIKI_CLIENT_IDThe client ID of the confidential application in the wiki organization that redeems the assertion. The policy names it as the client ID at the target.
WIKI_CLIENT_SECRETThe client secret of that application.

The setup script creates what the recipe needs, through the Admin API. You can run it again at any time.

node delegation/cross-app-access/setup.mjs
setup.mjs
// Registers the requesting application in the organization of the identity
// provider: an assistant that people sign in to. Run it again at any time.
// The roles, the switch of the application and the policy are set in the
// portal (see "Before you start").
//
// node delegation/cross-app-access/setup.mjs
//
// The API key needs the scopes admin:clients:read and admin:clients:write.
import { call, list, printEnv } from '../../_lib/admin.mjs';

const name = 'Acme Assistant';
const redirectUris = [`http://localhost:${process.env.PORT ?? 3000}/auth/callback`];
let app = (await list('/admin/clients')).find((c) => c.name === name);
let secret;
if (app) {
// LumoAuth shows a secret once. A second run therefore makes a new secret,
// and the old one stops working.
secret = (await call('POST', `/admin/clients/${app.clientId}/rotate-secret`)).data.secret;
await call('PATCH', `/admin/clients/${app.clientId}`, { redirectUris });
} else {
app = (
await call('POST', '/admin/clients', {
name,
isConfidential: true,
redirectUris,
grantTypes: ['authorization_code'],
scopes: ['openid', 'profile', 'email'],
})
).data;
secret = app.secret;
}

console.log(`The application "${name}" is ready.`);
printEnv({ ASSISTANT_CLIENT_ID: app.clientId, ASSISTANT_CLIENT_SECRET: secret });

Sign the person in to "Acme Assistant" with the scope openid, and set USER_ID_TOKEN to the ID token of that sign-in.

Code​

Run each command from the recipes folder of the examples repository. Set the folder up once for your language. The first line was seen, with another audience. The second line follows the documented answer of the wiki and was not seen.

delegation/cross-app-access/http/xaa.sh
#!/bin/sh
# Cross App Access between two organizations. The assistant gets an identity
# assertion (ID-JAG) at the identity provider, and redeems it at the
# authorization server of the wiki for an access token. Needs curl and jq.
#
# sh delegation/cross-app-access/http/xaa.sh
set -eu

IDP="$LUMOAUTH_URL/orgs/$LUMOAUTH_ORG_ID/api/v1" # the organization where the person signs in
WIKI="$WIKI_ISSUER" # the issuer of the wiki, as its discovery document shows it

# 1. At the identity provider: the assistant exchanges the ID token of the
# person for an assertion that names the wiki as audience.
answer=$(curl --silent --show-error "$IDP/oauth/token" \
--user "$ASSISTANT_CLIENT_ID:$ASSISTANT_CLIENT_SECRET" \
--data-urlencode "grant_type=urn:ietf:params:oauth:grant-type:token-exchange" \
--data-urlencode "requested_token_type=urn:ietf:params:oauth:token-type:id-jag" \
--data-urlencode "subject_token=$USER_ID_TOKEN" \
--data-urlencode "subject_token_type=urn:ietf:params:oauth:token-type:id_token" \
--data-urlencode "audience=$WIKI" \
--data-urlencode "scope=wiki:read")
assertion=$(printf '%s' "$answer" | jq -r '.access_token // empty')
if [ -z "$assertion" ]; then
echo "identity provider: $(printf '%s' "$answer" | jq -r '"\(.error): \(.error_description)"')"
exit 1
fi

# The assertion is a JWT. Show the claims that the wiki uses.
payload=$(printf '%s' "$assertion" | cut -d. -f2 | tr '_-' '/+')
while [ $((${#payload} % 4)) -ne 0 ]; do payload="$payload="; done
printf '%s' "$payload" | base64 -d |
jq -r '"assertion: for \(.aud), as client \(.client_id), scope \(.scope), email \(.email) (verified: \(.email_verified))"'

# 2. At the wiki: the wiki application, whose client ID the assertion names,
# redeems it with its own credentials. No screen is shown to the person.
curl --silent --show-error "$WIKI/oauth/token" \
--user "$WIKI_CLIENT_ID:$WIKI_CLIENT_SECRET" \
--data-urlencode "grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer" \
--data-urlencode "assertion=$assertion" |
jq -r 'if .access_token then "wiki: access token, scope \(.scope), expires in \(.expires_in) seconds" else "wiki: \(.error): \(.error_description)" end'
sh delegation/cross-app-access/http/xaa.sh

Compiles. Not run against an organization. Step 1 ran against an organization with the identity provider role, and an audience without a policy was refused. Step 2 did not run: the test organizations run on a local server, and the wiki side fetches the keys of the identity provider over the internet.

Check the result​

Output
assertion: for https://app.lumoauth.dev/orgs/northwind-wiki/api/v1, as client client_9a4e…, scope wiki:read, email riley.park@example.com (verified: true)
wiki: access token, scope wiki:read, expires in 3600 seconds
  • The assertion names the wiki as its audience and the wiki application as client_id, never the client ID of "Acme Assistant" in acme-corp. It is valid for five minutes, and the wiki accepts it once.
  • An audience without an active policy is refused at acme-corp with invalid_target and "The requested audience is not permitted for this client". Pause or delete the policy to see it.
  • The access token of the wiki names the account of the person in northwind-wiki as sub, and the wiki application with acme-corp as issuer in act.
  • Open Audit logs under Security in each organization. acme-corp records xaa.id_jag_issued, and northwind-wiki records xaa.id_jag_redeemed.

Limits​

  • The ID token must come from a sign-in of the requesting application in acme-corp.
  • The wiki gives no refresh token. When the access token expires, the assistant asks acme-corp for a new assertion.
  • The scope of the access token is the scope of the assertion that the wiki application is registered for. An assertion without a scope gives a token without a scope.
  • The wiki matches the person only by a verified email address. An address that is not verified on either side is refused with invalid_grant.
  • The issuers must match character for character, as each discovery document shows them.