Skip to content

chore(authz): review authz implementation#1244

Open
kanstantsinbuklis-sap wants to merge 4 commits into
mainfrom
kanstantsinbuklis-sap/issue-1241/review-authz-implementation
Open

chore(authz): review authz implementation#1244
kanstantsinbuklis-sap wants to merge 4 commits into
mainfrom
kanstantsinbuklis-sap/issue-1241/review-authz-implementation

Conversation

@kanstantsinbuklis-sap

@kanstantsinbuklis-sap kanstantsinbuklis-sap commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

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)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore
  • ⏩ Revert

Related Tickets & Documents

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help
  • Separate ticket for tests # (issue/pr)

Added to documentation?

  • 📜 README.md
  • 🤝 Documentation pages updated
  • 🙅 no documentation needed
  • (if applicable) generated OpenAPI docs for CRD changes

Signed-off-by: Kanstantsin Buklis <kanstantsin.buklis@sap.com>
@kanstantsinbuklis-sap
kanstantsinbuklis-sap force-pushed the kanstantsinbuklis-sap/issue-1241/review-authz-implementation branch from c482e75 to 29d4844 Compare July 6, 2026 11:27
@kanstantsinbuklis-sap
kanstantsinbuklis-sap marked this pull request as ready for review July 6, 2026 11:58
Copilot AI review requested due to automatic review settings July 6, 2026 11:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_write includes Support Group member.
  • Enforce can_write permission on the target service when creating a remediation, with tests for denied/error cases.
  • Add an OpenFGA can_write relation constant and update mockery config to generate an Authorization mock.

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)),
})

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serviceResult, err := r.App.ListServices(

Comment on lines +199 to +202
Relation: openfga.RelCanWrite,
ObjectType: openfga.TypeService,
ObjectId: openfga.ObjectId(fmt.Sprint(remediation.ServiceId)),
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(authz): review authz implementation

3 participants