Skip to content

Commit d32af7e

Browse files
committed
Update OpenFGA authorization model to v9
Enhances vote and survey authorization with improved access control: - Rename individual_vote to vote_response with owner relation - Add participant and results_viewer relations to vote type - Introduce survey and survey_response types with similar access patterns - Add conditional access for participants to view aggregate results - Improve auditor access definitions across vote and survey types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Andres Tobon <andrest2455@gmail.com>
1 parent c670a0d commit d32af7e

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

charts/lfx-platform/templates/openfga/model.yaml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ spec:
1919
- patch: Modifications of define
2020
*/}}
2121
- version:
22-
major: 8
22+
major: 9
2323
minor: 0
2424
patch: 0
2525
authorizationModel: |
@@ -295,22 +295,44 @@ spec:
295295
define committee: [committee]
296296
define project: [project]
297297
define writer: writer from project or writer from committee
298+
# auditor has access to participants, viewer does not
298299
define auditor: writer or auditor from project or auditor from committee
299-
define viewer: [user:*] or auditor
300+
define participant: [user]
301+
define viewer: [user:*] or auditor or participant
302+
define vote_for_participant_result_access: [vote] # set this relation to "self" to enable access
303+
# results_viewer is not for viewing the actual related vote_response objects,
304+
# but rather for an aggregate summary which can be made optionally public
305+
define results_viewer: [user:*] or auditor or participant from vote_for_participant_result_access
300306
301-
type individual_vote
307+
type vote_response
302308
relations
303309
define vote: [vote]
304-
define auditor: auditor from vote
305-
define writer: [user] # Only individuals can update their own vote
306-
define viewer: [user]
310+
# owner is the user who cast this response
311+
define owner: [user]
312+
# we don't need to create a "writer" relation that is defined as just "owner":
313+
# we just use the "owner" relation in our access checks!
314+
define auditor: owner or auditor from vote
307315
308-
# Vote results are not updated directly, but are instead an aggregation
309-
# of individual votes. This is done because the results of votes can themselves
310-
# be public or not, independently from the vote itself.
311-
type vote_results
316+
type survey
312317
relations
313-
define vote: [vote]
314-
define auditor: auditor from vote
315-
define viewer: [user:*] or auditor
318+
define committee: [committee]
319+
define project: [project]
320+
define writer: writer from project or writer from committee
321+
# auditor has access to participants, viewer does not
322+
define auditor: writer or auditor from project or auditor from committee
323+
define participant: [user]
324+
define viewer: [user:*] or auditor or participant
325+
define survey_for_participant_result_access: [survey] # set this relation to "self" to enable access
326+
# results_viewer is not for viewing the actual related survey_response objects,
327+
# but rather for an aggregate summary which can be made optionally public
328+
define results_viewer: [user:*] or auditor or participant from survey_for_participant_result_access
329+
330+
type survey_response
331+
relations
332+
define survey: [survey]
333+
# owner is the user who cast this response
334+
define owner: [user]
335+
# we don't need to create a "writer" relation that is defined as just "owner":
336+
# we just use the "owner" relation in our access checks!
337+
define auditor: owner or auditor from survey
316338
{{- end }}

0 commit comments

Comments
 (0)