8000 Add `PUT /api/v1/trusted_publishing/tokens` API endpoint by Turbo87 · Pull Request #11131 · rust-lang/crates.io · GitHub
[go: up one dir, main page]

Skip to content

Add PUT /api/v1/trusted_publishing/tokens API endpoint #11131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jun 2, 2025
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
AppBuilder: Add trustpub_providers() fn
  • Loading branch information
Turbo87 committed Jun 2, 2025
commit 98e79e4b3a6a8a2f834ab3cb2d4b74eb868a94a5
33 changes: 32 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use crate::storage::{Storage, StorageConfig};
use axum::extract::{FromRef, FromRequestParts, State};
use bon::Builder;
use crates_io_github::GitHubClient;
use crates_io_trustpub::keystore::OidcKeyStore;
use crates_io_trustpub::github::GITHUB_ISSUER_URL;
use crates_io_trustpub::keystore::{OidcKeyStore, RealOidcKeyStore};
use deadpool_diesel::Runtime;
use derive_more::Deref;
use diesel_async::AsyncPgConnection;
Expand Down Expand Up @@ -94,6 +95,36 @@ impl<S: app_builder::State> AppBuilder<S> {
self.github_oauth(github_oauth)
}

/// Set the "Trusted Publishing" providers supported by the application.
///
/// This method configures the OIDC key stores for the specified providers
/// and expects a list of provider names as input.
///
/// Currently, only "github" is supported as a provider.
pub fn trustpub_providers(
self,
providers: &[String],
) -> AppBuilder<app_builder::SetOidcKeyStores<S>>
where
S::OidcKeyStores: app_builder::IsUnset,
{
let mut key_stores: HashMap<String, Box<dyn OidcKeyStore>> = HashMap::new();

for provider in providers {
match provider.as_str() {
"github" => {
let key_store = RealOidcKeyStore::new(GITHUB_ISSUER_URL.into());
key_stores.insert(GITHUB_ISSUER_URL.into(), Box::new(key_store));
}
provider => {
warn!("Unknown Trusted Publishing provider: {provider}");
}
}
}

self.oidc_key_stores(key_stores)
}

pub fn databases_from_config(
self,
config: &config::DatabasePools,
Expand Down
0