GebSecure Docs v0.1.0

Guides · Security

Identity — agents, users, SSO, MFA and SCIM

Machine credentials and tokens, user sessions, single sign-on, multi-factor authentication, SCIM provisioning and organization access policies.

Agent and machine authentication#

Agents, service accounts and applications authenticate with their own credentials and exchange them for short-lived access tokens at POST {api}/v1/auth/token (ADR 0004).

grant_type Parameters Use
client_credentials client_secret (gsa_…), optional client_id, scope (space-separated), refresh client-secret credentials
client_credentials client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer, client_assertion private_key_jwt (RFC 7523)
refresh_token refresh_token rotating refresh tokens (issued when refresh: true)
urn:ietf:params:oauth:grant-type:token-exchange subject_token (gsd_…), actor_token, scope delegation (RFC 8693)

The response is {access_token, token_type: "Bearer", expires_in, scope, refresh_token?}. Access tokens are EdDSA-signed JWTs (typ: gs-access+jwt, audience gebsecure) valid for ACCESS_TOKEN_TTL (10 minutes by default); verify them with GET /.well-known/jwks.json. API keys (gsk_…) are sent directly as bearer tokens; their effective scopes are the key's scopes intersected with its service account's.

Credentials are issued with POST /v1/agents/{id}/credentials (also for service accounts and applications): type client_secret (default, returns a gsa_… secret once) or public_key with a publicJwk (Ed25519, P-256 or RSA ≥ 2048 — only the public key is stored), plus name, scopes and expiresInDays (1–730). POST /v1/credentials/{id}/rotate issues a replacement and keeps the old credential valid for gracePeriodMinutes (default 60, at most 10080); POST /v1/credentials/{id}/revoke revokes immediately.

private_key_jwt#

The assertion's iss and sub are the credential id, aud is {PUBLIC_API_URL}/v1/auth/token, it lives at most five minutes and its jti is single use. The SDKs sign it for you:

sdks/typescript/examples/private-key-jwt.ts
/**
 * Agent authentication with private_key_jwt: GebSecure stores only the public key.
 *   GEBSECURE_CREDENTIAL_ID=cred_… GEBSECURE_PRIVATE_KEY_FILE=agent.pem npx tsx sdks/typescript/examples/private-key-jwt.ts
 *
 * Create a key:   openssl genpkey -algorithm ed25519 -out agent.pem
 * Public JWK:     node -e "console.log(JSON.stringify(require('crypto').createPublicKey(require('fs').readFileSync('agent.pem')).export({format:'jwk'})))"
 * Register it:    POST /v1/agents/{id}/credentials {"type":"public_key","publicJwk":{…}}
 */
import { readFileSync } from 'node:fs';
import { GebSecure, privateKeyJwt } from '@gebsecure01/sdk';

const gs = new GebSecure({
  auth: privateKeyJwt({
    credentialId: process.env.GEBSECURE_CREDENTIAL_ID!,
    privateKey: readFileSync(process.env.GEBSECURE_PRIVATE_KEY_FILE ?? 'agent.pem', 'utf8'), // Ed25519, P-256 or RSA (PKCS#8)
    scope: 'authorize execute',
  }),
});

// Tokens are fetched lazily, cached, and refreshed before expiry; concurrent calls share one request.
const decision = await gs.authorize({ action: 'tickets:read', resource: 'zendesk:ticket/42', dryRun: true });
console.log(decision.decision, decision.reason);

Delegation between agents#

An agent delegates a subset of its authority (scopes, actions, an expiry) with POST /v1/delegations; the returned gsd_… token is shown once. The delegate exchanges it with its own credentials as the actor, so a leaked delegation token alone is useless. Delegated tokens live at most ten minutes, and policies see the chain in delegation.* and principal.delegated:

sdks/typescript/examples/delegation-exchange.ts
import { GebSecure, clientSecret, delegation } from '@gebsecure01/sdk';

// 1. Orchestrator (delegator) creates the delegation. The gsd_ token is shown once.
const orchestrator = new GebSecure({ apiKey: process.env.ORCHESTRATOR_API_KEY! });
const grant = await orchestrator.createDelegation({
  delegateAgentId: 'agent_research',
  scopes: ['authorize'],
  actions: ['search:*'],
  expiresInSeconds: 900,
  purpose: 'Market research for ticket #42',
});

