@@ -12,7 +12,8 @@ use crate::storage::{Storage, StorageConfig};
12
12
use axum:: extract:: { FromRef , FromRequestParts , State } ;
13
13
use bon:: Builder ;
14
14
use crates_io_github:: GitHubClient ;
15
- use crates_io_trustpub:: keystore:: OidcKeyStore ;
15
+ use crates_io_trustpub:: github:: GITHUB_ISSUER_URL ;
16
+ use crates_io_trustpub:: keystore:: { OidcKeyStore , RealOidcKeyStore } ;
16
17
use deadpool_diesel:: Runtime ;
17
18
use derive_more:: Deref ;
18
19
use diesel_async:: AsyncPgConnection ;
@@ -94,6 +95,36 @@ impl<S: app_builder::State> AppBuilder<S> {
94
95
self . github_oauth ( github_oauth)
95
96
}
96
97
98
+ /// Set the "Trusted Publishing" providers supported by the application.
99
+ ///
100
+ /// This method configures the OIDC key stores for the specified providers
101
+ /// and expects a list of provider names as input.
102
+ ///
103
+ /// Currently, only "github" is supported as a provider.
104
+ pub fn trustpub_providers (
105
+ self ,
106
+ providers : & [ String ] ,
107
+ ) -> AppBuilder < app_builder:: SetOidcKeyStores < S > >
108
+ where
109
+ S :: OidcKeyStores : app_builder:: IsUnset ,
110
+ {
111
+ let mut key_stores: HashMap < String , Box < dyn OidcKeyStore > > = HashMap :: new ( ) ;
112
+
113
+ for provider in providers {
114
+ match provider. as_str ( ) {
115
+ "github" => {
116
+ let key_store = RealOidcKeyStore :: new ( GITHUB_ISSUER_URL . into ( ) ) ;
117
+ key_stores. insert ( GITHUB_ISSUER_URL . into ( ) , Box :: new ( key_store) ) ;
118
+ }
119
+ provider => {
120
+ warn ! ( "Unknown Trusted Publishing provider: {provider}" ) ;
121
+ }
122
+ }
123
+ }
124
+
125
+ self . oidc_key_stores ( key_stores)
126
+ }
127
+
97
128
pub fn databases_from_config (
98
129
self ,
99
130
config : & config:: DatabasePools ,
0 commit comments