Ana içeriğe geç

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​

HeaderValue
AuthorizationBearer {token}

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI 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​

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy 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​
FieldTypeRequiredDefaultDescription
targetScopestringYes-Policy scope: ALL or ENDPOINT
targetEndpointstringNo*-Endpoint path (required if targetScope=ENDPOINT)
targetEndpointHTTPMethodstringNo*-HTTP method (required if targetScope=ENDPOINT)
targetPipelinestringYes-Pipeline: REQUEST, RESPONSE, or ERROR
deploybooleanNotrueWhether to deploy after adding policy
deployTargetEnvironmentNameListarrayNo[]List of environment names to deploy to
orderintegerNonullPolicy execution order (starts from 1)

Enum: targetScope

  • ALL - Policy applies to all endpoints
  • ENDPOINT - Policy applies only to specified endpoint

Enum: targetPipeline

  • REQUEST - Executes in request pipeline (authenticates request)
  • RESPONSE - Executes in response pipeline
  • ERROR - Executes in error pipeline

Enum: targetEndpointHTTPMethod

  • GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD
policy​
FieldTypeRequiredDefaultDescription
typestringYes-Policy type: policy-oidc
descriptionstringNo-Policy description
activebooleanNotrueWhether policy is active
issuerstringYes-OIDC Issuer URL (e.g., https://accounts.google.com)
authorizationEndpointstringYes-Authorization endpoint URL
tokenEndpointstringYes-Token endpoint URL
userInfoEndpointstringNonullUserInfo endpoint URL (optional)
jwksEndpointstringNo*nullJWKS endpoint URL (required if validateJwtSignature=true)
clientIdstringYes-OIDC Client ID
clientSecretstringNonullOIDC Client Secret (encrypted)
redirectUristringYes-Redirect URI (callback URL)
flowTypestringNoAUTHORIZATION_CODEOIDC Flow Type
enablePKCEbooleanNotrueEnable PKCE (Proof Key for Code Exchange)
scopesarrayYes["openid", "profile", "email"]OIDC/OAuth 2.0 scopes (must include "openid" for OIDC)
additionalAuthParamsobjectNoAdditional authorization parameters
authenticationModestringNoEXTERNAL_ONLYAuthentication mode
requireBothInHybridbooleanNofalseRequire both external and internal authentication in hybrid mode
validateIdTokenbooleanNotrueValidate ID Token signature and claims
validateAccessTokenbooleanNofalseValidate Access Token
validateJwtLocallybooleanNotrueValidate JWT token locally (exp, iss, aud checks)
validateJwtSignaturebooleanNofalseValidate JWT signature using JWKS endpoint
expectedJwtAuthSigningAlgsarrayNo["RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "PS256", "PS384", "PS512", "EdDSA"]Expected JWT signing algorithms
callUserInfoEndpointbooleanNotrueCall UserInfo endpoint to get user information
tokenCacheTimeoutSecondsintegerNo3600Token cache timeout in seconds
jwkCacheTimeoutSecondsintegerNo3600JWK cache timeout in seconds
usernameClaimPathstringNo"sub"Claim path for username
emailClaimPathstringNo"email"Claim path for email
displayNameClaimPathstringNo"name"Claim path for display name
roleMappingsarrayNo[]Role mappings for authorization
sessionCookieNamestringNo"OIDC_SESSION"Session cookie name
sessionTimeoutMinutesintegerNo60Session timeout in minutes
sessionStorageTypestring (enum)NoCACHE (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.
tempSessionStorageTypestring (enum)Nonull (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.
loginFlowTimeoutSecondsintegerNo600Login 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)).
enableStateValidationbooleanNotrueEnable state validation for CSRF protection
enableNonceValidationbooleanNotrueEnable nonce validation for replay attack protection
introspectionEndpointstringNonullIntrospection endpoint URL (optional)
validateIssuerbooleanNotrueValidate issuer claim in JWT
expectedIssuerstringNonullExpected issuer value
validateAudiencebooleanNofalseValidate audience claim in JWT
expectedAudiencearrayNo[]Expected audience values
sessionCookieSecurebooleanNotrueSession cookie secure flag (HTTPS only)
allowInsecureConnectionsbooleanNofalseAllow insecure HTTPS connections
connectionTimeoutSecondsintegerNo30Connection timeout in seconds
readTimeoutSecondsintegerNo30Read timeout in seconds
maxClockSkewSecondsintegerNo300Maximum clock skew in seconds for token validation
errorRedirectUrlstringNonullError redirect URL
errorMessageTemplatestringNonullError message template
includeErrorDetailsbooleanNofalseInclude error details in response
customHeadersobjectNoCustom HTTP headers to include in OIDC requests
userAgentstringNo"Apinizer-OIDC-Client/1.0"User agent string for OIDC requests
enableDebugLoggingbooleanNofalseEnable debug logging
customClaimMappingsobjectNoCustom claim mappings
disableUserinfoHeaderbooleanNofalseDisable userinfo header in response
userinfoHeaderNamestringNo"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 Only
  • INTERNAL_ONLY - Internal Apinizer Credentials Only
  • HYBRID - 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/512
  • ES256, ES384, ES512 - ECDSA with SHA-256/384/512
  • PS256, PS384, PS512 - RSASSA-PSS with SHA-256/384/512
  • EdDSA - Edwards-curve Digital Signature Algorithm

Note​

  • issuer, authorizationEndpoint, tokenEndpoint, clientId, and redirectUri are required.
  • scopes must contain at least "openid" for OIDC flows.
  • If validateJwtSignature: true, jwksEndpoint is required.
  • If validateAudience: true, expectedAudience must contain at least one value.
  • sessionStorageType covers the authenticated session only. The temporary login session — state/nonce/PKCE verifier — is governed by tempSessionStorageType, which defaults to null and then follows sessionStorageType. So with the default (null), setting sessionStorageType: COOKIE also moves the login flow off the cache. Set tempSessionStorageType explicitly only when you want the two to differ — for example CACHE to keep the login flow on the distributed cache while the authenticated session stays in a cookie.
  • loginFlowTimeoutSeconds is independent of sessionAbsoluteTimeoutSeconds. 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:

FieldTypeRequiredDefaultDescription
claimPathstringYes-JSONPath or claim name to extract role information (e.g., "roles", "groups", "$.realm_access.roles")
claimValuestringNonullExpected value in the claim (if null, any non-empty value matches)
roleNamestringYes-Apinizer role name to assign when claim matches
requiredbooleanNofalseWhether 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}/

Request​

Headers​

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy name

Request Body​

Full JSON Body Example​
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["tester"],
"order": 1
},
"policy": {
"type": "policy-oidc",
"description": "Updated: OIDC authentication with enhanced security",
"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-updated-client-secret",
"redirectUri": "https://api.example.com/oidc/callback",
"flowType": "AUTHORIZATION_CODE",
"enablePKCE": true,
"scopes": ["openid", "profile", "email", "groups"],
"additionalAuthParams": {
"prompt": "consent",
"access_type": "offline"
},
"authenticationMode": "EXTERNAL_ONLY",
"requireBothInHybrid": false,
"validateIdToken": true,
"validateAccessToken": true,
"validateJwtLocally": true,
"validateJwtSignature": true,
"expectedJwtAuthSigningAlgs": ["RS256", "RS384", "RS512", "ES256"],
"callUserInfoEndpoint": true,
"tokenCacheTimeoutSeconds": 7200,
"jwkCacheTimeoutSeconds": 7200,
"usernameClaimPath": "sub",
"emailClaimPath": "email",
"displayNameClaimPath": "name",
"roleMappings": [
{
"claimPath": "groups",
"claimValue": "admins",
"role": "admin"
},
{
"claimPath": "groups",
"claimValue": "users",
"role": "user"
}
],
"sessionCookieName": "OIDC_SESSION",
"sessionTimeoutMinutes": 120,
"enableStateValidation": true,
"enableNonceValidation": true,
"validateIssuer": true,
"expectedIssuer": "https://accounts.google.com",
"validateAudience": true,
"expectedAudience": ["your-client-id.apps.googleusercontent.com"],
"sessionCookieSecure": true,
"allowInsecureConnections": false,
"connectionTimeoutSeconds": 60,
"readTimeoutSeconds": 60,
"maxClockSkewSeconds": 180,
"errorRedirectUrl": "https://api.example.com/error",
"errorMessageTemplate": "Authentication failed: {error}",
"includeErrorDetails": true,
"customHeaders": {
"X-Custom-Header": "custom-value"
},
"userAgent": "Apinizer-OIDC-Client/2.0",
"enableDebugLogging": true,
"customClaimMappings": {
"department": "user.department",
"employee_id": "user.employeeId"
},
"disableUserinfoHeader": false,
"userinfoHeaderName": "X-UserInfo"
}
}