// 2. The research agent (delegate) authenticates with its OWN credentials and exchanges the delegation
//    token (RFC 8693). The stolen gsd_ token alone is useless without the delegate's credentials.
const research = new GebSecure({
  auth: delegation({
    subjectToken: grant.token,
    actor: clientSecret({ clientSecret: process.env.RESEARCH_CLIENT_SECRET! }),
    scope: 'authorize',
  }),
});
// Equivalent shorthand: new GebSecure({ auth: clientSecret({...}) }).withDelegation(grant.token)

const d = await research.authorize({ action: 'search:web', resource: 'web:query/competitor pricing' });
console.log(d.decision, d.reason, `chain depth via delegation ${grant.id}`);

User sessions#

Endpoint Notes
POST /v1/auth/login {email, password, orgId?, refreshTokenDelivery: "cookie" | "body"} (default cookie). With MFA enabled the response is {mfaRequired: true, challenge, expiresInSeconds: 300}
POST /v1/auth/mfa/challenge {challenge, code, refreshTokenDelivery} completes an MFA login (5 attempts)
POST /v1/auth/refresh rotates the refresh token: from the body ({refreshToken}, answer in the body) or from the gs_refresh cookie (requires the header x-gebsecure-csrf: 1). Reusing a rotated refresh token revokes the whole session family
POST /v1/auth/logout revokes the session and its refresh family
POST /v1/auth/switch-org {orgId} — a new access token for another organization (not for sessions established through an organization's SSO)
GET /v1/auth/me the principal, its organizations and effective permissions

The cookie gs_refresh is HTTP-only, SameSite=Strict, scoped to /v1/auth and Secure outside development and test. The SDKs' login() always asks for body delivery, for CLIs and CI.

Multi-factor authentication#

Factors: TOTP (RFC 6238) plus ten single-use recovery codes.

Endpoint Body Result
GET /v1/me/mfa — {enabled, pending, recoveryCodesRemaining}
POST /v1/me/mfa/enroll — {secret, otpauthUri}
POST /v1/me/mfa/confirm {code} {enabled: true, recoveryCodes}; marks the session verified
POST /v1/me/mfa/verify {code} steps up the current session
POST /v1/me/mfa/disable {code}
POST /v1/me/mfa/recovery-codes {code} (a TOTP code) new recovery codes
POST /v1/members/{userId}/mfa/reset {reason} administrator reset (members:manage); revokes the member's sessions

A 6-digit code is checked as TOTP, anything else as a recovery code. Setting the organization's mfaRequired makes every session without a verified second factor pending: requests fail with HTTP 403 and details.reason: "mfa_required", except GET /v1/me/mfa and POST /v1/me/mfa/enroll|confirm|verify, which let the user enroll or verify. With an SSO connection's trustIdpMfa, MFA performed at the identity provider counts.

Sign in with Google or GitHub#

Console users can sign up and sign in with a Google or GitHub account next to email and password. This is platform-wide (one OAuth app per provider for the deployment) and independent of the per-organization single sign-on below.

  • Google uses OpenID Connect with PKCE and a nonce. The ID token is verified against Google's published keys (signature, issuer, audience, expiry, nonce) and the email must be verified by Google.
  • GitHub uses OAuth with PKCE. Only the account's primary, verified email is used.
  • Accounts are matched by the provider's stable user id. A first sign-in with an email that already has a GebSecure account links to that account (audited as social.identity.link); otherwise a new account without a password is created.
  • The same rules as password login apply afterwards: disabled accounts are refused, organizations that enforce SSO cannot be entered this way, and users with MFA must still enter their second factor.
  • The browser only ever receives a one-time code (60 seconds) that the console exchanges for the session.
  • GET /v1/me/identities lists linked accounts; DELETE /v1/me/identities/{google|github} unlinks one, but never the last way to sign in.

To enable a provider, register an OAuth client with the provider using the redirect/callback URL {PUBLIC_API_URL}/v1/auth/oauth/{google|github}/callback, and set GOOGLE_OAUTH_CLIENT_ID / GOOGLE_OAUTH_CLIENT_SECRET or GITHUB_OAUTH_CLIENT_ID / GITHUB_OAUTH_CLIENT_SECRET (in AWS deployments the gebsecure/<env>/oauth-social secret). A provider without both values is not offered.

Single sign-on#

Connections (POST /v1/sso/connections, permission sso:manage) are OIDC or SAML 2.0:

Protocol Fields
both name, defaultRole (any role except owner, default member), jitProvisioning (default true), trustIdpMfa (default false)
oidc issuer (discovery from /.well-known/openid-configuration), clientId, clientSecret, scopes (default openid email profile), groupsClaim (default groups), tokenEndpointAuth (client_secret_basic or client_secret_post)
saml idpEntityId, idpSsoUrl, idpCertificates (1–5), emailAttribute, groupsAttribute (default groups)

For SAML, the service provider entity id and metadata are at {PUBLIC_API_URL}/v1/sso/saml/{id}/metadata and the ACS URL is {PUBLIC_API_URL}/v1/auth/sso/saml/acs/{id}. OIDC uses PKCE (S256) and a nonce.

Domains. An identity provider signs in only users of verified email domains: POST /v1/sso/domains, publish the DNS TXT record _gebsecure-challenge.<domain> = gebsecure-verification=<token>, then POST /v1/sso/domains/{id}/verify.

Login. POST /v1/auth/sso/start ({email | connectionId, redirectUri}) returns the authorizationUrl; OIDC completes with POST /v1/auth/sso/oidc/callback ({state, code}), SAML posts to the ACS URL, which redirects to redirectUri?sso_code=… for POST /v1/auth/sso/exchange.

Provisioning. With jitProvisioning, first sign-in creates a membership with defaultRole; otherwise unknown users are refused. Group mappings (/v1/sso/group-mappings: idpGroup → teamId, orgRole, or projectId + projectRole) turn identity-provider groups into teams and roles; they never grant owner.

Enforcement. The organization setting enforceSso: true (requires an active connection and a verified domain) rejects password sessions with HTTP 403 and details.reason: "sso_required".

SCIM 2.0#

Identity providers provision users and groups at {api}/scim/v2 with a SCIM bearer token (POST /v1/scim/tokens, permission sso:manage; the gss_… token is shown once):

Resource Operations
/ServiceProviderConfig GET
/Users (memberships) list, create, get, replace (PUT), patch (replace/add of active, displayName, externalId), delete
/Groups (teams) list, create, get, patch (members add/remove/replace, displayName), delete

Filters support attr eq "value" (userName, externalId, emails.value, displayName; groups displayName, externalId) with startIndex and count (at most 200). Deprovisioning (active: false) suspends the membership and revokes the user's API keys; owners cannot be deprovisioned. New users get the organization's settings.scim.defaultRole (default member).

Organization access policies#

PATCH /v1/org with settings (permission org:manage):

Setting Effect
mfaRequired sessions need a verified second factor (mfa_required)
enforceSso password sessions are refused (sso_required)
ipAllowlist, ipAllowlistScope up to 100 IPs/CIDRs; applied to users, api_keys, service_accounts by default (also agents, applications); other addresses get ip_not_allowed. Saving fails if your own address is not allowed
sessionMaxAgeHours, sessionIdleTimeoutMinutes session lifetime (1–720 hours) and idle timeout (5–1440 minutes)
allowedEmailDomains restricts who can join
defaultApprovalTtlMinutes, requireApprovalInProduction approval defaults (see Approvals)
auditRetentionDays, traceRetentionDays retention

Data residency. GebSecure Cloud stores customer data in the United States (AWS us-east-1); the service itself is available worldwide. An organization is created in the region of the deployment that creates it (POST /v1/orgs, region defaulting to the deployment's own); a deployment declares its region with REGION. GET /v1/regions (no authentication) returns that region and any other regional deployments (OTHER_REGIONS), which the sign-up page uses: with one region it states where data is stored, with several it lets the customer choose and sends them to the other region's console. When REGION is not local, requests for an organization of another region are refused with details.reason: "wrong_region" and the organization's region.

Roles and permissions#

Organization roles: owner, admin, security_admin, developer, approver, auditor, member, billing_admin. Project roles: project_admin, project_developer, project_approver, project_viewer. Permissions are resource:action strings (policies:deploy, approvals:decide, secrets:write, mcp:manage…, plus authorize and execute). Custom roles (/v1/roles/custom, permission roles:manage) have keys custom:<slug> and may only contain permissions their creator holds. Separation-of-duties rules (/v1/governance/sod-rules) block or warn on granting conflicting permission sets, and access reviews (/v1/governance/access-reviews) certify who keeps access.