#[derive(serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum Visibility {
Internal,
Private,
Public,
#[serde(untagged)]
Other(String),
}
#[derive(serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum RunnerEnvironment {
GithubHosted,
SelfHosted,
#[serde(untagged)]
Other(String),
}
#[derive(serde::Serialize, serde::Deserialize, PartialEq, Clone, Debug)]
pub struct Claims {
pub aud: String,
pub iss: String,
pub sub: String,
pub exp: f64,
pub iat: f64,
pub jti: String,
pub nbf: f64,
pub actor: String,
pub actor_id: String,
pub base_ref: String,
pub environment: Option<String>,
pub event_name: String,
pub head_ref: String,
pub job_workflow_ref: Option<String>,
pub job_workflow_sha: Option<String>,
#[serde(rename = "ref")]
pub git_ref: String,
pub ref_type: String,
pub repository_visibility: Visibility,
pub repository: String,
pub repository_id: String,
pub repository_owner: String,
pub repository_owner_id: String,
pub run_id: String,
pub run_number: String,
pub run_attempt: String,
pub runner_environment: RunnerEnvironment,
pub workflow: String,
pub workflow_ref: String,
pub workflow_sha: String,
}
impl Claims {
pub fn make_dummy() -> Self {
Self {
aud: "".into(),
iss: "".into(),
sub: "".into(),
exp: 33247274880f64,
iat: 1690366107f64,
jti: "".into(),
nbf: 1690366107f64,
actor: "".into(),
actor_id: "".into(),
base_ref: "".into(),
environment: None,
event_name: "".into(),
head_ref: "".into(),
job_workflow_ref: None,
job_workflow_sha: None,
git_ref: "refs/heads/main".into(),
ref_type: "branch".into(),
repository_visibility: Visibility::Public,
repository: "".into(),
repository_id: "".into(),
repository_owner: "".into(),
repository_owner_id: "".into(),
run_id: "".into(),
run_number: "".into(),
run_attempt: "1".into(),
runner_environment: RunnerEnvironment::GithubHosted,
workflow: "".into(),
workflow_ref: "".into(),
workflow_sha: "".into(),
}
}
}