Skip to content

Commit

Permalink
🐛 Fix analyses RBAC. (#472)
Browse files Browse the repository at this point in the history
Fix RBAC for:
- /analyses - _This is the primary endpoint for analyses_
- /applications/:id/analyses endpoints - _This is the analyses
subresource under applications_.

Roles:
- Addon: CRUD for:
  - /applications/:id/analyses
- Admin, Architect: CRUD for:
  - /analyses
  - /applications/:id/analyses
- Migrator, Project-Manager: Read-Only, 
  - /analyses
  - /applications/:id/analyses

---------

Signed-off-by: Jeff Ortel <jortel@redhat.com>
  • Loading branch information
jortel committed Aug 10, 2023
1 parent f9552d7 commit f18f21c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
9 changes: 5 additions & 4 deletions api/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,24 @@ type AnalysisHandler struct {
//
// AddRoutes adds routes.
func (h AnalysisHandler) AddRoutes(e *gin.Engine) {
// Primary
routeGroup := e.Group("/")
routeGroup.Use(Required("application"))
//
routeGroup.Use(Required("analyses"))
routeGroup.GET(AnalysisRoot, h.Get)
routeGroup.DELETE(AnalysisRoot, h.Delete)
routeGroup.GET(AnalysesDepsRoot, h.Deps)
routeGroup.GET(AnalysesIssuesRoot, h.Issues)
routeGroup.GET(AnalysesIssueRoot, h.Issue)
routeGroup.GET(AnalysisIncidentsRoot, h.Incidents)
//
routeGroup.GET(AnalysisReportRuleRoot, h.RuleReports)
routeGroup.GET(AnalysisReportAppsIssuesRoot, h.AppIssueReports)
routeGroup.GET(AnalysisReportIssuesAppsRoot, h.IssueAppReports)
routeGroup.GET(AnalysisReportFileRoot, h.FileReports)
routeGroup.GET(AnalysisReportDepsRoot, h.DepReports)
routeGroup.GET(AnalysisReportDepsAppsRoot, h.DepAppReports)
//
// Application
routeGroup = e.Group("/")
routeGroup.Use(Required("applications.analyses"))
routeGroup.POST(AppAnalysesRoot, h.AppCreate)
routeGroup.GET(AppAnalysesRoot, h.AppList)
routeGroup.GET(AppAnalysisRoot, h.AppLatest)
Expand Down
1 change: 1 addition & 0 deletions auth/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var AddonRole = []string{
"applications.tags:*",
"applications.facts:*",
"applications.bucket:*",
"applications.analyses:*",
"identities:get",
"identities:decrypt",
"proxies:get",
Expand Down
38 changes: 37 additions & 1 deletion auth/roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
- get
- post
- put
- name: applications.analyses
verbs:
- delete
- get
- post
- put
- name: applications.stakeholders
verbs:
- put
Expand Down Expand Up @@ -173,6 +179,12 @@
- get
- post
- put
- name: analyses
verbs:
- delete
- get
- post
- put
- role: tackle-architect
resources:
- name: addons
Expand Down Expand Up @@ -208,6 +220,12 @@
- get
- post
- put
- name: applications.analyses
verbs:
- delete
- get
- post
- put
- name: applications.stakeholders
verbs:
- put
Expand Down Expand Up @@ -335,6 +353,12 @@
- get
- post
- put
- name: analyses
verbs:
- delete
- get
- post
- put
- role: tackle-migrator
resources:
- name: addons
Expand All @@ -355,6 +379,9 @@
- name: applications.bucket
verbs:
- get
- name: applications.analyses
verbs:
- get
- name: assessments
verbs:
- get
Expand Down Expand Up @@ -436,6 +463,9 @@
- name: targets
verb:
- get
- name: analyses
verbs:
- get
- role: tackle-project-manager
resources:
- name: addons
Expand All @@ -456,6 +486,9 @@
- name: applications.bucket
verbs:
- get
- name: applications.analyses
verbs:
- get
- name: applications.stakeholders
verbs:
- put
Expand Down Expand Up @@ -530,4 +563,7 @@
- put
- name: targets
verbs:
- get
- get
- name: analyses
verbs:
- get

0 comments on commit f18f21c

Please sign in to comment.