summaryrefslogtreecommitdiff
path: root/src/authorization/cedar_authorizer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/authorization/cedar_authorizer.rs')
-rw-r--r--src/authorization/cedar_authorizer.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/authorization/cedar_authorizer.rs b/src/authorization/cedar_authorizer.rs
index c6b886ec..ceaee51c 100644
--- a/src/authorization/cedar_authorizer.rs
+++ b/src/authorization/cedar_authorizer.rs
@@ -74,11 +74,16 @@ impl CedarAuthorizer {
fn principal_from(
&self,
- _http_request: &envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest,
+ http_request: &envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest,
) -> Result<cedar_policy::EntityUid, Box<dyn std::error::Error>> {
+ let subject = http_request
+ .headers
+ .get("x-jwt-claim-sub")
+ .map_or("", |v| v);
+
Ok(cedar_policy::EntityUid::from_type_name_and_id(
cedar_policy::EntityTypeName::from_str("User")?,
- cedar_policy::EntityId::from_str("client")?,
+ cedar_policy::EntityId::from_str(subject)?,
))
}