Struct GithubJWKS

Source
pub struct GithubJWKS {
    pub keys: Vec<JWK>,
}
Expand description

Represents a set of JSON Web Keys (JWKS) used for GitHub token validation.

This structure is crucial for GitHub Actions authentication because:

  1. GitHub Key Rotation: GitHub rotates its keys for security, and having multiple keys allows your application to validate tokens continuously during these changes.

  2. Multiple Environments: Different GitHub environments (like production and development) might use different keys. A set of keys allows your app to work across these environments.

  3. Fallback Mechanism: If one key fails for any reason, your app can try others in the set.

Think of it like a key ring for a building manager. They don’t just carry one key, but a set of keys for different doors or areas.

Fields§

§keys: Vec<JWK>

Vector of JSON Web Keys

Implementations§

Source§

impl GithubJWKS

Source

pub fn validate_github_token( &self, token: &str, config: &GitHubOIDCConfig, ) -> Result<GitHubClaims, GitHubOIDCError>

Validates a GitHub OIDC token against the provided JSON Web Key Set (JWKS).

This method performs several checks:

  1. Verifies the token format.
  2. Decodes the token header to find the key ID (kid).
  3. Locates the corresponding key in the JWKS.
  4. Validates the token signature and claims.
  5. Optionally checks the token’s audience.
  6. Verifies the token’s organization and repository claims against environment variables.
§Arguments
  • token - The GitHub OIDC token to validate.
  • jwks - An Arc<RwLock<GithubJWKS>> containing the JSON Web Key Set.
  • config - A GitHubOIDCConfig struct containing validation options.
  • expected_audience - An optional expected audience for the token.
§Returns

Returns a Result<GitHubClaims, GitHubOIDCError> containing the validated claims if successful, or an error if validation fails.

Trait Implementations§

Source§

impl Debug for GithubJWKS

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for GithubJWKS

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for GithubJWKS

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,