All checks were successful
Run Check Script / check (pull_request) Successful in 2m17s
27 lines
971 B
Rust
27 lines
971 B
Rust
use anyhow::{Context, Result};
|
|
use harmony_fleet_auth::{CredentialSource, CredentialsSection, NatsCredential};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
let key_path = std::env::var("ZITADEL_KEY_PATH").context("ZITADEL_KEY_PATH missing")?;
|
|
let issuer = std::env::var("ZITADEL_ISSUER").context("ZITADEL_ISSUER missing")?;
|
|
let audience = std::env::var("ZITADEL_PROJECT_ID").context("ZITADEL_PROJECT_ID missing")?;
|
|
|
|
let source =
|
|
CredentialSource::credential_source_from_config(&CredentialsSection::ZitadelJwt {
|
|
key_path: key_path.into(),
|
|
key_json: None,
|
|
oidc_issuer_url: issuer,
|
|
audience,
|
|
danger_accept_invalid_certs: false,
|
|
})?;
|
|
|
|
match source.next_credential().await? {
|
|
NatsCredential::BearerToken(token) => {
|
|
println!("{token}");
|
|
Ok(())
|
|
}
|
|
NatsCredential::UserPass { .. } => anyhow::bail!("expected bearer token"),
|
|
}
|
|
}
|