Introduction
Tyk Identity Broker (TIB) can act as a bridge between external identity providers (such as LDAP, GitHub, or Entra ID) and Tyk Gateway to issue API tokens for client applications (such as Single Page Applications or mobile apps).This is distinct from using TIB to log into the Tyk Dashboard or Developer Portal.
- Standard API Tokens (Auth Tokens)
- OAuth 2.0 Tokens (Tyk as OAuth Provider)
Issuing Standard API Tokens (Auth Tokens)
When your API is secured with standard Auth Token authentication you can use TIB to authenticate the user against an identity provider before directly generating a Tyk Session and associated Key (auth token), attaching a specific policy to it. Prerequisites- An API configured to use Auth Token authentication.
- A Tyk policy to attach to generated tokens; this becomes the
MatchedPolicyID. - A TIB service account - a dedicated Tyk Dashboard user whose API key is used as
DashboardCredential.
GenerateTemporaryAuthToken action and works with both embedded and standalone TIB. It is configured in the TIB profile as follows:
| Parameter | Required | Description |
|---|---|---|
ActionType | Required | Must be GenerateTemporaryAuthToken. |
ID | Required | Unique identifier for this profile. Forms part of the TIB authentication URL; see Profile. |
IdentityHandlerConfig.DashboardCredential | Required | The TIB service account’s Dashboard API key. Although the token grants access to Tyk Gateway, TIB creates it by calling the Tyk Dashboard API (POST /api/keys). |
IdentityHandlerConfig.TokenAuth.BaseAPIID | Required | The ID of the API to which the generated token grants access. |
IdentityHandlerConfig.TokenAuth.Expires | Optional | Token expiry in seconds. Defaults to 3600. |
IdentityHandlerConfig.DisableOneTokenPerAPI | Optional | Set to true to allow multiple active tokens per user. Defaults to false. See Controlling Concurrent Sessions. |
MatchedPolicyID | Required | The ID of the policy to apply to the generated session. |
OrgID | Required | The Tyk Organisation ID. |
ProviderConfig | Required | IdP-specific connection settings. See the Identity Provider guides. |
ProviderName | Required | The authentication method. Can be SocialProvider, ADProvider, SAMLProvider, or ProxyProvider. |
Type | Required | Determined by provider: redirect for Social/SAML, passthrough for LDAP/Proxy. |
Issuing OAuth Tokens
When your API is secured with Tyk’s built-in OAuth 2.0 authorization server you can use TIB as the identity server, authenticating the user against an external IdP and then handling the authorization code exchange with Tyk Dashboard on their behalf.This flow requires Tyk Gateway’s built-in OAuth 2.0 authorization server. It does not apply if you are using an external OAuth authorization server such as Auth0 or Okta.
- An API configured to use Tyk’s OAuth 2.0 authentication method.
- An OAuth client app registered for the target API in Tyk Dashboard.
- A TIB service account - a dedicated Tyk Dashboard user whose API key is used as
DashboardCredential. - TIB must be running as a standalone instance, as this flow requires TIB to communicate directly with Tyk Gateway.
GenerateOAuthTokenForClient action. Requests for tokens go via the base API’s listen path ({listen_path}/tyk/oauth/authorize-client/), so TIB needs to know the listen path and ID of this API to make the correct API calls on your behalf. It is configured in the TIB profile as follows:
| Parameter | Required | Description |
|---|---|---|
ActionType | Required | Must be GenerateOAuthTokenForClient. |
ID | Required | Unique identifier for this profile. Forms part of the TIB authentication URL; see Profile. |
IdentityHandlerConfig.DashboardCredential | Required | The TIB service account’s Dashboard API key, used to invalidate previous tokens on re-authentication. |
IdentityHandlerConfig.DisableOneTokenPerAPI | Optional | Set to true to allow multiple active tokens per user. Defaults to false. See Controlling Concurrent Sessions. |
IdentityHandlerConfig.OAuth.APIListenPath | Required | The listen path of the API; TIB uses this to call the OAuth authorize endpoint ({listen_path}/tyk/oauth/authorize-client/). |
IdentityHandlerConfig.OAuth.BaseAPIID | Required | The ID of the API secured with Tyk’s built-in OAuth 2.0 authorization server. |
IdentityHandlerConfig.OAuth.ClientId | Required | The client ID of the Tyk OAuth client registered for this API. |
IdentityHandlerConfig.OAuth.RedirectURI | Required | The redirect URI registered for the Tyk OAuth client. The token is returned to the client as a URL fragment at this address. |
IdentityHandlerConfig.OAuth.ResponseType | Required | token or authorization_code. Use token for SPAs and mobile apps. |
IdentityHandlerConfig.OAuth.Secret | Required | The client secret of the Tyk OAuth client. |
IdentityHandlerConfig.OAuth.NoRedirect | Optional | Set to true to return the token as JSON in the response body instead of redirecting. Useful for non-browser clients. Defaults to false. |
MatchedPolicyID | Required | The ID of the policy to apply to the generated OAuth token. |
OrgID | Required | The Tyk Organisation ID. |
ProviderConfig | Required | IdP-specific connection settings. See the Identity Provider guides. |
ProviderName | Required | The authentication method. Can be SocialProvider, ADProvider, SAMLProvider, or ProxyProvider. |
Type | Required | Determined by provider: redirect for Social/SAML, passthrough for LDAP/Proxy. |
Handling the Token Response
When TIB successfully authorizes the user and generates the token, it delivers it back to the client application as follows:- For
redirectprovider types (such as Social providers or SAML): TIB redirects the user back to the application’sRedirectURIwith the token or auth code appended as a URL fragment (for example,http://app-domain/callback#access_token=...). The client app decodes and uses it as needed. - For
passthroughprovider types (such as LDAP): TIB returns the token directly in the response or redirect, depending on the configuration.
Controlling Concurrent Sessions
When a user authenticates, TIB checks a Redis cache to see whether a token has already been issued for that user and invalidates it before generating a new one. This means re-authentication automatically revokes the previous token, which is useful if a token is compromised. Set"DisableOneTokenPerAPI": true to skip this check and allow multiple active tokens per user. This is useful when users need concurrent sessions across multiple devices or applications. The trade-off is that old tokens accumulate until they expire via the policy TTL, rather than being revoked on re-authentication.
Worked Examples
GitHub (OAuth Token via Social Provider)
The following video demonstrates this flow end-to-end:-
Register a GitHub OAuth Application
- In GitHub, go to Settings > Developer settings > OAuth Apps and create a new OAuth app.
- Set the Authorization callback URL to:
http://{tib-host}/auth/{profile-id}/github/callback - Note the Client ID and Client Secret.
- Register an OAuth Client in Tyk Dashboard Before TIB can request a token on the user’s behalf, you need an OAuth client registered in Tyk Dashboard for the target API. See Client App Registration for details.
-
IdP-Specific Profile Configuration
Configure the TIB profile for the OAuth token flow setting
ProviderNametoSocialProviderandTypetoredirect. The GitHub-specific settings go inProviderConfig:
OAuth Token via LDAP
This example authenticates the user against LDAP before issuing the OAuth token. It is useful for internal APIs that require valid OAuth tokens but where user identity is managed in an LDAP directory such as Active Directory, rather than a web-based IdP. Because LDAP is a passthrough flow, users submit their credentials via a formPOST directly to TIB; no browser redirect to an external IdP is involved. See Login Page for how to create the login form.
- Register an OAuth Client in Tyk Dashboard As with the GitHub example, you need an OAuth client registered in Tyk Dashboard for the target API. See Client App Registration for details.
-
IdP-Specific Profile Configuration
Configure the TIB profile for the OAuth token flow setting
ProviderNametoADProviderandTypetopassthrough. The LDAP-specific settings go inProviderConfig:
Type: "passthrough" and the LDAP-specific ProviderConfig. Set GetAuthFromBAHeader: true if your login form submits credentials via HTTP Basic Auth. Set LDAPUserDN to match your LDAP directory structure, keeping *USERNAME* as a literal placeholder; TIB replaces it with the submitted username at runtime.
See the LDAP field reference for all available ProviderConfig options.