Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions .github/workflows/sign-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Sign Commits with OIDC Machine Identity

on:
push:
branches: [main]
paths-ignore:
- '**.md'
- 'docs/**'
- 'LICENSE*'
- '.gitignore'

permissions:
contents: write
id-token: read

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings

jobs:
sign-commits:
name: Sign Commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- uses: dtolnay/rust-toolchain@stable

- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build auths-cli
run: cargo build --release -p auths_cli
continue-on-error: false

- name: Configure Git
run: |
git config --global user.name "auths-ci"
git config --global user.email "auths-ci@example.com"

- name: Sign commits with OIDC machine identity
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set +e # Don't exit on error; we want to log and continue

# Build auths binary path
AUTHS_BIN="./target/release/auths"

# Get the list of new commits in this push
# For the first push (no HEAD@{1}), use all commits in main
if git rev-parse "HEAD@{1}" >/dev/null 2>&1; then
COMMIT_RANGE="HEAD@{1}..HEAD"
else
COMMIT_RANGE="HEAD"
fi

echo "Commits to sign:"
git rev-list $COMMIT_RANGE

# For each commit, initialize OIDC machine identity and sign
while IFS= read -r commit_sha; do
echo ""
echo "=========================================="
echo "Signing commit: $commit_sha"
echo "=========================================="

# Initialize machine identity from OIDC token
echo "Setting up OIDC machine identity..."
if ! $AUTHS_BIN init --profile ci 2>/dev/null; then
echo "⚠️ Warning: Failed to initialize OIDC machine identity for $commit_sha"
continue
fi

# Sign the commit
echo "Signing commit with machine identity..."
if ! $AUTHS_BIN sign-commit "$commit_sha" 2>&1 | tee sign-output.txt; then
echo "⚠️ Warning: Failed to sign commit $commit_sha"
echo "Continuing with next commit..."
continue
fi

# Display attestation for debugging
echo ""
echo "Attestation structure:"
if git show "refs/auths/commits/$commit_sha" 2>/dev/null; then
echo "✓ Attestation stored successfully"
else
echo "⚠️ Warning: Could not retrieve attestation for $commit_sha"
fi

done < <(git rev-list $COMMIT_RANGE)

echo ""
echo "=========================================="
echo "Commit signing complete"
echo "=========================================="

- name: Push attestation refs
if: always()
run: |
set +e

# Push all attestation refs to origin
echo "Pushing attestation refs to origin..."
if git push origin 'refs/auths/commits/*:refs/auths/commits/*' 2>&1; then
echo "✓ Attestation refs pushed successfully"
else
echo "⚠️ Warning: Failed to push attestation refs (may not exist yet)"
fi

# Also push KERI refs if they exist
if git show-ref | grep -q "refs/keri"; then
git push origin 'refs/keri/*:refs/keri/*' 2>&1 || echo "⚠️ Failed to push KERI refs"
fi

- name: Summary
if: always()
run: |
echo "Commit signing workflow completed"
echo "View signed commits: git log --oneline -10"
echo "View attestations: git show refs/auths/commits/<commit-sha>"
echo "Verify attestation: ./target/release/auths verify-commit <commit-sha>"
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ repos:

- id: cargo-fmt
name: cargo fmt
entry: bash -c 'cargo fmt --all && cargo fmt --all --manifest-path packages/auths-node/Cargo.toml && cargo fmt --all --manifest-path packages/auths-python/Cargo.toml'
entry: cargo fmt --all
language: system
types: [rust]
pass_filenames: false

- id: cargo-clippy
name: cargo clippy
entry: bash -c 'SQLX_OFFLINE=true cargo clippy --all-targets --all-features -- -D warnings && CARGO_TARGET_DIR=../../target cargo clippy --manifest-path packages/auths-node/Cargo.toml --all-targets -- -D warnings && CARGO_TARGET_DIR=../../target cargo clippy --manifest-path packages/auths-python/Cargo.toml --all-targets -- -D warnings'
entry: cargo clippy --all-targets --all-features -- -D warnings
language: system
types: [rust]
pass_filenames: false
Expand Down
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ members = [
"crates/auths-radicle",
"crates/auths-scim",
"crates/auths-utils",
"crates/auths-oidc-port",
"crates/xtask",
]

Expand Down
1 change: 1 addition & 0 deletions crates/auths-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ nix = { version = "0.29", features = ["signal", "process"] }

[dev-dependencies]
auths-crypto = { workspace = true, features = ["test-utils"] }
auths-verifier = { workspace = true, features = ["test-utils"] }
assert_cmd = "2"
tempfile = "3"
predicates = "2"
Expand Down
2 changes: 2 additions & 0 deletions crates/auths-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::commands::org::OrgCommand;
use crate::commands::policy::PolicyCommand;
use crate::commands::scim::ScimCommand;
use crate::commands::sign::SignCommand;
use crate::commands::sign_commit::SignCommitCommand;
use crate::commands::signers::SignersCommand;
use crate::commands::status::StatusCommand;
use crate::commands::trust::TrustCommand;
Expand Down Expand Up @@ -93,6 +94,7 @@ pub struct AuthsCli {
pub enum RootCommand {
Init(InitCommand),
Sign(SignCommand),
SignCommit(SignCommitCommand),
Verify(UnifiedVerifyCommand),
Status(StatusCommand),
Whoami(WhoamiCommand),
Expand Down
1 change: 1 addition & 0 deletions crates/auths-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub mod policy;
pub mod provision;
pub mod scim;
pub mod sign;
pub mod sign_commit;
pub mod signers;
pub mod status;
pub mod trust;
Expand Down
Loading
Loading