Let Your Business Customers Sign In With Okta¶
Sell software to companies, and the second question after the price is "does it work with our Okta?". Their IT department doesn't want another set of passwords: people join and leave every week, and access has to follow the company directory, not a list your app keeps.
This post shows how a backend on ObjectsGrid lets a company's people sign in with that company's Okta, without the backend becoming an identity provider.
Who does what¶
OpenID Connect splits the job in two:
- The identity provider, here the customer's Okta org, checks who the person is and issues a signed ID token.
- The relying party trusts that token for the apps it was issued to.
ObjectsGrid is only ever the relying party. It never sees a password, and it doesn't hold anyone's identity: it checks the ID token your customer's Okta org issued, with the keys that org publishes, and gives your app its own short-lived access token.
sequenceDiagram
participant User
participant App as Your app
participant Okta as Customer's Okta org
participant OG as ObjectsGrid
User->>App: Sign in
App->>Okta: Authorization code flow with PKCE
Okta-->>App: ID token
App->>OG: POST /oauth2/token with the ID token
OG-->>App: Access token and refresh token
1. Register the Okta org¶
In Okta, the customer's admin creates an OIDC app integration for your app and gives you two values: the issuer,
such as https://acme.okta.com/oauth2/default, and the app's client ID. Your Organization Account lists them in
identityProviders, next to Google and Apple if you use those too:
"identityProviders": [
{"issuer": "https://accounts.google.com", "clientIds": ["<your Google client id>"]},
{"issuer": "https://acme.okta.com/oauth2/default", "clientIds": ["0oa1b2c3d4EXAMPLE"]}
]
ObjectsGrid checks the issuer when you save it: its discovery document must be readable, name the same issuer, and
publish its keys on https with RS256. A typo shows up then, not at the first sign-in. An account can trust up to
3 issuers of its own.
2. Exchange the ID token¶
Your app signs the person in with Okta's SDK, asking for the openid and email scopes, and exchanges the ID token:
const response = await fetch("https://apis.objectsgrid.com/oauth2/token", {
method: "POST",
headers: {"Content-Type": "application/json", "X-ObjectsGrid-AccessPoint": "EU"},
body: JSON.stringify({
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
subject_token: idToken,
subject_token_type: "urn:ietf:params:oauth:token-type:id_token",
client_id: "<organization account id>",
}),
});
const { access_token, refresh_token } = await response.json();
The first time, ObjectsGrid creates the person's User Account. It finds them again by issuer and subject, never by email, so someone who changes their email at Okta keeps their account, and nobody can claim an account by registering a matching email elsewhere.
3. Give people their access¶
A new User Account has no access until your ABAC policy gives it some. Tag
accounts with what your policy decides on, such as company = acme and a role, and write rules on those tags.
That's what keeps Acme's people in Acme's data: a rule that allows only objects tagged with the caller's own company.
See fine-grained access control for patterns.
4. Decide how long a sign-in lasts¶
When someone leaves Acme, Okta stops signing them in, but your app's refresh token for them was issued earlier and
doesn't know. Bound it with the Organization Account's refreshTokenLifetimeHours: with 12, a person signed in at
09:00 can refresh until 21:00, then signs in with Okta again. Okta's SDK does that without a prompt while their Okta
session lasts, and refuses once they've been removed. To cut someone off at once, an administrator disables their
User Account, and their access stops within the hour, when the access token expires.
Before you go live¶
- Keep the issuer stable. Accounts are found by issuer and subject, so moving the Okta org to a custom domain gives everyone new, empty accounts. Decide the issuer first.
- Okta's thin ID tokens. An ID token issued with an access token leaves out
email_verified. For an issuer you registered, ObjectsGrid accepts that, since you chose to trust that directory; a token that saysfalseis still refused. - The owner signs in elsewhere. Creating an Organization Account and binding its administrator take a Google or Apple sign-in. Okta is for the people who use your app.
The Sign in with Okta guide has every step, with the Okta screens.