Skip to content

Commit c8488f7

Browse files
committed
OpenAPI: Add trustpub_token security scheme
1 parent 8465b56 commit c8488f7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/openapi.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crates_io_session::COOKIE_NAME;
22
use http::header;
3-
use utoipa::openapi::security::{ApiKey, ApiKeyValue, SecurityScheme};
3+
use utoipa::openapi::security::{ApiKey, ApiKeyValue, Http, HttpAuthScheme, SecurityScheme};
44
use utoipa::{Modify, OpenApi};
55
use utoipa_axum::router::OpenApiRouter;
66

@@ -72,6 +72,14 @@ impl Modify for SecurityAddon {
7272
"The API token is used to authenticate requests from cargo and other clients.";
7373
let api_token = ApiKey::Header(ApiKeyValue::with_description(name, description));
7474
components.add_security_scheme("api_token", SecurityScheme::ApiKey(api_token));
75+
76+
let description = "Temporary access tokens are used by the \"Trusted Publishing\" flow.";
77+
let trustpub_token = Http::builder()
78+
.scheme(HttpAuthScheme::Bearer)
79+
.description(Some(description))
80+
.build();
81+
82+
components.add_security_scheme("trustpub_token", SecurityScheme::Http(trustpub_token));
7583
}
7684
}
7785

src/snapshots/crates_io__openapi__tests__openapi_snapshot.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,11 @@ expression: response.json()
12521252
"in": "cookie",
12531253
"name": "cargo_session",
12541254
"type": "apiKey"
1255+
},
1256+
"trustpub_token": {
1257+
"description": "Temporary access tokens are used by the \"Trusted Publishing\" flow.",
1258+
"scheme": "bearer",
1259+
"type": "http"
12551260
}
12561261
}
12571262
},

0 commit comments

Comments
 (0)