-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into aumetra/case-insensitive-usernames
- Loading branch information
Showing
20 changed files
with
363 additions
and
172 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "kitsune-oidc" | ||
edition.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] | ||
async-trait = "0.1.74" | ||
deadpool-redis = "0.13.0" | ||
enum_dispatch = "0.3.12" | ||
http = "0.2.9" | ||
hyper = "0.14.27" | ||
kitsune-config = { path = "../kitsune-config" } | ||
kitsune-http-client = { path = "../kitsune-http-client" } | ||
moka = { version = "0.12.1", features = ["sync"] } | ||
once_cell = "1.18.0" | ||
openidconnect = { version = "3.4.0", default-features = false, features = [ | ||
# Accept these two, per specification invalid, cases to increase compatibility | ||
"accept-rfc3339-timestamps", | ||
"accept-string-booleans", | ||
] } | ||
redis = "0.23.3" | ||
serde = { version = "1.0.190", features = ["derive"] } | ||
simd-json = "0.13.4" | ||
speedy-uuid = { path = "../../lib/speedy-uuid", features = ["serde"] } | ||
thiserror = "1.0.50" | ||
url = "2.4.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use openidconnect::{ | ||
core::CoreErrorResponseType, ClaimsVerificationError, DiscoveryError, RequestTokenError, | ||
SigningError, StandardErrorResponse, | ||
}; | ||
use thiserror::Error; | ||
|
||
pub type Result<T, E = Error> = std::result::Result<T, E>; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
ClaimsVerification(#[from] ClaimsVerificationError), | ||
|
||
#[error(transparent)] | ||
CreateRedisPool(#[from] deadpool_redis::CreatePoolError), | ||
|
||
#[error(transparent)] | ||
Discovery(#[from] DiscoveryError<kitsune_http_client::Error>), | ||
|
||
#[error(transparent)] | ||
JsonParse(#[from] simd_json::Error), | ||
|
||
#[error("Missing Email address")] | ||
MissingEmail, | ||
|
||
#[error("Mismatching hash")] | ||
MismatchingHash, | ||
|
||
#[error("Missing ID token")] | ||
MissingIdToken, | ||
|
||
#[error("Missing login state")] | ||
MissingLoginState, | ||
|
||
#[error("Missing username")] | ||
MissingUsername, | ||
|
||
#[error(transparent)] | ||
Redis(#[from] redis::RedisError), | ||
|
||
#[error(transparent)] | ||
RedisPool(#[from] deadpool_redis::PoolError), | ||
|
||
#[error(transparent)] | ||
RequestToken( | ||
#[from] | ||
RequestTokenError< | ||
kitsune_http_client::Error, | ||
StandardErrorResponse<CoreErrorResponseType>, | ||
>, | ||
), | ||
|
||
#[error(transparent)] | ||
Signing(#[from] SigningError), | ||
|
||
#[error("Unknown CSRF token")] | ||
UnknownCsrfToken, | ||
|
||
#[error(transparent)] | ||
UrlParse(#[from] url::ParseError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use http::Request; | ||
use hyper::Body; | ||
use kitsune_http_client::Client as HttpClient; | ||
use once_cell::sync::Lazy; | ||
use openidconnect::{HttpRequest, HttpResponse}; | ||
|
||
static HTTP_CLIENT: Lazy<HttpClient> = Lazy::new(HttpClient::default); | ||
|
||
pub async fn async_client(req: HttpRequest) -> Result<HttpResponse, kitsune_http_client::Error> { | ||
let mut request = Request::builder().method(req.method).uri(req.url.as_str()); | ||
*request.headers_mut().unwrap() = req.headers; | ||
let request = request.body(Body::from(req.body)).unwrap(); | ||
let response = HTTP_CLIENT.execute(request).await?; | ||
|
||
Ok(HttpResponse { | ||
status_code: response.status(), | ||
headers: response.headers().clone(), | ||
body: response.bytes().await?.to_vec(), | ||
}) | ||
} |
Oops, something went wrong.