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:
-
GitHub Key Rotation: GitHub rotates its keys for security, and having multiple keys allows your application to validate tokens continuously during these changes.
-
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.
-
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
impl GithubJWKS
Sourcepub fn validate_github_token(
&self,
token: &str,
config: &GitHubOIDCConfig,
) -> Result<GitHubClaims, GitHubOIDCError>
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:
- Verifies the token format.
- Decodes the token header to find the key ID (kid).
- Locates the corresponding key in the JWKS.
- Validates the token signature and claims.
- Optionally checks the token’s audience.
- Verifies the token’s organization and repository claims against environment variables.
§Arguments
token
- The GitHub OIDC token to validate.jwks
- AnArc<RwLock<GithubJWKS>>
containing the JSON Web Key Set.config
- AGitHubOIDCConfig
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.