use ic_auth_protocol_types::{AuthRole, DelegatedRoleGrant, ScopeLabel};
pub(crate) fn for_role<'a>(
grants: &'a [DelegatedRoleGrant],
role: &AuthRole,
) -> Option<&'a DelegatedRoleGrant> {
grants
.binary_search_by(|grant| grant.target.cmp(role))
.ok()
.map(|index| &grants[index])
}
pub(crate) fn scopes_subset(wanted: &[ScopeLabel], allowed: &[ScopeLabel]) -> bool {
wanted == allowed
|| wanted
.iter()
.all(|scope| allowed.binary_search(scope).is_ok())
}