File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
crates/crates_io_trustpub/src/github
src/controllers/trustpub/tokens/exchange Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ pub struct GitHubClaims {
25
25
pub repository : String ,
26
26
pub workflow_ref : String ,
27
27
pub environment : Option < String > ,
28
+ pub run_id : String ,
29
+ pub sha : String ,
28
30
}
29
31
30
32
impl GitHubClaims {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use super::json;
2
2
use crate :: app:: AppState ;
3
3
use crate :: util:: errors:: { AppResult , bad_request, server_error} ;
4
4
use axum:: Json ;
5
- use crates_io_database:: models:: trustpub:: { NewToken , NewUsedJti } ;
5
+ use crates_io_database:: models:: trustpub:: { NewToken , NewUsedJti , TrustpubData } ;
6
6
use crates_io_database:: schema:: trustpub_configs_github;
7
7
use crates_io_diesel_helpers:: lower;
8
8
use crates_io_trustpub:: access_token:: AccessToken ;
@@ -130,11 +130,17 @@ pub async fn exchange_trustpub_token(
130
130
131
131
let new_token = AccessToken :: generate ( ) ;
132
132
133
+ let trustpub_data = TrustpubData :: GitHub {
134
+ repository : signed_claims. repository ,
135
+ run_id : signed_claims. run_id ,
136
+ sha : signed_claims. sha ,
137
+ } ;
138
+
133
139
let new_token_model = NewToken {
134
140
expires_at : chrono:: Utc :: now ( ) + chrono:: Duration :: minutes ( 30 ) ,
135
141
hashed_token : & new_token. sha256 ( ) ,
136
142
crate_ids : & crate_ids,
137
- trustpub_data : None ,
143
+ trustpub_data : Some ( & trustpub_data ) ,
138
144
} ;
139
145
140
146
new_token_model. insert ( conn) . await ?;
You can’t perform that action at this time.
0 commit comments