Skip to content

Header policy #152

@sigmavirus24

Description

@sigmavirus24

Working on a toy project that might turn into something open source eventually, I've been using jose to deal with JWS and JWK. One thing I'm looking for is a way to enforce a header is only sent as protected (or unprotected) and/or that no headers were sent unprotected. Right now, for every header I want to look up that isn't a standard header I'm doing something along the lines of

match header.additional("header") {
  Some(HeaderValue::Protected(serde_json::Value::String(v))) => Ok(v),
  Some(HeaderValue::Protected(_)) => Err(HeaderError::InvalidHeaderTypeFor("header")),
  Some(HeaderValue::Unprotected(_)) => Err(HeaderError::UnprotectedHeader("header")),
  None => Err(HeaderError::MissingHeader("header")),
}

With enough values this is cumbersome. The policies around JWKs is nice... if not entirely what I was looking for there, so I was wondering if a similar policy logic could be introduced for jose::header. I saw that jose::policy moved to jose::jwk::policy since 0.0.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions