diff options
| author | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-10-05 07:34:26 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-10-05 07:34:26 +0000 |
| commit | 649ff6395bdca06530ceabd3e216c66851dc60d6 (patch) | |
| tree | 2bbe7008a8258b11ada120315fedff208d230206 /src | |
| parent | 693e7ee89f8618c1abbf8af5c0db23b071700803 (diff) | |
| download | genenetwork4-649ff6395bdca06530ceabd3e216c66851dc60d6.tar.gz | |
Rename /dev/token to /get-test-token; require a token everywhere
Rename: POST /dev/token -> POST /get-test-token (src/routes/dev.rs,
TestToken replacing DevToken), matching tests/get_test_token.rs and
test/python/test_get_test_token.py (renamed from
tests/dev_token.rs/test_dev_token.py). Config::dev_token_enabled() and
the GN_AUTH_DEV_* config keys keep their names -- they're about the
dev-token feature generically, not tied to this one route's path.
Every endpoint now requires a valid token, not just the
dataset_probeset*/traits* family: species(_by_name/_datasets),
groups(_by_name/_strains/_traits*/_datasets) and dataset_by_name all
gain an AuthToken parameter. /, /version, /openapi.json and
/get-test-token itself are the only exceptions -- a health check, a
version check, the spec describing all this, and the endpoint that
hands out a token in the first place (which would be circular if it
needed one).
Rather than repeating security(("bearer_token" = [])) on every
#[utoipa::path], ApiDoc now declares it once as the document's default
security(...), and the three exceptions besides /get-test-token (/,
/version) override it with their own empty security() -- standard
OpenAPI semantics (an operation's own security, even empty, overrides
the document default; an absent one inherits it). error::Unauthorized,
a new #[derive(utoipa::IntoResponses)] type wrapping ApiError, is the
shared 401 every gated handler now references bare in its own
responses(...) list instead of writing out the same
(status = 401, description = "...", body = ApiError) tuple by hand.
Verified the resolved security per operation in a live /openapi.json.
tests/common::auth_token() (Rust) and the new
test/python/auth_helpers.auth_token() (Python, deduplicating what four
files previously each defined locally) now try this server's own
POST /get-test-token first, falling back to GN4_TEST_AUTH_TOKEN --
every previously-ungated test file gains a token check and switches to
get_with_token; the whole suite, both languages, now runs with zero
manually-provisioned tokens given GENENETWORK4_DEV_MODE=true
GENENETWORK4_BIND=127.0.0.1 for the test run. ServerTestCase gains
EXTRA_ENV so each Python test class can start its own server with dev
mode on. Verified both configured (auto-fetch) and unconfigured
(GN4_TEST_AUTH_TOKEN fallback, and full skip when neither is set, e.g.
the Guix build sandbox) paths.
README.md, docs/gn-auth.md and RELEASE_NOTES.md updated throughout for
the rename and the new blanket token requirement.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XDDpXvZBQat9uSgDeEMJ8d
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.rs | 6 | ||||
| -rw-r--r-- | src/error.rs | 13 | ||||
| -rw-r--r-- | src/lib.rs | 20 | ||||
| -rw-r--r-- | src/routes/correlation.rs | 7 | ||||
| -rw-r--r-- | src/routes/datasets.rs | 13 | ||||
| -rw-r--r-- | src/routes/dev.rs | 27 | ||||
| -rw-r--r-- | src/routes/groups.rs | 17 | ||||
| -rw-r--r-- | src/routes/species.rs | 9 | ||||
| -rw-r--r-- | src/routes/traits.rs | 11 |
9 files changed, 88 insertions, 35 deletions
diff --git a/src/config.rs b/src/config.rs index 0f2df91..e8313a3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -26,7 +26,7 @@ pub struct Config { /// Address to bind the TCP listener to (see src/main.rs). Defaults /// to "0.0.0.0" (every interface); set to "127.0.0.1" to only /// accept local connections -- required, together with `dev_mode`, - /// for `dev_token_enabled()` to allow POST /dev/token (see + /// for `dev_token_enabled()` to allow POST /get-test-token (see /// src/routes/dev.rs). pub bind: String, /// Enables development-only endpoints when combined with a @@ -34,7 +34,7 @@ pub struct Config { /// this on in a deployment reachable from anywhere but localhost. pub dev_mode: bool, /// gn-auth OAuth2 client id/secret and dev user credentials used by - /// POST /dev/token's password-grant call. Default to gn-auth's own + /// POST /get-test-token's password-grant call. Default to gn-auth's own /// well-known development fixtures (`flask init-dev-clients`, /// `gn_auth/wsgi.py`), so this works against an unmodified dev /// gn-auth instance with no extra configuration. @@ -45,7 +45,7 @@ pub struct Config { } impl Config { - /// Whether POST /dev/token (src/routes/dev.rs) should be + /// Whether POST /get-test-token (src/routes/dev.rs) should be /// registered at all: `dev_mode` on, and `bind` resolves to a /// loopback address (127.0.0.1, ::1, ...) -- both set in config, /// per the feature's own requirement that it never be reachable diff --git a/src/error.rs b/src/error.rs index f96f44b..eb58918 100644 --- a/src/error.rs +++ b/src/error.rs @@ -65,3 +65,16 @@ impl IntoResponse for ApiError { (status, Json(self)).into_response() } } + +/// The 401 every token-gated endpoint can return, as one shared +/// `IntoResponses` type (an `ApiError` body under the hood) instead of +/// writing out `(status = 401, description = "...", body = ApiError)` +/// by hand on each `#[utoipa::path(...)]` -- reference it bare inside +/// `responses(...)`, e.g. `responses(Unauthorized, (status = 200, ...))`. +/// Which endpoints actually need it (i.e. take `AuthToken`) is still a +/// per-handler decision; this only removes the repetition in +/// documenting the one response shape that decision implies. +#[derive(utoipa::IntoResponses)] +#[response(status = 401, description = "Missing or invalid token")] +#[allow(dead_code)] // only ever used for its OpenAPI schema, never constructed +pub struct Unauthorized(#[to_schema] ApiError); diff --git a/src/lib.rs b/src/lib.rs index 84a143a..b1f004c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,12 +21,13 @@ use error::ApiError; title = "GeneNetwork4 API", description = "GeneNetwork4 REST API", license(name = "AGPL-3.0-or-later") -), modifiers(&SecurityAddon))] +), security(("bearer_token" = [])), modifiers(&SecurityAddon))] struct ApiDoc; -/// Registers the "bearer_token" scheme used by endpoints that require a -/// gn-auth token (see `security(...)` on their `#[utoipa::path]`, e.g. -/// `routes::datasets::dataset_probeset_info`). +/// Registers the "bearer_token" scheme `ApiDoc`'s own `security(...)` +/// (above) requires by default on every operation -- every endpoint +/// needs a token unless it opts out with its own empty `security()` +/// (`hello_world`, `version`, `routes::dev::get_test_token`: see each). struct SecurityAddon; impl utoipa::Modify for SecurityAddon { @@ -75,7 +76,7 @@ pub fn app() -> Router { // dev-mode server bound to loopback only. See // Config::dev_token_enabled and src/routes/dev.rs. if config::Config::load().dev_token_enabled() { - api_router = api_router.routes(routes!(routes::dev::dev_token)); + api_router = api_router.routes(routes!(routes::dev::get_test_token)); } let (router, api) = api_router.split_for_parts(); router @@ -93,11 +94,14 @@ fn request_id_string(request_id: &RequestId) -> Option<String> { } // hello_world and version predate the domain-module split and don't -// belong to a data domain; kept here as top-level utility routes. +// belong to a data domain; kept here as top-level utility routes. Both +// opt out of ApiDoc's default security requirement with an empty +// security() -- neither takes an AuthToken, so documenting them as +// needing one would be wrong, not just inconsistent. #[utoipa::path(get, path = "/", summary = "Greeting; confirms the server is up", responses( (status = 200, description = "Greeting", body = String), (status = 500, description = "Internal error", body = ApiError) -))] +), security())] async fn hello_world() -> &'static str { "Hello, world!" } @@ -115,7 +119,7 @@ struct VersionInfo { #[utoipa::path(get, path = "/version", summary = "Build information: version, git commit, commit date", responses( (status = 200, description = "Build information", body = VersionInfo), (status = 500, description = "Internal error", body = ApiError) -))] +), security())] async fn version() -> Json<VersionInfo> { Json(VersionInfo { name: "GeneNetwork4", diff --git a/src/routes/correlation.rs b/src/routes/correlation.rs index 3a74e15..df10c22 100644 --- a/src/routes/correlation.rs +++ b/src/routes/correlation.rs @@ -10,7 +10,8 @@ use axum::extract::Extension; use serde::{Deserialize, Serialize}; use tower_http::request_id::RequestId; -use crate::error::ApiError; +use crate::auth::AuthToken; +use crate::error::{ApiError, Unauthorized}; use crate::request_id_string; use crate::response::Envelope; @@ -38,10 +39,12 @@ Currently returns canned data wrapped in the descriptive envelope \ request_body = CorrelationRequest, responses( (status = 200, description = "Correlated traits, strongest first", body = Vec<CorrelationHit>), + Unauthorized, (status = 500, description = "Internal error", body = ApiError) -))] + ))] pub async fn correlation( Extension(request_id): Extension<RequestId>, + _token: AuthToken, Json(request): Json<CorrelationRequest>, ) -> Result<Json<Envelope<Vec<CorrelationHit>>>, ApiError> { // The stub accepts the request (and its request id, kept for the diff --git a/src/routes/datasets.rs b/src/routes/datasets.rs index 363f289..f7a3081 100644 --- a/src/routes/datasets.rs +++ b/src/routes/datasets.rs @@ -9,19 +9,21 @@ use tower_http::request_id::RequestId; use crate::auth::{self, AuthToken, VIEW_RESOURCE_PRIVILEGE}; use crate::config::Config; use crate::db; -use crate::error::ApiError; +use crate::error::{ApiError, Unauthorized}; use crate::request_id_string; #[utoipa::path(get, path = "/datasets/{dataset}", summary = "Get one expression dataset's full record by name or numeric id", params( ("dataset" = String, Path, description = "Dataset Name, Name2, FullName, ShortName or numeric Id") ), responses( (status = 200, description = "The matching row of the ProbeSetFreeze table", body = db::Dataset), + Unauthorized, (status = 404, description = "No matching dataset", body = ApiError), (status = 500, description = "Database error", body = ApiError) ))] pub async fn dataset_by_name( Extension(request_id): Extension<RequestId>, Path(dataset): Path<String>, + _token: AuthToken, ) -> Result<Json<db::Dataset>, ApiError> { let rid = request_id_string(&request_id); let not_found_name = dataset.clone(); @@ -96,11 +98,12 @@ fn get_dataset_probesets_result( ("dataset" = String, Path, description = "Dataset Name, Name2, FullName, ShortName or numeric Id") ), responses( (status = 200, description = "The probesets' ProbeSetXRef/ProbeSet metadata", body = Vec<db::ProbeSetInfo>), + Unauthorized, (status = 403, description = "The dataset isn't public, and the caller isn't authorized for it", body = ApiError), (status = 404, description = "No matching dataset", body = ApiError), (status = 500, description = "Database error", body = ApiError), (status = 502, description = "Could not reach gn-auth to check authorization", body = ApiError) -), security(("bearer_token" = [])))] +))] pub async fn dataset_probesets( Extension(request_id): Extension<RequestId>, Path(dataset): Path<String>, @@ -224,11 +227,12 @@ fn get_dataset_probeset_info_result( ("probeset" = String, Path, description = "ProbeSet.Name within the dataset") ), responses( (status = 200, description = "The probeset's ProbeSetXRef/ProbeSet metadata", body = db::ProbeSetInfo), + Unauthorized, (status = 403, description = "The dataset isn't public, and the caller isn't authorized for it", body = ApiError), (status = 404, description = "No matching dataset, or no matching probeset in that dataset", body = ApiError), (status = 500, description = "Database error", body = ApiError), (status = 502, description = "Could not reach gn-auth to check authorization", body = ApiError) -), security(("bearer_token" = [])))] +))] pub async fn dataset_probeset_info( Extension(request_id): Extension<RequestId>, Path((dataset, probeset)): Path<(String, String)>, @@ -337,11 +341,12 @@ fn get_dataset_probeset_values_result( ("probeset" = String, Path, description = "ProbeSet.Name within the dataset") ), responses( (status = 200, description = "The dataset's per-strain values for the probeset", body = Vec<db::ProbeSetValue>), + Unauthorized, (status = 403, description = "The dataset isn't public, and the caller isn't authorized for it", body = ApiError), (status = 404, description = "No matching dataset, or no matching probeset in that dataset", body = ApiError), (status = 500, description = "Database error", body = ApiError), (status = 502, description = "Could not reach gn-auth to check authorization", body = ApiError) -), security(("bearer_token" = [])))] +))] pub async fn dataset_probeset_values( Extension(request_id): Extension<RequestId>, Path((dataset, probeset)): Path<(String, String)>, diff --git a/src/routes/dev.rs b/src/routes/dev.rs index 04e88e4..7b490cc 100644 --- a/src/routes/dev.rs +++ b/src/routes/dev.rs @@ -10,7 +10,8 @@ //! that led to this file): this endpoint must never exist on a server //! reachable from anywhere but localhost, since any caller who can //! reach it gets a token for gn-auth's own published, publicly-known -//! dev credentials. +//! dev credentials. It's also the one endpoint in this API that must +//! NOT itself require a token -- that would be circular. use axum::Json; use axum::extract::Extension; @@ -26,7 +27,7 @@ use crate::request_id_string; /// grant -- just the fields a caller actually needs to use it (see /// AuthToken in src/auth.rs), not gn-auth's full token response. #[derive(Serialize, utoipa::ToSchema)] -pub struct DevToken { +pub struct TestToken { pub access_token: String, pub token_type: String, pub scope: String, @@ -39,17 +40,19 @@ struct TokenResponse { scope: String, } -#[utoipa::path(post, path = "/dev/token", summary = "Development only: obtain a real gn-auth token for gn-auth's own dev user", responses( - (status = 200, description = "A bearer token for gn-auth's well-known development user", body = DevToken), +#[utoipa::path(post, path = "/get-test-token", summary = "Development only: obtain a real gn-auth token for gn-auth's own dev user", responses( + (status = 200, description = "A bearer token for gn-auth's well-known development user", body = TestToken), (status = 500, description = "Internal error", body = ApiError), (status = 502, description = "Could not obtain a token from gn-auth", body = ApiError) -))] -pub async fn dev_token( +// Opts out of ApiDoc's default security requirement: this is the one +// endpoint that must NOT need a token already (that would be circular). +), security())] +pub async fn get_test_token( Extension(request_id): Extension<RequestId>, -) -> Result<Json<DevToken>, ApiError> { +) -> Result<Json<TestToken>, ApiError> { let rid = request_id_string(&request_id); let config = Config::load(); - tokio::task::spawn_blocking(move || fetch_dev_token(&config)) + tokio::task::spawn_blocking(move || fetch_test_token(&config)) .await .map_err(|e| { ApiError::new( @@ -57,7 +60,7 @@ pub async fn dev_token( "internal_error", "Internal error", e.to_string(), - "dev_token", + "get_test_token", ) .with_request_id(rid.clone()) })? @@ -68,13 +71,13 @@ pub async fn dev_token( "auth_server_error", "Could not obtain a token from gn-auth", e, - "dev_token", + "get_test_token", ) .with_request_id(rid) }) } -fn fetch_dev_token(config: &Config) -> Result<DevToken, String> { +fn fetch_test_token(config: &Config) -> Result<TestToken, String> { let url = format!( "{}/auth/token", config.auth_server_url.trim_end_matches('/') @@ -92,7 +95,7 @@ fn fetch_dev_token(config: &Config) -> Result<DevToken, String> { .body_mut() .read_json() .map_err(|e| format!("parsing token response from {url}: {e}"))?; - Ok(DevToken { + Ok(TestToken { access_token: response.access_token, token_type: response.token_type, scope: response.scope, diff --git a/src/routes/groups.rs b/src/routes/groups.rs index a27f8b2..51f12cc 100644 --- a/src/routes/groups.rs +++ b/src/routes/groups.rs @@ -6,16 +6,19 @@ use axum::extract::{Extension, Path, Query}; use axum::http::StatusCode; use tower_http::request_id::RequestId; +use crate::auth::AuthToken; use crate::db; -use crate::error::ApiError; +use crate::error::{ApiError, Unauthorized}; use crate::request_id_string; #[utoipa::path(get, path = "/groups", summary = "List all groups (populations; InbredSet rows)", responses( (status = 200, description = "All groups (InbredSet rows) in the database", body = Vec<db::Group>), + Unauthorized, (status = 500, description = "Database error", body = ApiError) ))] pub async fn groups( Extension(request_id): Extension<RequestId>, + _token: AuthToken, ) -> Result<Json<Vec<db::Group>>, ApiError> { let rid = request_id_string(&request_id); tokio::task::spawn_blocking(db::get_all_groups) @@ -47,12 +50,14 @@ pub async fn groups( ("group" = String, Path, description = "Group InbredSetName, Name, FullName or numeric Id") ), responses( (status = 200, description = "The matching row of the InbredSet table", body = db::GroupDetail), + Unauthorized, (status = 404, description = "No matching group", body = ApiError), (status = 500, description = "Database error", body = ApiError) ))] pub async fn group_by_name( Extension(request_id): Extension<RequestId>, Path(group): Path<String>, + _token: AuthToken, ) -> Result<Json<db::GroupDetail>, ApiError> { let rid = request_id_string(&request_id); let not_found_name = group.clone(); @@ -102,6 +107,7 @@ pub struct GroupStrainsParams { ("used_for_mapping" = Option<bool>, Query, description = "Only strains/samples used for mapping") ), responses( (status = 200, description = "The strains/samples belonging to the group", body = Vec<db::Strain>), + Unauthorized, (status = 404, description = "No matching group", body = ApiError), (status = 500, description = "Database error", body = ApiError) ))] @@ -109,6 +115,7 @@ pub async fn group_strains( Extension(request_id): Extension<RequestId>, Path(group): Path<String>, Query(params): Query<GroupStrainsParams>, + _token: AuthToken, ) -> Result<Json<Vec<db::Strain>>, ApiError> { let rid = request_id_string(&request_id); let not_found_name = group.clone(); @@ -185,12 +192,14 @@ fn get_group_trait_values_result( ("trait_id" = u32, Path, description = "PublishXRef.Id of a published (phenotype) trait") ), responses( (status = 200, description = "The group's per-strain values for the trait", body = Vec<db::TraitValue>), + Unauthorized, (status = 404, description = "No matching group, or no matching trait in that group", body = ApiError), (status = 500, description = "Database error", body = ApiError) ))] pub async fn group_trait_values( Extension(request_id): Extension<RequestId>, Path((group, trait_id)): Path<(String, u32)>, + _token: AuthToken, ) -> Result<Json<Vec<db::TraitValue>>, ApiError> { let rid = request_id_string(&request_id); let not_found_group = group.clone(); @@ -256,12 +265,14 @@ fn get_group_trait_info_result( ("trait_id" = u32, Path, description = "PublishXRef.Id of a published (phenotype) trait") ), responses( (status = 200, description = "The trait's PublishXRef/Phenotype/Publication metadata", body = db::TraitInfo), + Unauthorized, (status = 404, description = "No matching group, or no matching trait in that group", body = ApiError), (status = 500, description = "Database error", body = ApiError) ))] pub async fn group_trait_info( Extension(request_id): Extension<RequestId>, Path((group, trait_id)): Path<(String, u32)>, + _token: AuthToken, ) -> Result<Json<db::TraitInfo>, ApiError> { let rid = request_id_string(&request_id); let not_found_group = group.clone(); @@ -313,12 +324,14 @@ pub async fn group_trait_info( ("group" = String, Path, description = "Group InbredSetName, Name, FullName or numeric Id") ), responses( (status = 200, description = "The published traits belonging to the group", body = Vec<db::TraitInfo>), + Unauthorized, (status = 404, description = "No matching group", body = ApiError), (status = 500, description = "Database error", body = ApiError) ))] pub async fn group_traits( Extension(request_id): Extension<RequestId>, Path(group): Path<String>, + _token: AuthToken, ) -> Result<Json<Vec<db::TraitInfo>>, ApiError> { let rid = request_id_string(&request_id); let not_found_name = group.clone(); @@ -367,12 +380,14 @@ pub async fn group_traits( ("group" = String, Path, description = "Group InbredSetName, Name, FullName or numeric Id") ), responses( (status = 200, description = "The expression (ProbeSet) datasets belonging to the group", body = Vec<db::Dataset>), + Unauthorized, (status = 404, description = "No matching group", body = ApiError), (status = 500, description = "Database error", body = ApiError) ))] pub async fn group_datasets( Extension(request_id): Extension<RequestId>, Path(group): Path<String>, + _token: AuthToken, ) -> Result<Json<Vec<db::Dataset>>, ApiError> { let rid = request_id_string(&request_id); let not_found_name = group.clone(); diff --git a/src/routes/species.rs b/src/routes/species.rs index bb8794e..35d149e 100644 --- a/src/routes/species.rs +++ b/src/routes/species.rs @@ -5,16 +5,19 @@ use axum::extract::{Extension, Path}; use axum::http::StatusCode; use tower_http::request_id::RequestId; +use crate::auth::AuthToken; use crate::db; -use crate::error::ApiError; +use crate::error::{ApiError, Unauthorized}; use crate::request_id_string; #[utoipa::path(get, path = "/species", summary = "List all species in the database", responses( (status = 200, description = "All species in the database", body = Vec<db::Species>), + Unauthorized, (status = 500, description = "Database error", body = ApiError) ))] pub async fn species( Extension(request_id): Extension<RequestId>, + _token: AuthToken, ) -> Result<Json<Vec<db::Species>>, ApiError> { let rid = request_id_string(&request_id); // mysql's Conn is blocking; run it on a blocking thread so it doesn't @@ -48,12 +51,14 @@ pub async fn species( ("species" = String, Path, description = "Species Name, FullName or SpeciesName") ), responses( (status = 200, description = "The matching row of the Species table", body = db::SpeciesDetail), + Unauthorized, (status = 404, description = "No matching species", body = ApiError), (status = 500, description = "Database error", body = ApiError) ))] pub async fn species_by_name( Extension(request_id): Extension<RequestId>, Path(species): Path<String>, + _token: AuthToken, ) -> Result<Json<db::SpeciesDetail>, ApiError> { let rid = request_id_string(&request_id); let not_found_name = species.clone(); @@ -97,12 +102,14 @@ pub async fn species_by_name( ("species" = String, Path, description = "Species Name, FullName or SpeciesName") ), responses( (status = 200, description = "The expression (ProbeSet) datasets belonging to the species", body = Vec<db::Dataset>), + Unauthorized, (status = 404, description = "No matching species", body = ApiError), (status = 500, description = "Database error", body = ApiError) ))] pub async fn species_datasets( Extension(request_id): Extension<RequestId>, Path(species): Path<String>, + _token: AuthToken, ) -> Result<Json<Vec<db::Dataset>>, ApiError> { let rid = request_id_string(&request_id); let not_found_name = species.clone(); diff --git a/src/routes/traits.rs b/src/routes/traits.rs index 811387e..880d60d 100644 --- a/src/routes/traits.rs +++ b/src/routes/traits.rs @@ -21,7 +21,7 @@ use tower_http::request_id::RequestId; use crate::auth::{self, AuthToken, VIEW_RESOURCE_PRIVILEGE}; use crate::config::Config; use crate::db; -use crate::error::ApiError; +use crate::error::{ApiError, Unauthorized}; use crate::request_id_string; /// One trait's metadata, tagged by which category its dataset resolved @@ -148,11 +148,12 @@ fn get_traits_result( ("dataset" = String, Path, description = "ProbeSetFreeze Name/Name2/FullName/ShortName/Id, or PublishFreeze Name/ShortName/Id, or (for Publish data) the owning group's Name/InbredSetName/FullName/Id") ), responses( (status = 200, description = "Every trait in the dataset, tagged by category", body = Vec<TraitInfoResponse>), + Unauthorized, (status = 403, description = "The dataset isn't public, and the caller isn't authorized for it", body = ApiError), (status = 404, description = "No matching dataset", body = ApiError), (status = 500, description = "Database error", body = ApiError), (status = 502, description = "Could not reach gn-auth to check authorization", body = ApiError) -), security(("bearer_token" = [])))] +))] pub async fn traits( Extension(request_id): Extension<RequestId>, Path(dataset): Path<String>, @@ -283,11 +284,12 @@ fn get_trait_info_result( ("trait" = String, Path, description = "ProbeSet.Name (ProbeSet category) or PublishXRef.Id (Publish category)") ), responses( (status = 200, description = "The trait's metadata, tagged by category", body = TraitInfoResponse), + Unauthorized, (status = 403, description = "The dataset isn't public, and the caller isn't authorized for it", body = ApiError), (status = 404, description = "No matching dataset, or no matching trait in that dataset", body = ApiError), (status = 500, description = "Database error", body = ApiError), (status = 502, description = "Could not reach gn-auth to check authorization", body = ApiError) -), security(("bearer_token" = [])))] +))] pub async fn trait_info( Extension(request_id): Extension<RequestId>, Path((dataset, trait_name)): Path<(String, String)>, @@ -438,11 +440,12 @@ fn get_trait_values_result( ("trait" = String, Path, description = "ProbeSet.Name (ProbeSet category) or PublishXRef.Id (Publish category)") ), responses( (status = 200, description = "The trait's per-strain values", body = Vec<db::TraitValue>), + Unauthorized, (status = 403, description = "The dataset isn't public, and the caller isn't authorized for it", body = ApiError), (status = 404, description = "No matching dataset, or no matching trait in that dataset", body = ApiError), (status = 500, description = "Database error", body = ApiError), (status = 502, description = "Could not reach gn-auth to check authorization", body = ApiError) -), security(("bearer_token" = [])))] +))] pub async fn trait_values( Extension(request_id): Extension<RequestId>, Path((dataset, trait_name)): Path<(String, String)>, |
