chore(authz): review authz implementation#1244
Open
kanstantsinbuklis-sap wants to merge 4 commits into
Open
Conversation
Signed-off-by: Kanstantsin Buklis <kanstantsin.buklis@sap.com>
kanstantsinbuklis-sap
force-pushed
the
kanstantsinbuklis-sap/issue-1241/review-authz-implementation
branch
from
July 6, 2026 11:27
c482e75 to
29d4844
Compare
kanstantsinbuklis-sap
marked this pull request as ready for review
July 6, 2026 11:58
kanstantsinbuklis-sap
requested review from
copyonwrite,
dorneanu and
michalkrzyz
as code owners
July 6, 2026 11:58
4 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an authorization check to remediation creation using OpenFGA (service can_write) and updates the OpenFGA model and tests to support the new behavior.
Changes:
- Extend the OpenFGA authorization model so
service.can_writeincludes Support Groupmember. - Enforce
can_writepermission on the target service when creating a remediation, with tests for denied/error cases. - Add an OpenFGA
can_writerelation constant and update mockery config to generate anAuthorizationmock.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/openfga/model/model.fga | Expands service.can_write to include Support Group members. |
| internal/openfga/interface.go | Adds RelCanWrite and changes OpenFGA initialization behavior. |
| internal/app/remediation/remediation_handler.go | Adds can_write authorization gate before remediation creation. |
| internal/app/remediation/remediation_handler_test.go | Adds unit tests covering permission denied / authz error paths; initializes authz for suite. |
| .mockery.yaml | Configures mock generation for the OpenFGA Authorization interface. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
100
to
+105
| if cfg.AuthzOpenFgaApiUrl != "" { | ||
| return NewAuthz(l, cfg) | ||
| if authz := NewAuthz(l, cfg); authz != nil { | ||
| return authz | ||
| } | ||
|
|
||
| l.Warn("OpenFGA unavailable; falling back to no-op authorization") |
Comment on lines
+196
to
+202
| hasPermission, err := rh.authz.CheckPermission(openfga.RelationInput{ | ||
| UserType: openfga.TypeUser, | ||
| UserId: openfga.UserId(fmt.Sprint(remediation.CreatedBy)), | ||
| Relation: openfga.RelCanWrite, | ||
| ObjectType: openfga.TypeService, | ||
| ObjectId: openfga.ObjectId(fmt.Sprint(remediation.ServiceId)), | ||
| }) |
Collaborator
Author
There was a problem hiding this comment.
Comment on lines
+199
to
+202
| Relation: openfga.RelCanWrite, | ||
| ObjectType: openfga.TypeService, | ||
| ObjectId: openfga.ObjectId(fmt.Sprint(remediation.ServiceId)), | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In this PR I've added authz for the remediation creating logic and added tests to verify
What type of PR is this? (check all applicable)
Related Tickets & Documents
Added tests?
Added to documentation?