Skip to content

Commit

Permalink
user_key instead of user or email
Browse files Browse the repository at this point in the history
  • Loading branch information
daisieh committed Mar 7, 2024
1 parent a9d71a1 commit a6c31ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions permissions_engine/authz.rego
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ import data.store_token.token as vault_token
import future.keywords.in

roles = http.send({"method": "get", "url": "VAULT_URL/v1/opa/roles", "headers": {"X-Vault-Token": vault_token}}).body.data.roles
user := decode_verify_token_output[_][2].CANDIG_USER_KEY # get user key from the token payload
user_key := decode_verify_token_output[_][2].CANDIG_USER_KEY # get user key from the token payload

allow {
user in roles.site_admin
user_key in roles.site_admin
}

keys = http.send({"method": "get", "url": "VAULT_URL/v1/opa/data", "headers": {"X-Vault-Token": vault_token}}).body.data.keys
Expand Down
6 changes: 2 additions & 4 deletions permissions_engine/idp.rego
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ valid_token = true {
decode_verify_token_output[_][0]
}

user := decode_verify_token_output[_][2].CANDIG_USER_KEY # get user key from the token payload
user_key := decode_verify_token_output[_][2].CANDIG_USER_KEY # get user key from the token payload

#
# Check trusted_researcher in the token payload
Expand All @@ -45,7 +45,5 @@ import future.keywords.in

roles = http.send({"method": "get", "url": "VAULT_URL/v1/opa/roles", "headers": {"X-Vault-Token": token}}).body.data.roles
site_admin = true {
user in roles.site_admin
user_key in roles.site_admin
}

email := decode_verify_token_output[_][2].email # get email from the token payload
4 changes: 2 additions & 2 deletions permissions_engine/permissions.rego
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ post_input_paths = paths.post
#
import data.idp.valid_token
import data.idp.trusted_researcher
import data.idp.email
import data.idp.user_key

#
# is registered access allowed?
Expand All @@ -43,7 +43,7 @@ registered_allowed = access.registered_datasets {

default controlled_allowed = []

controlled_allowed = access.controlled_access_list[email]{
controlled_allowed = access.controlled_access_list[user_key]{
valid_token # extant, valid token
}

Expand Down

0 comments on commit a6c31ce

Please sign in to comment.