GitHubProject#

class gafaelfawr.models.github_project.GitHubProject(*, id, template=None, description=None, requested_by=None, username, repository, repository_id, repository_owner_id, workflow=None, environment=None, ref=None, scopes, max_lifetime, uid=None, gid=None, groups=None, enabled, created, created_by, modified, modified_by)#

Bases: BaseModel

A registered GitHub project.

Parameters:

Attributes Summary

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

workflow_path

Workflow as a full path, as in the job_workflow_ref claim.

Methods Summary

matches(claims)

Whether a GitHub Actions ID token satisfies this project.

overlaps(other)

Whether a GitHub Actions ID token could match both projects.

Attributes Documentation

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

workflow_path#

Workflow as a full path, as in the job_workflow_ref claim.

A workflow given as .github/workflows/<file> is prefixed with the project repository, and one given as a full <owner>/<repo>/.github/workflows/<file> path is used as is. The repository part is lowercased, since repository names are matched case-insensitively, but the path part is not.

Methods Documentation

matches(claims)#

Whether a GitHub Actions ID token satisfies this project.

A token matches when the project is enabled and every constraint the project sets is satisfied: the repository claim equals the project repository (case-insensitively) and the repository_id and repository_owner_id claims equal the pinned IDs; if a workflow is set, the path part of job_workflow_ref equals it; if an environment is set, the environment claim equals it; and if a ref is set, the ref claim equals it or, when the ref ends in /, starts with it. Unset constraints match anything.

Parameters:

claims (GitHubActionsClaims) – Claims of the verified token.

Returns:

True if the token satisfies every constraint of the project.

Return type:

bool

overlaps(other)#

Whether a GitHub Actions ID token could match both projects.

Two projects overlap when they are for the same repository and, for each of workflow, environment, and ref, the constraint is unset in at least one of them, the values are equal, or one ref is a prefix of the other.

Parameters:

other (GitHubProjectCreate | Self) – Project to compare against, with its repository in the form GitHub reports it.

Returns:

True if some token could satisfy the constraints of both.

Return type:

bool