OIDC Authentication Policy
General Information
Policy Type
policy-oidc
Endpoints
List Policies
GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/
Add Policy
POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Update Policy
PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Delete Policy
DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
List Policies
Endpoint
GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
Response
Success Response (200 OK)
{
"status": "SUCCESS",
"resultList": [
{
"apiProxy": {
"name": "MyAPI",
"requestPolicyList": [
{
"type": "policy-oidc",
"name": "oidc-auth-policy",
"description": "OIDC authentication with Google",
"active": true,
"issuer": "https://accounts.google.com",
"authorizationEndpoint": "https://accounts.google.com/o/oauth2/v2/auth",
"tokenEndpoint": "https://oauth2.googleapis.com/token",
"flowType": "AUTHORIZATION_CODE",
"clientId": "your-client-id",
"scopes": ["openid", "profile", "email"]
}
],
"responsePolicyList": [],
"errorPolicyList": []
}
}
],
"resultCount": 1
}
Note: In list operations, clientSecret is cleared for security.
cURL Example
curl -X GET \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/" \
-H "Authorization: Bearer YOUR_TOKEN"
Add Policy
Endpoint
POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
| Content-Type | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
| policyName | string | Yes | Policy name |
Request Body
Full JSON Body Example - Authorization Code Flow with PKCE
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-oidc",
"description": "OIDC authentication with Google",
"active": true,
"issuer": "https://accounts.google.com",
"authorizationEndpoint": "https://accounts.google.com/o/oauth2/v2/auth",
"tokenEndpoint": "https://oauth2.googleapis.com/token",
"userInfoEndpoint": "https://openidconnect.googleapis.com/v1/userinfo",
"jwksEndpoint": "https://www.googleapis.com/oauth2/v3/certs",
"clientId": "your-client-id.apps.googleusercontent.com",
"clientSecret": "your-client-secret",
"redirectUri": "https://api.example.com/oidc/callback",
"flowType": "AUTHORIZATION_CODE",
"enablePKCE": true,
"scopes": ["openid", "profile", "email"],
"additionalAuthParams": {},
"authenticationMode": "EXTERNAL_ONLY",
"requireBothInHybrid": false,
"validateIdToken": true,
"validateAccessToken": false,
"validateJwtLocally": true,
"validateJwtSignature": true,
"expectedJwtAuthSigningAlgs": ["RS256", "RS384", "RS512"],
"callUserInfoEndpoint": true,
"tokenCacheTimeoutSeconds": 3600,
"jwkCacheTimeoutSeconds": 3600,
"usernameClaimPath": "sub",
"emailClaimPath": "email",
"displayNameClaimPath": "name",
"roleMappings": [],
"sessionCookieName": "OIDC_SESSION",
"sessionTimeoutMinutes": 60,
"enableStateValidation": true,
"enableNonceValidation": true,
"validateIssuer": true,
"expectedIssuer": "https://accounts.google.com",
"validateAudience": false,
"expectedAudience": [],
"sessionCookieSecure": true,
"allowInsecureConnections": false,
"connectionTimeoutSeconds": 30,
"readTimeoutSeconds": 30,
"maxClockSkewSeconds": 300,
"errorRedirectUrl": null,
"errorMessageTemplate": null,
"includeErrorDetails": false,
"customHeaders": {},
"userAgent": "Apinizer-OIDC-Client/1.0",
"enableDebugLogging": false,
"customClaimMappings": {},
"disableUserinfoHeader": false,
"userinfoHeaderName": "UserInfo"
}
}
Request Body Fields
operationMetadata
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| targetScope | string | Yes | - | Policy scope: ALL or ENDPOINT |
| targetEndpoint | string | No* | - | Endpoint path (required if targetScope=ENDPOINT) |
| targetEndpointHTTPMethod | string | No* | - | HTTP method (required if targetScope=ENDPOINT) |
| targetPipeline | string | Yes | - | Pipeline: REQUEST, RESPONSE, or ERROR |
| deploy | boolean | No | true | Whether to deploy after adding policy |
| deployTargetEnvironmentNameList | array | No | [] | List of environment names to deploy to |
| order | integer | No | null | Policy execution order (starts from 1) |
Enum: targetScope
ALL- Policy applies to all endpointsENDPOINT- Policy applies only to specified endpoint
Enum: targetPipeline
REQUEST- Executes in request pipeline (authenticates request)RESPONSE- Executes in response pipelineERROR- Executes in error pipeline
Enum: targetEndpointHTTPMethod
GET,POST,PUT,DELETE,PATCH,OPTIONS,HEAD
policy
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| type | string | Yes | - | Policy type: policy-oidc |
| description | string | No | - | Policy description |
| active | boolean | No | true | Whether policy is active |
| issuer | string | Yes | - | OIDC Issuer URL (e.g., https://accounts.google.com) |
| authorizationEndpoint | string | Yes | - | Authorization endpoint URL |
| tokenEndpoint | string | Yes | - | Token endpoint URL |
| userInfoEndpoint | string | No | null | UserInfo endpoint URL (optional) |
| jwksEndpoint | string | No* | null | JWKS endpoint URL (required if validateJwtSignature=true) |
| clientId | string | Yes | - | OIDC Client ID |
| clientSecret | string | No | null | OIDC Client Secret (encrypted) |
| redirectUri | string | Yes | - | Redirect URI (callback URL) |
| flowType | string | No | AUTHORIZATION_CODE | OIDC Flow Type |
| enablePKCE | boolean | No | true | Enable PKCE (Proof Key for Code Exchange) |
| scopes | array | Yes | ["openid", "profile", "email"] | OIDC/OAuth 2.0 scopes (must include "openid" for OIDC) |
| additionalAuthParams | object | No | Additional authorization parameters | |
| authenticationMode | string | No | EXTERNAL_ONLY | Authentication mode |
| requireBothInHybrid | boolean | No | false | Require both external and internal authentication in hybrid mode |
| validateIdToken | boolean | No | true | Validate ID Token signature and claims |
| validateAccessToken | boolean | No | false | Validate Access Token |
| validateJwtLocally | boolean | No | true | Validate JWT token locally (exp, iss, aud checks) |
| validateJwtSignature | boolean | No | false | Validate JWT signature using JWKS endpoint |
| expectedJwtAuthSigningAlgs | array | No | ["RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "PS256", "PS384", "PS512", "EdDSA"] | Expected JWT signing algorithms |
| callUserInfoEndpoint | boolean | No | true | Call UserInfo endpoint to get user information |
| tokenCacheTimeoutSeconds | integer | No | 3600 | Token cache timeout in seconds |
| jwkCacheTimeoutSeconds | integer | No | 3600 | JWK cache timeout in seconds |
| usernameClaimPath | string | No | "sub" | Claim path for username |
| emailClaimPath | string | No | "email" | Claim path for email |
| displayNameClaimPath | string | No | "name" | Claim path for display name |
| roleMappings | array | No | [] | Role mappings for authorization |
| sessionCookieName | string | No | "OIDC_SESSION" | Session cookie name |
| sessionTimeoutMinutes | integer | No | 60 | Session timeout in minutes |
| sessionStorageType | string (enum) | No | CACHE (null resolves to CACHE) | Where the authenticated session is stored: CACHE (distributed cache; cookie carries only the session id) or COOKIE (session encrypted with AES-256-GCM and embedded directly in the cookie, stateless). See EnumOIDCSessionStorageType. |
| tempSessionStorageType | string (enum) | No | null (follows sessionStorageType) | Storage for the temporary login session (state / nonce / PKCE verifier / return URL) held only during the authorize→callback round trip. If null, follows sessionStorageType above; can be overridden independently (e.g. keep sessionStorageType=CACHE for authenticated sessions but set tempSessionStorageType=COOKIE for a stateless login round trip). See EnumOIDCSessionStorageType and the Note below. |
| loginFlowTimeoutSeconds | integer | No | 600 | Login flow completion window in seconds — TTL of the temporary login session (state/nonce/PKCE verifier). null or <= 0 resolves to 600 at runtime. Independent of sessionAbsoluteTimeoutSeconds (the authenticated session's lifetime); too low a value causes callback failures (state validation failed (CSRF protection): temporary session not found (expired or already consumed)). |
| enableStateValidation | boolean | No | true | Enable state validation for CSRF protection |
| enableNonceValidation | boolean | No | true | Enable nonce validation for replay attack protection |
| introspectionEndpoint | string | No | null | Introspection endpoint URL (optional) |
| validateIssuer | boolean | No | true | Validate issuer claim in JWT |
| expectedIssuer | string | No | null | Expected issuer value |
| validateAudience | boolean | No | false | Validate audience claim in JWT |
| expectedAudience | array | No | [] | Expected audience values |
| sessionCookieSecure | boolean | No | true | Session cookie secure flag (HTTPS only) |
| allowInsecureConnections | boolean | No | false | Allow insecure HTTPS connections |
| connectionTimeoutSeconds | integer | No | 30 | Connection timeout in seconds |
| readTimeoutSeconds | integer | No | 30 | Read timeout in seconds |
| maxClockSkewSeconds | integer | No | 300 | Maximum clock skew in seconds for token validation |
| errorRedirectUrl | string | No | null | Error redirect URL |
| errorMessageTemplate | string | No | null | Error message template |
| includeErrorDetails | boolean | No | false | Include error details in response |
| customHeaders | object | No | Custom HTTP headers to include in OIDC requests | |
| userAgent | string | No | "Apinizer-OIDC-Client/1.0" | User agent string for OIDC requests |
| enableDebugLogging | boolean | No | false | Enable debug logging |
| customClaimMappings | object | No | Custom claim mappings | |
| disableUserinfoHeader | boolean | No | false | Disable userinfo header in response |
| userinfoHeaderName | string | No | "UserInfo" | Userinfo header name |
EnumOIDCFlowType
AUTHORIZATION_CODE- Authorization Code Flow (recommended, most secure)IMPLICIT- Implicit Flow (less secure, deprecated)HYBRID- Hybrid Flow (combines authorization code and implicit)OAUTH2_AUTHORIZATION_CODE- OAuth 2.0 Authorization Code Flow (without OIDC)
EnumOIDCAuthenticationMode
EXTERNAL_ONLY- External OIDC Provider OnlyINTERNAL_ONLY- Internal Apinizer Credentials OnlyHYBRID- Hybrid - External OIDC + Internal Credentials
EnumOIDCSessionStorageType
Used by both sessionStorageType (authenticated session) and tempSessionStorageType (temporary login session).
CACHE- Store session data in the distributed cache; cookie holds only the session id (default, backward-compatible; allows server-side revocation)COOKIE- Embed AES-256-GCM encrypted session data directly in the cookie (stateless, no cache call); bounded by the ~4 KB browser cookie limit and offers no server-side revocation
JWT Signing Algorithms
RS256,RS384,RS512- RSA with SHA-256/384/512ES256,ES384,ES512- ECDSA with SHA-256/384/512PS256,PS384,PS512- RSASSA-PSS with SHA-256/384/512EdDSA- Edwards-curve Digital Signature Algorithm
Note
issuer,authorizationEndpoint,tokenEndpoint,clientId, andredirectUriare required.scopesmust contain at least "openid" for OIDC flows.- If
validateJwtSignature: true,jwksEndpointis required. - If
validateAudience: true,expectedAudiencemust contain at least one value. sessionStorageTypecovers the authenticated session only. The temporary login session — state/nonce/PKCE verifier — is governed bytempSessionStorageType, which defaults tonulland then followssessionStorageType. So with the default (null), settingsessionStorageType: COOKIEalso moves the login flow off the cache. SettempSessionStorageTypeexplicitly only when you want the two to differ — for exampleCACHEto keep the login flow on the distributed cache while the authenticated session stays in a cookie.loginFlowTimeoutSecondsis independent ofsessionAbsoluteTimeoutSeconds. Shortening the authenticated session's absolute timeout does not shorten the login round-trip window, and vice versa.
roleMappings
Each role mapping is an object with the following fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| claimPath | string | Yes | - | JSONPath or claim name to extract role information (e.g., "roles", "groups", "$.realm_access.roles") |
| claimValue | string | No | null | Expected value in the claim (if null, any non-empty value matches) |
| roleName | string | Yes | - | Apinizer role name to assign when claim matches |
| required | boolean | No | false | Whether this is a required role mapping |
Claim Path Examples
"roles"- Simple claim name"groups"- Groups claim"$.realm_access.roles"- JSONPath for nested claim"$.resource_access.myapp.roles"- JSONPath for resource-specific roles
Response
Success Response (200 OK)
{
"status": "SUCCESS",
"deploymentResult": {
"success": true,
"deploymentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployment successful"
}
]
}
}
cURL Example
curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/oidc-auth-policy/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-oidc",
"description": "OIDC authentication",
"active": true,
"issuer": "https://accounts.google.com",
"authorizationEndpoint": "https://accounts.google.com/o/oauth2/v2/auth",
"tokenEndpoint": "https://oauth2.googleapis.com/token",
"clientId": "your-client-id",
"clientSecret": "your-client-secret",
"redirectUri": "https://api.example.com/oidc/callback",
"flowType": "AUTHORIZATION_CODE",
"enablePKCE": true,
"scopes": ["openid", "profile", "email"]
}
}'
Update Policy
Endpoint
PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/