chore: Fix most clippy issue, format & typos

This commit is contained in:
Jade Ellis 2025-05-10 13:29:31 +01:00 committed by nexy7574
commit d7b48a0f7c
No known key found for this signature in database
GPG key ID: 0FA334385D0B689F
19 changed files with 369 additions and 409 deletions

View file

@ -1,22 +1,20 @@
use oxide_auth::primitives::prelude::Client;
use axum::{
Json,
extract::State,
};
use axum::{Json, extract::State};
use conduwuit::{Result, err};
use ruma::DeviceId;
use oxide_auth::primitives::prelude::Client;
use reqwest::Url;
use ruma::DeviceId;
/// The required parameters to register a new client for OAuth2 application.
#[derive(serde::Deserialize, Clone)]
pub(crate) struct ClientQuery {
/// Human-readable name.
client_name: String,
/// A public page that tells more about the client. All other links must be within.
client_uri: Url,
client_name: String,
/// A public page that tells more about the client. All other links must be
/// within.
client_uri: Url,
/// Redirect URIs declared by the client. At least one.
redirect_uris: Vec<Url>,
/// Must be ["code"].
/// Must be `["code"]`.
response_types: Vec<String>,
/// Must include "authorization_type" and "refresh_token".
grant_types: Vec<String>,
@ -51,8 +49,9 @@ pub(crate) struct ClientResponse {
/// # `GET /_matrix/client/unstable/org.matrix.msc2964/device/register`
///
/// Register a client, as specified in [MSC2966]. This client, "device" in OIDC parlance,
/// will have the right to submit [super::authorize::authorize] requests.
/// Register a client, as specified in [MSC2966]. This client, "device" in OIDC
/// parlance, will have the right to submit [super::authorize::authorize]
/// requests.
///
/// [MSC2966]: https://github.com/matrix-org/matrix-spec-proposals/pull/2966
pub(crate) async fn register_client(
@ -66,15 +65,17 @@ pub(crate) async fn register_client(
};
let device_id = DeviceId::new();
let scope = format!(
"urn:matrix:org.matrix.msc2967.client:api:* urn:matrix:org.matrix.msc2967.client:device:{}",
device_id
"urn:matrix:org.matrix.msc2967.client:api:* \
urn:matrix:org.matrix.msc2967.client:device:{device_id}"
);
// TODO check if the users service needs an update.
//services.users.update_device_metadata();
services.oidc.register_client(&Client::public(
&device_id.to_string(),
device_id.as_ref(),
redirect_uri.into(),
scope.parse().expect("device ID should parse in Matrix scope"),
scope
.parse()
.expect("device ID should parse in Matrix scope"),
))?;
Ok(Json(ClientResponse {
@ -88,6 +89,6 @@ pub(crate) async fn register_client(
token_endpoint_auth_method: client.token_endpoint_auth_method.clone(),
response_types: client.response_types.clone(),
grant_types: client.grant_types.clone(),
application_type: client.application_type.clone(),
application_type: client.application_type,
}))
}