Okta FGA Authorization Policy
This policy authorizes requests using Okta Fine-Grained Authorization (FGA), providing robust access control for your API resources. If the request is not authorized, a 403 response will be returned.
With this policy, you'll benefit from:
- Powerful Authorization Model: Implement complex relationship-based access control using Okta FGA's authorization model
- Flexible Permission Structure: Define granular permissions with user-to-resource relationships that scale with your application
- Seamless Okta Integration: Leverage your existing Okta identity infrastructure for consistent authorization across your ecosystem
- Dynamic Authorization Logic: Create context-aware authorization rules that adapt based on route, method, or request properties
- Simplified Implementation: Reduce development time with ready-to-use authorization checks that integrate with your API gateway
- Enhanced Security: Apply fine-grained access control to protect sensitive resources and operations
- Centralized Policy Management: Manage all your authorization rules in one place through Okta FGA
Beta
This policy is in beta. You can use it today, but it may change in non-backward compatible ways before the final release.
Configuration
The configuration shows how to configure the policy in the 'policies.json' document.
Code(json)
Policy Configuration
name
<string>
- The name of your policy instance. This is used as a reference in your routes.policyType
<string>
- The identifier of the policy. This is used by the Zuplo UI. Value should beokta-fga-authz-inbound
.handler.export
<string>
- The name of the exported type. Value should beOktaFGAAuthZInboundPolicy
.handler.module
<string>
- The module containing the policy. Value should be$import(@zuplo/runtime)
.handler.options
<object>
- The options for this policy. See Policy Options below.
Policy Options
The options for this policy are specified below. All properties are optional unless specifically marked as required.
region
(required)<string>
- The region your store is deployed. Allowed values areus1
,eu1
,au1
.storeId
(required)<string>
- The ID of the store.authorizationModelId
(required)<string>
- The ID of the authorization model.allowUnauthorizedRequests
<boolean>
- Indicates whether the request should continue if authorization fails. Default isfalse
which means unauthorized users will automatically receive a 403 response. Defaults tofalse
.credentials
(required)<object>
- No description available.clientId
(required)<string>
- The client ID.clientSecret
(required)<string>
- The client secret.
Using the Policy
Usage
To use this policy, you must programmatically set the relationship checks to be
performed against your Okta FGA store. This is done using the static
setContextChecks
method.
The most common way to set the authorization checks are:
- Creating custom inbound policies for each authorization scenario
- Creating a custom inbound policy that reads data from the OpenAPI operation and sets the authorization checks dynamically
Example: Custom Authorization Policies
Create a file like modules/oktafga-checks.ts
to define your custom
authorization policies:
Code(typescript)
Applying to Routes
In your route configuration, apply both the custom authorization policy and the OktaFGA policy:
Code(json)
Then in your policies.json
:
Code(json)
Example: Dynamic Authorization Checks
You can make your authorization checks more dynamic by reading data from your OpenAPI specification or other sources. This allows you to define authorization rules that adapt based on the route, method, or other request properties.
For example, you could access custom data defined in your route:
Code(typescript)
Then in your OpenAPI document, you would set the custom data on the x-authz
property:
Code(json)
Read more about how policies work