Skip to content

Commit 68645bb

Browse files
committed
trustpub: Improve "Unsupported JWT issuer" error message
1 parent a895d9b commit 68645bb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/controllers/trustpub/tokens/exchange/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ pub async fn exchange_trustpub_token(
3838

3939
let unverified_issuer = unverified_token_data.claims.iss;
4040
let Some(keystore) = state.oidc_key_stores.get(&unverified_issuer) else {
41-
return Err(bad_request("Unsupported JWT issuer"));
41+
let error = format!("Unsupported JWT issuer: {unverified_issuer}");
42+
return Err(bad_request(error));
4243
};
4344

4445
let Some(unverified_key_id) = unverified_token_data.header.kid else {
@@ -60,7 +61,8 @@ pub async fn exchange_trustpub_token(
6061
// The following code is only supporting GitHub Actions for now, so let's
6162
// drop out if the issuer is not GitHub.
6263
if unverified_issuer != GITHUB_ISSUER_URL {
63-
return Err(bad_request("Unsupported JWT issuer"));
64+
let error = format!("Unsupported JWT issuer: {unverified_issuer}");
65+
return Err(bad_request(error));
6466
}
6567

6668
let audience = &state.config.trustpub_audience;

src/controllers/trustpub/tokens/exchange/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ async fn test_unsupported_issuer() -> anyhow::Result<()> {
157157
let body = default_claims().as_exchange_body()?;
158158
let response = client.post::<()>(URL, body).await;
159159
assert_snapshot!(response.status(), @"400 Bad Request");
160-
assert_snapshot!(response.json(), @r#"{"errors":[{"detail":"Unsupported JWT issuer"}]}"#);
160+
assert_snapshot!(response.json(), @r#"{"errors":[{"detail":"Unsupported JWT issuer: https://token.actions.githubusercontent.com"}]}"#);
161161

162162
Ok(())
163163
}

0 commit comments

Comments
 (0)