Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: site curator is allowed to curate always #70

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions permissions_engine/calculate.rego
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ site_admin = true {
user_key in site_roles.admin
}

site_curator = true {
user_key in site_roles.curator
}

#
# what programs are available to this user?
#
Expand Down
45 changes: 29 additions & 16 deletions permissions_engine/permissions.rego
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,35 @@ site_admin := data.calculate.site_admin {
valid_token
}

site_curator := data.calculate.site_curator {
valid_token
}

datasets := data.calculate.datasets {
valid_token
}
else := []

# convenience path: if a specific program is in the body, allowed = true if that program is in datasets

# true if the path and method in the input match something in paths.json
path_method_registered := true {
input.body.method = "GET"
object.union(data.calculate.readable_get, data.calculate.curateable_get)[_]
}
else := true {
input.body.method = "POST"
object.union(data.calculate.readable_post, data.calculate.curateable_post)[_]
}
else := true {
input.body.method = "DELETE"
data.calculate.curateable_delete[_]
}
else := false


# if a specific program is in the body, allowed = true if that program is in datasets
# or if the user is a site admin
# or if the user is a site curator and wants to curate something
allowed := true
{
input.body.program in datasets
Expand All @@ -27,6 +50,11 @@ else := true
{
site_admin
}
else := true
{
site_curator
path_method_registered
}


#
Expand All @@ -51,21 +79,6 @@ user_is_site_curator := true {
}
else := false

# true if the path and method in the input match something in paths.json
path_method_registered := true {
input.body.method = "GET"
object.union(data.calculate.readable_get, data.calculate.curateable_get)[_]
}
else := true {
input.body.method = "POST"
object.union(data.calculate.readable_post, data.calculate.curateable_post)[_]
}
else := true {
input.body.method = "DELETE"
data.calculate.curateable_delete[_]
}
else := false

# programs the user is listed as a team member for
team_member_programs := object.keys(data.calculate.team_readable_programs)

Expand Down