Skip to content

Commit

Permalink
#1731 Fix managePlatform permission
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Mar 4, 2021
1 parent 0a45b8f commit cc49281
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions thehive/app/org/thp/thehive/controllers/v1/UserCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ class UserCtrl @Inject() (
.current
.richUserWithCustomRenderer(request.organisation, _.organisationWithRole)
.getOrFail("User")
.map(user =>
.map { user =>
val scope =
if (user._1.organisation == Organisation.administration.name) "admin"
else "organisation"
Results
.Ok(user.toJson)
.withHeaders("X-Organisation" -> request.organisation.toString)
.withHeaders("X-Permissions" -> user._1.permissions.mkString(","))
)
.withHeaders("X-Permissions" -> (Permissions.forScope(scope) & user._1.permissions).mkString(","))
}
.recover { case _ => Results.Unauthorized.withHeaders("X-Logout" -> "1") }
}

Expand Down
1 change: 1 addition & 0 deletions thehive/app/org/thp/thehive/models/Permissions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ object Permissions extends Perms {
manageOrganisation,
managePage,
managePattern,
managePlatform,
manageProcedure,
manageProfile,
manageShare,
Expand Down

0 comments on commit cc49281

Please sign in to comment.