Note: Request body structure is the same as Add Policy. All fields should be provided for update.

Response​

Success Response (200 OK)​

{
"status": "SUCCESS",
"deploymentResult": {
"success": true,
"deploymentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployment successful"
}
]
}
}

Delete Policy​

Endpoint​

DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Request​

Headers​

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy name

Request Body​

Full JSON Body Example​
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": false
}
}

Response​

Success Response (200 OK)​

{
"status": "SUCCESS",
"deploymentResult": {
"success": true,
"deploymentResults": []
}
}

Notes and Warnings​

  • Flow Types:

    • AUTHORIZATION_CODE - Recommended, most secure flow
    • IMPLICIT - Less secure, deprecated
    • HYBRID - Combines authorization code and implicit
    • OAUTH2_AUTHORIZATION_CODE - OAuth 2.0 without OIDC
  • PKCE: Enable PKCE for enhanced security (recommended for all flows)

  • Scopes: Must include "openid" for OIDC flows. Common scopes: "openid", "profile", "email", "offline_access"

  • Token Validation:

    • validateIdToken: Validates ID token signature and claims
    • validateJwtSignature: Validates JWT signature using JWKS endpoint (requires jwksEndpoint)
    • validateJwtLocally: Validates expiration, issuer, audience locally
  • Issuer and Audience:

    • validateIssuer: Validates issuer claim matches expected issuer
    • validateAudience: Validates audience claim matches expected audience (requires expectedAudience)
  • Session Management:

    • Authenticated-session storage is controlled by sessionStorageType: CACHE (default) keeps session data in the distributed cache with only the session id in the cookie; COOKIE embeds the AES-256-GCM encrypted session directly in the cookie (stateless, no cache call, ~4 KB limit)
    • The temporary login session (state/nonce/PKCE verifier) is controlled by tempSessionStorageType, which defaults to null and then follows sessionStorageType — so COOKIE on the authenticated session moves the login flow off the cache as well. Set tempSessionStorageType explicitly only to make the two differ (e.g. CACHE to keep the login flow on the distributed cache)
    • loginFlowTimeoutSeconds (default 600) bounds how long the temporary login session stays valid, independently of sessionAbsoluteTimeoutSeconds
    • Session encryption key/IV are auto-generated from policy ID
    • Session cookie is secure by default (HTTPS only)
  • Role Mapping: Map OIDC claims to Apinizer roles using roleMappings

  • UserInfo Endpoint: Call UserInfo endpoint to get additional user information

  • Cache: Token and JWK caches improve performance (configurable timeouts)

  • Security:

    • Use HTTPS for all OIDC endpoints
    • Enable state and nonce validation for CSRF/replay protection
    • Validate JWT signatures for token integrity
  • Performance: Token and JWK caching reduces provider calls

  • Pipeline:

    • REQUEST pipeline authenticates request using OIDC flow
    • Authentication failure redirects to authorization endpoint or returns error
  • Error Handling: Configure error redirect URL and message template for user-friendly error handling

  • Deployment: Policy changes require deployment to take effect. Set deploy: true or deploy manually.