#ci #credentials #oidc #ambient #systems #detection #token

ci-id

Ambient OIDC credentials detection on CI systems

6 releases

0.3.0 Dec 3, 2024
0.2.1 Nov 5, 2024
0.1.2 Oct 29, 2024

#645 in Authentication


Used in ci-id-bin

Apache-2.0

24KB
492 lines

Ambient credentials detection for CI systems

CI badge

ci-id provides easy access to ambient OIDC credentials in CI systems.

use ci_id::{detect_credentials, CIIDError};

fn main() -> Result<(), CIIDError>  {
    let token = detect_credentials(Some("myaudience"))?;
    print!("Ambient OIDC token detected: {}", token);
    Ok(())
}

See ci-id-bin crate for a simple CLI wrapper.

ci-id is based on id, a similar Python project.

Supported environments

Currently supported environments are:

  • GitHub Actions
  • GitLab CI/CD
  • CircleCI
  • Buildkite

See documentation for details on what configuration each of these environments needs.

License

ci-id is licensed under the Apache 2.0 License.


lib.rs:

ci-id provides easy access to ambient OIDC credentials in CI systems like GitHub Actions.

match ci_id::detect_credentials(Some("my-audience")) {
    Ok(token) => println!("{}", token),
    Err(e) => eprintln!("{}", e)
}

Environment specific setup

Typically the CI environment needs to allow OIDC identity access.

GitHub Actions

Workflow must be given the permission to use the workflow identity:

permissions:
    id-token: write

GitLab Pipelines

An ID token must be defined in the pipeline:

id_tokens:
    MY_AUDIENCE_ID_TOKEN:
        aud: my-audience

The ID token name must be based on the audience so that token name is <AUD>_ID_TOKEN where <AUD> is the audience string sanitized for environment variable names (uppercased and all characters outside of ascii letters and digits are replaced with "_").

CircleCI

No configuration is needed.

Buildkite

No configuration is needed.

Dependencies

~6–19MB
~251K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy