Skip to content

Commit 4005d53

Browse files
committed
introspection: introduce errors for personal sessions
1 parent 3756fb8 commit 4005d53

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

crates/handlers/src/oauth2/introspection.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ pub enum RouteError {
9393
#[error("unknown compat session {0}")]
9494
CantLoadCompatSession(Ulid),
9595

96+
/// The personal access token session is not valid.
97+
#[error("invalid personal access token session {0}")]
98+
InvalidPersonalSession(Ulid),
99+
100+
/// The personal access token session could not be found in the database.
101+
#[error("unknown personal access token session {0}")]
102+
CantLoadPersonalSession(Ulid),
103+
96104
/// The Device ID in the compat session can't be encoded as a scope
97105
#[error("device ID contains characters that are not allowed in a scope")]
98106
CantEncodeDeviceID(#[from] mas_data_model::ToScopeTokenError),
@@ -103,6 +111,9 @@ pub enum RouteError {
103111
#[error("unknown user {0}")]
104112
CantLoadUser(Ulid),
105113

114+
#[error("unknown OAuth2 client {0}")]
115+
CantLoadOAuth2Client(Ulid),
116+
106117
#[error("bad request")]
107118
BadRequest,
108119

@@ -131,7 +142,9 @@ impl IntoResponse for RouteError {
131142
e @ (Self::Internal(_)
132143
| Self::CantLoadCompatSession(_)
133144
| Self::CantLoadOAuthSession(_)
145+
| Self::CantLoadPersonalSession(_)
134146
| Self::CantLoadUser(_)
147+
| Self::CantLoadOAuth2Client(_)
135148
| Self::FailedToVerifyToken(_)) => (
136149
StatusCode::INTERNAL_SERVER_ERROR,
137150
Json(
@@ -167,6 +180,7 @@ impl IntoResponse for RouteError {
167180
| Self::InvalidUser(_)
168181
| Self::InvalidCompatSession(_)
169182
| Self::InvalidOAuthSession(_)
183+
| Self::InvalidPersonalSession(_)
170184
| Self::InvalidTokenFormat(_)
171185
| Self::CantEncodeDeviceID(_) => {
172186
INTROSPECTION_COUNTER.add(1, &[KeyValue::new(ACTIVE.clone(), false)]);

0 commit comments

Comments
 (0)