@mayurajs/auth-okta
v1.2.0
Published
Okta access tokens as Mayura server identities, verified with your authorization server's published keys.
Readme
@mayurajs/auth-okta
Okta access tokens from a custom authorization server as Mayura server identities: verified with its published keys, on any runtime, with no dependency.
npm install mayura @mayurajs/auth-oktaimport { mapCapabilities, principalId } from 'mayura/auth';
import { oktaAuthenticator } from '@mayurajs/auth-okta';
const authenticate = oktaAuthenticator({
domain: 'acme.okta.com',
authorizationServer: 'default', // the default; or your custom authorization server's id
audience: 'api://default',
identity: session => ({
principalId: principalId('okta', session.userId ?? session.subject),
projectId: 'acme',
agentIds: ['support'],
capabilities: mapCapabilities(session.scopes, { 'agents.use': ['runs:submit', 'runs:read'] }),
}),
});
// createAgentServer({ ..., authenticate })- Which tokens. RS256 access tokens issued by the custom authorization server
(
https://<domain>/oauth2/<authorizationServer>) for its audience, checked against<issuer>/v1/keys. Tokens from the org authorization server (https://<domain>) are meant for Okta's own APIs, and are never accepted. - Refused. Machine tokens (client credentials: no
uid, the client as subject) unlessallowMachines, tokens from clients not inclientIdswhen it is given, and sender-constrained (DPoP) tokens, whose proof of possession this does not check. - What you get.
identityreceives the session:subject(the user's login, or a machine's client id),userId(uid, the stable key),clientId,machine,scopes,groups(when your authorization server adds agroupsclaim), and the rawclaims. Nothing is granted unlessidentitygrants it. - Options:
domain,authorizationServer(default),audience,identity,clientIds,allowMachines,clockSkewMs(5 s),maxIdentityMs(60 s),fetch.
See Authentication and API keys. Apache-2.0.
