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
12 changes: 12 additions & 0 deletions policy/diamond/policy/blueapi/blueapi.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package diamond.policy.blueapi

import data.diamond.policy.token
import rego.v1

default tiled_service_account_for_beamline := false

tiled_service_account_for_beamline if {
input.beamline == token.claims.beamline
"tiled-writer" in token.claims.aud
not token.claims.fedid
}
24 changes: 24 additions & 0 deletions policy/diamond/policy/blueapi/blueapi_test.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package diamond.policy.blueapi_test

import data.diamond.policy.blueapi
import rego.v1

test_service_account_if_beamline_matches if {
blueapi.tiled_service_account_for_beamline with input as {"beamline": "i22"}
with data.diamond.policy.token.claims as {"beamline": "i22", "aud": ["tiled-writer"]}
}

test_not_service_account_if_beamline_mismatch if {
not blueapi.tiled_service_account_for_beamline with input as {"beamline": "b21"}
with data.diamond.policy.token.claims as {"beamline": "i22", "aud": ["tiled-writer"]}
}

test_not_service_account_if_missing_aud if {
not blueapi.tiled_service_account_for_beamline with input as {"beamline": "i22"}
with data.diamond.policy.token.claims as {"beamline": "i22", "aud": ["blueapiCli"]}
}

test_not_service_account_if_fedid_present if {
not blueapi.tiled_service_account_for_beamline with input as {"beamline": "i22"}
with data.diamond.policy.token.claims as {"beamline": "i22", "aud": ["tiled-writer"], "fedid": "abc12345"}
}
Loading