Skip to content

Commit

Permalink
add oauth errors as strum enum
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Dec 7, 2024
1 parent af4f6da commit 441f190
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/komainu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ http.workspace = true
serde.workspace = true
serde_urlencoded.workspace = true
sonic-rs.workspace = true
strum.workspace = true
thiserror.workspace = true
tracing.workspace = true

Expand Down
13 changes: 13 additions & 0 deletions lib/komainu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extern crate tracing;
use bytes::Bytes;
use std::collections::HashSet;
use std::{borrow::Cow, future::Future};
use strum::AsRefStr;

pub use self::error::{Error, Result};
pub use self::params::ParamStorage;
Expand Down Expand Up @@ -49,6 +50,18 @@ pub struct AuthorizerExtractor<CE> {
client_extractor: CE,
}

#[derive(AsRefStr)]
#[strum(serialize_all = "snake_case")]
pub enum OAuthError {
InvalidRequest,
UnauthorizedClient,
AccessDenied,
UnsupportedResponseType,
InvalidScope,
ServerError,
TemporarilyUnavailable,
}

#[inline]
fn get_from_either<'a>(
key: &str,
Expand Down

0 comments on commit 441f190

Please sign in to comment.