Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/controllers/trustpub/tokens/revoke/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod tests;
#[utoipa::path(
delete,
path = "/api/v1/trusted_publishing/tokens",
security(("trustpub_token" = [])),
tag = "trusted_publishing",
responses((status = 204, description = "Successful Response")),
)]
Expand Down
10 changes: 9 additions & 1 deletion src/openapi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crates_io_session::COOKIE_NAME;
use http::header;
use utoipa::openapi::security::{ApiKey, ApiKeyValue, SecurityScheme};
use utoipa::openapi::security::{ApiKey, ApiKeyValue, Http, HttpAuthScheme, SecurityScheme};
use utoipa::{Modify, OpenApi};
use utoipa_axum::router::OpenApiRouter;

Expand Down Expand Up @@ -72,6 +72,14 @@ impl Modify for SecurityAddon {
"The API token is used to authenticate requests from cargo and other clients.";
let api_token = ApiKey::Header(ApiKeyValue::with_description(name, description));
components.add_security_scheme("api_token", SecurityScheme::ApiKey(api_token));

let description = "Temporary access tokens are used by the \"Trusted Publishing\" flow.";
let trustpub_token = Http::builder()
.scheme(HttpAuthScheme::Bearer)
.description(Some(description))
.build();

components.add_security_scheme("trustpub_token", SecurityScheme::Http(trustpub_token));
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/snapshots/crates_io__openapi__tests__openapi_snapshot.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,11 @@ expression: response.json()
"in": "cookie",
"name": "cargo_session",
"type": "apiKey"
},
"trustpub_token": {
"description": "Temporary access tokens are used by the \"Trusted Publishing\" flow.",
"scheme": "bearer",
"type": "http"
}
}
},
Expand Down Expand Up @@ -4310,6 +4315,11 @@ expression: response.json()
"description": "Successful Response"
}
},
"security": [
{
"trustpub_token": []
}
],
"summary": "Revoke a temporary access token.",
"tags": [
"trusted_publishing"
Expand Down