Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package identity.check_token
package identity.auth.token.show

import data.identity

# Update mapping.
# Validate the token

default allow := false

Expand All @@ -11,14 +11,16 @@ allow if {
}

allow if {
"reader" in input.credentials.roles
"all" in input.credentials.system_scope
"service" in input.credentials.roles
}

allow if {
identity.token_subject
"reader" in input.credentials.roles
input.credentials.system_scope != null
"all" == input.credentials.system_scope
}

allow if {
"service" in input.credentials.roles
identity.token_subject
}

19 changes: 19 additions & 0 deletions policy/auth/token/show_test.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

package test_auth_token_show

import data.identity.auth.token.show

test_allowed if {
show.allow with input as {"credentials": {"roles": ["admin"]}}
show.allow with input as {"credentials": {"roles": ["service"]}}
show.allow with input as {"credentials": {"roles": ["reader"], "system_scope": "all"}}
show.allow with input as {"credentials": {"user_id": "foo"}, "target": {"token": {"user_id": "foo"}}}
show.allow with input as {"credentials": {"roles": ["admin"], "user_id": "foo"}, "target": {"token": {"user_id": "bar"}}}
}

test_forbidden if {
not show.allow with input as {"credentials": {"roles": ["reader"], "system_scope": "not_all"}}
not show.allow with input as {"credentials": {"roles": ["manager"], "user_id": "foo"}, "target": {"token": {"user_id": "bar"}}}
not show.allow with input as {"credentials": {"roles": ["member"], "user_id": "foo"}, "target": {"token": {"user_id": "bar"}}}
not show.allow with input as {"credentials": {"roles": ["reader"], "user_id": "foo"}, "target": {"token": {"user_id": "bar"}}}
}
24 changes: 0 additions & 24 deletions policy/federation/token/validate.rego

This file was deleted.

2 changes: 1 addition & 1 deletion src/api/v3/auth/token/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ async fn show(

policy
.enforce(
"identity/validate_token",
"identity/auth/token/show",
&user_auth,
to_value(json!({"token": &token}))?,
None,
Expand Down
Loading