trellis_auth/error.rs
1use std::io;
2
3/// Errors returned by Trellis auth and admin-session helpers.
4#[derive(Debug, thiserror::Error)]
5pub enum TrellisAuthError {
6 /// The supplied contract JSON could not be parsed.
7 #[error("invalid contract json: {0}")]
8 ContractJson(#[from] serde_json::Error),
9
10 /// A configured auth or callback URL was invalid.
11 #[error("invalid url: {0}")]
12 Url(#[from] url::ParseError),
13
14 /// The HTTP transport used for browser login or bind requests failed.
15 #[error("http client error: {0}")]
16 Http(#[from] reqwest::Error),
17
18 /// Local filesystem persistence or callback listener I/O failed.
19 #[error("io error: {0}")]
20 Io(#[from] io::Error),
21
22 /// The underlying Trellis RPC client returned an error.
23 #[error("trellis client error: {0}")]
24 TrellisClient(#[from] trellis_client::TrellisClientError),
25
26 /// The browser login callback never arrived before the timeout.
27 #[error("timed out waiting for browser login")]
28 LoginTimedOut,
29
30 /// The local browser login callback listener shut down before completion.
31 #[error("browser login was interrupted")]
32 LoginInterrupted,
33
34 /// The local callback request was missing the expected query or fragment shape.
35 #[error("invalid callback request")]
36 InvalidCallbackRequest,
37
38 /// The callback completed without returning an auth token.
39 #[error("missing auth token in callback")]
40 MissingAuthToken,
41
42 /// The auth service returned a terminal flow error.
43 #[error("auth flow failed: {0}")]
44 AuthFlowFailed(String),
45
46 /// The low-level bind endpoint returned a non-success HTTP response.
47 #[error("bind failed: {0} {1}")]
48 BindHttpFailure(u16, String),
49
50 /// The bind endpoint returned a response shape this crate does not understand.
51 #[error("unexpected bind status: {0}")]
52 UnexpectedBindStatus(String),
53
54 /// The caller supplied arguments that violate the Trellis auth invariants.
55 #[error("invalid argument: {0}")]
56 InvalidArgument(String),
57
58 /// A helper wrapped operation finished without a usable successful result.
59 #[error("operation failed: {0}")]
60 OperationFailed(String),
61
62 /// A workload activation wait request returned a non-success HTTP response.
63 #[error("workload activation wait failed: {0} {1}")]
64 WorkloadActivationWaitFailure(u16, String),
65
66 /// Workload activation was explicitly rejected.
67 #[error("workload activation rejected{0}")]
68 WorkloadActivationRejected(String),
69
70 /// The authenticated user completed login successfully but lacks admin capability.
71 #[error("logged in user is not an admin")]
72 NotAdmin,
73}