GitHubActionsTokenVerifier#

class gafaelfawr.services.github_actions.GitHubActionsTokenVerifier(config, jwks_cache, http_client, logger)#

Bases: object

Verify an ID token issued by GitHub to a GitHub Actions job.

Parameters:
  • config (GitHubTokenExchangeConfig) – GitHub Actions token exchange configuration.

  • jwks_cache (JWKSCache) – Process-wide cache of GitHub’s signing keys.

  • http_client (AsyncClient) – Session to use to make HTTP requests.

  • logger (BoundLogger) – Logger for any log messages.

Methods Summary

verify_token(encoded)

Verify a GitHub Actions ID token and return its claims.

Methods Documentation

async verify_token(encoded)#

Verify a GitHub Actions ID token and return its claims.

The token must be signed with RS256 by a key in GitHub’s JWKS, have the GitHub Actions issuer, carry the configured audience, and be within its validity window. A small clock skew is allowed when checking the exp, nbf, and iat claims. It must also contain every claim that the project registry matches on.

Parameters:

encoded (str) – Encoded ID token.

Returns:

Claims from the verified token.

Return type:

GitHubActionsClaims

Raises:
  • jwt.exceptions.InvalidTokenError – Raised if the token is malformed, has the wrong issuer or audience, is outside its validity window, or has an invalid signature.

  • FetchKeysError – Raised if GitHub’s key data is syntactically invalid or contains no usable keys.

  • GitHubWebError – Raised if unable to retrieve signing keys from GitHub.

  • InvalidTokenClaimsError – Raised if the token is missing a required claim or a claim has an invalid format.

  • UnknownAlgorithmError – Raised if the token uses an algorithm other than RS256.

  • UnknownKeyIdError – Raised if the token does not name a key ID or names one that is not in GitHub’s key set, even after refreshing the keys.