This document describes how to enable and use authorization with Flipt.
allowed == true
for the request to be allowed.
/api/v1/
roles
containing a value admin
:
input.authentication
: The authentication information for the request. These are specific to each authentication provider/method and can include things like the user’s roles, email, etc.input.request
: The incoming request details, such as the namespace
, resource
, and action
.input.authentication.metadata
field may contain the user’s name and email as well as custom claims assigned to the user.
Here is an example of the input.authentication.metadata
field for a request authenticated using an example OIDC provider:
io.flipt.auth.claims
field is a JSON object that contains custom claims
provided by the authentication provider. Each authentication provider may
provide different claims, so it’s up to you to map these claims as needed in
your policies.input.authentication
field:
metadata
: A map of authentication metadata provided by the authentication method. This can include the user’s email, name, roles, etc.
io.flipt.auth.email
: The user’s email address.io.flipt.auth.name
: The user’s name.io.flipt.auth.claims
: A map of all claims provided by the authentication method. This can include the user’s roles, groups, etc. These claims are marshaled into a JSON string before being passed to OPA for evaluation.method
: The authentication method used to authenticate the request.input
field.
flipt.is_auth_method(input, method)
The helper function flipt.is_auth_method(input, method)
can be used to check if the request was authenticated using the specified method.
The method
parameter is the authentication method name as it is registered in Flipt, e.g. oidc
, token
, kubernetes
, github
, jwt
.
Example:
authentication
) with the requested resource (request
) to make an authorization decision whether or not the request should be allowed (allow
).
Some authentication methods provide user details such as roles directly, while others may provide a user ID or email that you can use to look up roles in your own system. Many authentication providers support adding custom claims to the JWT token, which can be used to provide additional information about the user.
For example, Okta allows you to add custom claims using their groups feature. An example JWT token with custom claims generated by Okta might look like this:
groups
claim is used to provide the user’s organizational groups. You can then write a policy that checks for the presence of specific groups to determine whether the user should be allowed to access a particular resource.
json.unmarshal
function is used to convert the groups
claim from a string to a JSON object that can be queried in the policy.Flipt encodes the raw authentication claims as a JSON string to pass them to OPA for evaluation.input.request
field contains information about the incoming request. This includes the namespace
, resource
, and action
of the request.
namespace
: The namespace in Flipt of the resource being accessed. If no namespace is provided, the default namespace is used, or it is not applicable as the resource is not namespace scoped (e.g. authentication)
resource
: The resource being accessed. This can be one of:
namespace
: Access to namespace resources (e.g., listing or creating namespaces).flag
: Access to flag resources and sub-resources (e.g., listing or creating flags, variants, rules or rollouts).segment
: Access to segment resources and sub-resources (e.g., listing or creating segments, constraints or distributions).authentication
: Access to authentication resources (e.g., listing or creating client tokens).subject
: The (optional) nested subject of the request. This can be one of:
namespace
: Access to namespace resources.flag
: Access to flag resources.
segment
: Access to segment resources.
constraint
: Access to segment constraint resources.distribution
: Access to segment distribution resources.token
: Access to client token resources.action
: The action being performed on the resource. This can be one of:
create
: Access to create resources.read
: Access to list or read resources.update
: Access to update resources.delete
: Access to delete resources.input.request
field for a request to list flags in the default namespace:
IT
group to delete flags in the default namespace:
admin
role: