Skip to content

Commit d37901c

Browse files
authored
Merge pull request #147 from linuxfoundation/jme/LFXV2-2395
feat: add openfga_or_check authorizer for OR-based FGA authorization (LFXV2-2395)
2 parents d30e6ee + 96fd64b commit d37901c

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

charts/lfx-platform/values.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,63 @@ heimdall:
332332
expressions:
333333
- expression: |
334334
Payload.allowed == true
335+
- id: openfga_or_check
336+
type: remote
337+
config:
338+
endpoint: "http://lfx-platform-openfga:8080/stores/${OPENFGA_STORE_ID}/batch-check"
339+
values:
340+
model_id: ${OPENFGA_AUTH_MODEL_ID}
341+
payload: |
342+
{
343+
"authorization_model_id": "{{ .Values.model_id }}",
344+
"checks": [
345+
{
346+
"tuple_key": {
347+
"user": {{
348+
list
349+
"user:"
350+
(
351+
eq .Subject.ID "_anonymous"
352+
| ternary
353+
"_anonymous"
354+
(or
355+
.Subject.Attributes.username
356+
(list .Subject.Attributes.client_id "@clients" | join ""))
357+
)
358+
| join "" | quote
359+
}},
360+
"relation": "{{ .Values.relation }}",
361+
"object": "{{ .Values.object }}"
362+
},
363+
"correlation_id": "primary_check"
364+
}
365+
{{- if .Values.or_object }},
366+
{
367+
"tuple_key": {
368+
"user": {{
369+
list
370+
"user:"
371+
(
372+
eq .Subject.ID "_anonymous"
373+
| ternary
374+
"_anonymous"
375+
(or
376+
.Subject.Attributes.username
377+
(list .Subject.Attributes.client_id "@clients" | join ""))
378+
)
379+
| join "" | quote
380+
}},
381+
"relation": "{{ or .Values.or_relation .Values.relation }}",
382+
"object": "{{ .Values.or_object }}"
383+
},
384+
"correlation_id": "secondary_check"
385+
}
386+
{{- end }}
387+
]
388+
}
389+
expressions:
390+
- expression: |
391+
Payload.result.primary_check.allowed || ("secondary_check" in Payload.result && Payload.result.secondary_check.allowed)
335392
finalizers:
336393
- id: create_jwt
337394
type: jwt

0 commit comments

Comments
 (0)