remove stale dependency oxide-auth-axum

This commit is contained in:
lafleur 2025-05-09 12:08:12 +02:00 committed by nexy7574
commit 67e5869e43
No known key found for this signature in database
GPG key ID: 0FA334385D0B689F
9 changed files with 102 additions and 72 deletions

View file

@ -91,7 +91,6 @@ sha1.workspace = true
tokio.workspace = true
tracing.workspace = true
oxide-auth.workspace = true
oxide-auth-axum.workspace = true
conduwuit-web.workspace = true
percent-encoding.workspace = true

View file

@ -1,5 +1,4 @@
use conduwuit_web::oidc::{oidc_consent_form, oidc_login_form, AuthorizationQuery, OidcRequest, OidcResponse};
use oxide_auth_axum::{OAuthResponse, OAuthRequest};
use oxide_auth::{
endpoint::{OwnerConsent, Solicitation},
frontends::simple::endpoint::FnSolicitor,
@ -78,8 +77,8 @@ pub(crate) struct Allowance {
pub(crate) async fn authorize_consent(
Query(Allowance { allow }): Query<Allowance>,
State(services): State<crate::State>,
oauth: OAuthRequest,
) -> Result<OAuthResponse> {
oauth: OidcRequest,
) -> Result<OidcResponse> {
let allowed = allow.unwrap_or(false);
tracing::debug!("processing user's consent: {:?} - {:?}", allowed, oauth);

View file

@ -1,10 +1,7 @@
use oxide_auth_axum::{OAuthResponse, OAuthRequest};
use oxide_auth::endpoint::QueryParameter;
use axum::{
extract::State,
response::IntoResponse,
};
use conduwuit_web::oidc::{OidcRequest, OidcResponse};
use conduwuit::{Result, err};
use oxide_auth::endpoint::QueryParameter;
use axum::extract::State;
/// # `POST /_matrix/client/unstable/org.matrix.msc2964/token`
///
@ -12,8 +9,8 @@ use conduwuit::{Result, err};
/// it in the server's ring, or refresh the token.
pub(crate) async fn token(
State(services): State<crate::State>,
oauth: OAuthRequest,
) -> Result<OAuthResponse> {
oauth: OidcRequest,
) -> Result<OidcResponse> {
let Some(body) = oauth.body() else {
return Err(err!(Request(Unknown("OAuth request had an empty body"))));
};
@ -37,36 +34,3 @@ pub(crate) async fn token(
Err(err!(Request(Unknown("unsupported grant type: {other:?}")))),
}
}
/// Sample protected content. TODO check that resources are available with the returned token.
pub(crate) async fn _protected_resource(
State(services): State<crate::State>,
oauth: OAuthRequest,
) -> impl IntoResponse {
const DENY_TEXT: &str = "<html>
This page should be accessed via an oauth token from the client in the example. Click
<a href=\"/authorize?response_type=code&client_id=LocalClient\">
here</a> to begin the authorization process.
</html>
";
let protect = services
.oidc
.endpoint()
.with_scopes(vec!["default-scope".parse().unwrap()])
.resource_flow()
.execute(oauth);
match protect {
Ok(_grant) => Ok("Hello, world"),
Err(Ok(response)) => {
let error: OAuthResponse = response
//.header(ContentType::HTML)
.body(DENY_TEXT)
//.finalize()
.into();
Err(Ok(error))
}
Err(Err(err)) => Err(Err(err!(Request(Unknown("auth failed: {err:?}"))))),
}
}