Skip to content

Commit e7b6abf

Browse files
committed
docs(v2): opt-in authorization for evaluation APIs
Document authorization.exclude.evaluation/ofrep defaults. Covers the authentication prerequisite for enforcement. closes #426 Signed-off-by: Roman Dmytrenko <rdmytrenko@gmail.com>
1 parent 2894476 commit e7b6abf

2 files changed

Lines changed: 100 additions & 6 deletions

File tree

‎docs/v2/configuration/authorization.mdx‎

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ authorization:
1212
required: true
1313
```
1414
15-
When authorization is set to `required`, the API will ensure valid credentials are present on all management API requests.
15+
When authorization is set to `required`, the API will ensure valid credentials are present on management API requests. Evaluation and OFREP endpoints are excluded by default. See [Evaluation and OFREP Exclusions](#evaluation-and-ofrep-exclusions) to opt in to enforcement.
1616

1717
<Info>
1818
Once authorization has been set to `required: true` all management API routes will require a valid authentication session as well.
@@ -21,6 +21,41 @@ The UI will require a session-compatible authentication method (e.g. OIDC) to be
2121

2222
</Info>
2323

24+
## Evaluation and OFREP Exclusions
25+
26+
Evaluation (`/evaluate/v1` and `/client/v2` snapshot/stream) and OFREP (`/ofrep`) endpoints bypass authorization by default, even when `authorization.required` is `true`.
27+
28+
To enforce authorization on evaluation or OFREP, set the corresponding exclusion option to `false`:
29+
30+
```yaml
31+
authorization:
32+
required: true
33+
exclude:
34+
evaluation: false
35+
ofrep: false
36+
```
37+
38+
<Note>
39+
Sections of the API excluded from authentication always skip authorization as
40+
well, since there is no identity to evaluate policy against. To enforce
41+
authorization on evaluation or OFREP, you must also require authentication for
42+
those sections by setting `authentication.exclude.evaluation` and
43+
`authentication.exclude.ofrep` to `false`.
44+
</Note>
45+
46+
When enforced, evaluation requests use the `evaluate` action instead of `read`. This lets you grant evaluation without granting management reads, for example with namespace-scoped tokens:
47+
48+
```rego
49+
allow if {
50+
input.request.action == "evaluate"
51+
input.request.scope == "namespace"
52+
input.request.environment == "production"
53+
input.request.namespace == "frontend"
54+
}
55+
```
56+
57+
See [Configuration Overview](/v2/configuration/overview#authorization) for the full list of options.
58+
2459
## Backends
2560

2661
Flipt uses [Open Policy Agent (OPA)](https://www.openpolicyagent.org/) to enforce authorization policies. OPA is a general-purpose policy engine that can be used to enforce policies across the stack.
@@ -101,6 +136,30 @@ authorization:
101136
poll_interval: "1m"
102137
```
103138

139+
### Helper Functions
140+
141+
To make it easier to write policies, Flipt provides a set of helper functions that are available to be used for the `input` field.
142+
143+
`flipt.is_auth_method(input, method)`
144+
145+
The helper function `flipt.is_auth_method(input, method)` can be used to check if the request was authenticated using the specified method.
146+
147+
The `method` parameter is the authentication method name as it is registered in Flipt, e.g. `oidc`, `token`, `kubernetes`, `github`, `jwt` (`k8s` is accepted as an alias for `kubernetes`).
148+
149+
Example:
150+
151+
```rego policy.rego
152+
package flipt.authz.v2
153+
154+
import rego.v1
155+
156+
default allow := false
157+
158+
allow if {
159+
flipt.is_auth_method(input, "jwt")
160+
}
161+
```
162+
104163
## Key Differences from v1
105164

106165
Flipt v2 authorization introduces several important changes:
@@ -145,11 +204,13 @@ v2 uses a simplified request structure with `scope` field:
145204
"scope": "namespace", // or "environment"
146205
"environment": "production",
147206
"namespace": "frontend",
148-
"action": "update"
207+
"action": "update" // create, read, update, delete, or evaluate
149208
}
150209
}
151210
```
152211

212+
The `evaluate` action is used for evaluation, snapshot, and OFREP requests when those endpoints are not excluded from authorization. Use it to grant evaluation without granting management reads.
213+
153214
## Example Policies
154215

155216
### Basic RBAC Policy

‎docs/v2/configuration/overview.mdx‎

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ Authentication configuration controls how users and systems authenticate with Fl
290290
| Property | Description | Default | Since |
291291
| --------------------------------- | ------------------------------------------------------- | ------- | ------ |
292292
| authentication.required | Enable or disable authentication validation on requests | false | v2.0.0 |
293-
| authentication.exclude.evaluation | Exclude authentication for /evaluation/v1 API prefix | false | v2.0.0 |
293+
| authentication.exclude.evaluation | Exclude authentication for /evaluate/v1 API prefix | false | v2.0.0 |
294294
| authentication.exclude.ofrep | Exclude authentication for /ofrep API prefix | false | v2.0.0 |
295295

296296
#### Authentication Session
@@ -399,9 +399,42 @@ Authentication configuration controls how users and systems authenticate with Fl
399399

400400
Authorization configuration enforces fine-grained access control policies to restrict operations based on user roles and permissions.
401401

402-
| Property | Description | Default | Since |
403-
| ---------------------- | ------------------------------------------------------ | ------- | ------ |
404-
| authorization.required | Enable or disable authorization validation on requests | false | v2.0.0 |
402+
| Property | Description | Default | Since |
403+
| -------------------------------- | ----------------------------------------------------------------------------------------------- | ------- | ------- |
404+
| authorization.required | Enable or disable authorization validation on requests | false | v2.0.0 |
405+
| authorization.exclude.evaluation | Exclude evaluation APIs (/evaluate/v1 and /client/v2 snapshot/stream) from authorization checks | true | v2.14.0 |
406+
| authorization.exclude.ofrep | Exclude OFREP API (/ofrep) from authorization checks | true | v2.14.0 |
407+
408+
#### Authorization Exclusions for Evaluation
409+
410+
By default, evaluation and OFREP endpoints bypass authorization checks even when `authorization.required` is set to `true`. This preserves backward compatibility.
411+
412+
To enforce authorization on evaluation or OFREP, set the corresponding exclusion option to `false`:
413+
414+
```yaml
415+
authorization:
416+
required: true
417+
exclude:
418+
evaluation: false
419+
ofrep: false
420+
```
421+
422+
You can also use environment variables:
423+
424+
```console
425+
export FLIPT_AUTHORIZATION_EXCLUDE_EVALUATION=false
426+
export FLIPT_AUTHORIZATION_EXCLUDE_OFREP=false
427+
```
428+
429+
<Note>
430+
Sections of the API excluded from authentication always skip authorization as
431+
well, since there is no identity to evaluate policy against. To enforce
432+
authorization on evaluation or OFREP, you must also require authentication for
433+
those sections by setting `authentication.exclude.evaluation` and
434+
`authentication.exclude.ofrep` to `false`.
435+
</Note>
436+
437+
When enforced, evaluation requests carry the `evaluate` action (instead of `read`), so you can grant evaluation without granting management reads. See [Authorization](/v2/configuration/authorization) for example policies.
405438

406439
#### Authorization Backend: Local
407440

0 commit comments

Comments
 (0)