Skip to content

feat: add rule to check if service account is valid#303

Open
tpoliaw wants to merge 4 commits into
mainfrom
tiled-service-account-check
Open

feat: add rule to check if service account is valid#303
tpoliaw wants to merge 4 commits into
mainfrom
tiled-service-account-check

Conversation

@tpoliaw
Copy link
Copy Markdown
Collaborator

@tpoliaw tpoliaw commented May 8, 2026

No description provided.

@tpoliaw tpoliaw changed the title Add rule to check if service account is valid for beamline feat: Add rule to check if service account is valid for beamline May 8, 2026
@tpoliaw tpoliaw force-pushed the tiled-service-account-check branch 2 times, most recently from 980f098 to c77b98c Compare May 8, 2026 14:55
@tpoliaw tpoliaw force-pushed the tiled-service-account-check branch from c77b98c to 05d911c Compare May 8, 2026 14:57
@tpoliaw tpoliaw requested a review from ZohebShaikh May 8, 2026 14:58
@tpoliaw tpoliaw changed the title feat: Add rule to check if service account is valid for beamline feat: add rule to check if service account is valid May 8, 2026
Copy link
Copy Markdown
Collaborator

@ZohebShaikh ZohebShaikh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rego policy logic looks correct

Comment thread policy/diamond/policy/tiled/tiled.rego Outdated
Comment thread policy/diamond/policy/tiled/tiled.rego Outdated
"tiled-writer" in token.claims.aud
not token.claims.fedid
}

Copy link
Copy Markdown
Collaborator

@ZohebShaikh ZohebShaikh May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errors should be used to give the reason why the policy has failed without leaking any privileged information.

I see this pattern emerging

class OPADecision(..):
	...
	
	def _make_call_to_opa(endpoint,expected_result:Any=True,input:dict[str,str]):
		response = request.post(endpoint,input)
		
		(decision,error) = from response
		if decision == expected_result:
			return;
		if decision != expected_result:
			raise AuthZError(f"{error}")
	
	def delete_task(....):
		_make_call_to_opa(....)
		# successful authz
		return blueapi.delete_task()

This might be better than having exception handling in every func like this

	def delete_task(....):
		decision = _make_call_to_opa(....)
		if decision != True:
			raise AuthZError("Cannot delete this awesome task")
		if decision == True:
			return blueapi.delete_task()

Another example I can think of is when we were debugging numtracker and there was an extra “/” in the issuer, which caused JWT verification to fail. If we had received a clearer error message from OPA, the debugging process would have been much simpler.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would this go in the module if there end up being multiple rules? How would you distinguish between causes of errors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants