You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-06 06:02:40 +03:00
Fix recently added Clippy lints
This also ignores the clippy::blocks_in_conditions lint in two crates, until tracing gets fixed: https://github.com/tokio-rs/tracing/issues/2876
This commit is contained in:
@@ -694,7 +694,7 @@ impl Options {
|
|||||||
})
|
})
|
||||||
.await??;
|
.await??;
|
||||||
|
|
||||||
req.upstream_provider_mappings.push((&provider, subject));
|
req.upstream_provider_mappings.push((provider, subject));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ pub enum EmailSmtpMode {
|
|||||||
/// Plain text
|
/// Plain text
|
||||||
Plain,
|
Plain,
|
||||||
|
|
||||||
/// StartTLS (starts as plain text then upgrade to TLS)
|
/// `StartTLS` (starts as plain text then upgrade to TLS)
|
||||||
StartTls,
|
StartTls,
|
||||||
|
|
||||||
/// TLS
|
/// TLS
|
||||||
@@ -94,7 +94,7 @@ pub struct EmailConfig {
|
|||||||
hostname: Option<String>,
|
hostname: Option<String>,
|
||||||
|
|
||||||
/// SMTP transport: Port to connect to. Default is 25 for plain, 465 for TLS
|
/// SMTP transport: Port to connect to. Default is 25 for plain, 465 for TLS
|
||||||
/// and 587 for StartTLS
|
/// and 587 for `StartTLS`
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[schemars(range(min = 1, max = 65535))]
|
#[schemars(range(min = 1, max = 65535))]
|
||||||
port: Option<NonZeroU16>,
|
port: Option<NonZeroU16>,
|
||||||
|
@@ -336,7 +336,7 @@ pub struct ListenerConfig {
|
|||||||
/// List of sockets to bind
|
/// List of sockets to bind
|
||||||
pub binds: Vec<BindConfig>,
|
pub binds: Vec<BindConfig>,
|
||||||
|
|
||||||
/// Accept HAProxy's Proxy Protocol V1
|
/// Accept `HAProxy`'s Proxy Protocol V1
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub proxy_protocol: bool,
|
pub proxy_protocol: bool,
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@ pub struct Client {
|
|||||||
/// Array of Redirection URI values used by the Client
|
/// Array of Redirection URI values used by the Client
|
||||||
pub redirect_uris: Vec<Url>,
|
pub redirect_uris: Vec<Url>,
|
||||||
|
|
||||||
/// Array containing a list of the OAuth 2.0 response_type values that the
|
/// Array containing a list of the OAuth 2.0 `response_type` values that the
|
||||||
/// Client is declaring that it will restrict itself to using
|
/// Client is declaring that it will restrict itself to using
|
||||||
pub response_types: Vec<OAuthAuthorizationEndpointResponseType>,
|
pub response_types: Vec<OAuthAuthorizationEndpointResponseType>,
|
||||||
|
|
||||||
@@ -83,15 +83,15 @@ pub struct Client {
|
|||||||
/// Client
|
/// Client
|
||||||
pub id_token_signed_response_alg: Option<JsonWebSignatureAlg>,
|
pub id_token_signed_response_alg: Option<JsonWebSignatureAlg>,
|
||||||
|
|
||||||
/// JWS alg algorithm REQUIRED for signing UserInfo Responses.
|
/// JWS alg algorithm REQUIRED for signing `UserInfo` Responses.
|
||||||
pub userinfo_signed_response_alg: Option<JsonWebSignatureAlg>,
|
pub userinfo_signed_response_alg: Option<JsonWebSignatureAlg>,
|
||||||
|
|
||||||
/// Requested authentication method for the token endpoint
|
/// Requested authentication method for the token endpoint
|
||||||
pub token_endpoint_auth_method: Option<OAuthClientAuthenticationMethod>,
|
pub token_endpoint_auth_method: Option<OAuthClientAuthenticationMethod>,
|
||||||
|
|
||||||
/// JWS alg algorithm that MUST be used for signing the JWT used to
|
/// JWS alg algorithm that MUST be used for signing the JWT used to
|
||||||
/// authenticate the Client at the Token Endpoint for the private_key_jwt
|
/// authenticate the Client at the Token Endpoint for the `private_key_jwt`
|
||||||
/// and client_secret_jwt authentication methods
|
/// and `client_secret_jwt` authentication methods
|
||||||
pub token_endpoint_auth_signing_alg: Option<JsonWebSignatureAlg>,
|
pub token_endpoint_auth_signing_alg: Option<JsonWebSignatureAlg>,
|
||||||
|
|
||||||
/// URI using the https scheme that a third party can use to initiate a
|
/// URI using the https scheme that a third party can use to initiate a
|
||||||
|
@@ -148,13 +148,6 @@ impl UserAgent {
|
|||||||
result.os_version = VALUE_UNKNOWN.into();
|
result.os_version = VALUE_UNKNOWN.into();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like
|
|
||||||
// Gecko) Chrome/100.0.4896.133 Safari/537.36
|
|
||||||
("Mac OSX", "10.15.7") if user_agent.contains("Macintosh; Intel Mac OS X 10_15_7") => {
|
|
||||||
result.os = "macOS";
|
|
||||||
result.os_version = VALUE_UNKNOWN.into();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
|
// Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
|
||||||
// Chrome/100.0.0.0 Safari/537.36
|
// Chrome/100.0.0.0 Safari/537.36
|
||||||
("Linux", _) if user_agent.contains("X11; Linux x86_64") => {
|
("Linux", _) if user_agent.contains("X11; Linux x86_64") => {
|
||||||
@@ -176,6 +169,8 @@ impl UserAgent {
|
|||||||
result.os_version = VALUE_UNKNOWN.into();
|
result.os_version = VALUE_UNKNOWN.into();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like
|
||||||
|
// Gecko) Chrome/100.0.4896.133 Safari/537.36
|
||||||
// Safari also freezes the OS version
|
// Safari also freezes the OS version
|
||||||
// Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like
|
// Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like
|
||||||
// Gecko) Version/17.3.1 Safari/605.1.15
|
// Gecko) Version/17.3.1 Safari/605.1.15
|
||||||
|
@@ -32,7 +32,7 @@ use thiserror::Error;
|
|||||||
pub enum SmtpMode {
|
pub enum SmtpMode {
|
||||||
/// Plain text
|
/// Plain text
|
||||||
Plain,
|
Plain,
|
||||||
/// StartTLS (starts as plain text then upgrade to TLS)
|
/// `StartTLS` (starts as plain text then upgrade to TLS)
|
||||||
StartTls,
|
StartTls,
|
||||||
/// TLS
|
/// TLS
|
||||||
Tls,
|
Tls,
|
||||||
|
@@ -51,7 +51,7 @@ pub enum Requester {
|
|||||||
/// The requester is a browser session, stored in a cookie.
|
/// The requester is a browser session, stored in a cookie.
|
||||||
BrowserSession(Box<BrowserSession>),
|
BrowserSession(Box<BrowserSession>),
|
||||||
|
|
||||||
/// The requester is a OAuth2 session, with an access token.
|
/// The requester is a `OAuth2` session, with an access token.
|
||||||
OAuth2Session(Box<(Session, Option<User>)>),
|
OAuth2Session(Box<(Session, Option<User>)>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use axum::{extract::State, response::IntoResponse, Json, TypedHeader};
|
use axum::{extract::State, response::IntoResponse, Json, TypedHeader};
|
||||||
use chrono::{DateTime, Duration, Utc};
|
use chrono::Duration;
|
||||||
use headers::{CacheControl, HeaderMap, HeaderMapExt, Pragma};
|
use headers::{CacheControl, HeaderMap, HeaderMapExt, Pragma};
|
||||||
use hyper::StatusCode;
|
use hyper::StatusCode;
|
||||||
use mas_axum_utils::{
|
use mas_axum_utils::{
|
||||||
@@ -46,33 +46,13 @@ use oauth2_types::{
|
|||||||
},
|
},
|
||||||
scope,
|
scope,
|
||||||
};
|
};
|
||||||
use serde::Serialize;
|
|
||||||
use serde_with::{serde_as, skip_serializing_none};
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use ulid::Ulid;
|
use ulid::Ulid;
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
use super::{generate_id_token, generate_token_pair};
|
use super::{generate_id_token, generate_token_pair};
|
||||||
use crate::{impl_from_error_for_route, BoundActivityTracker};
|
use crate::{impl_from_error_for_route, BoundActivityTracker};
|
||||||
|
|
||||||
#[serde_as]
|
|
||||||
#[skip_serializing_none]
|
|
||||||
#[derive(Serialize, Debug)]
|
|
||||||
struct CustomClaims {
|
|
||||||
#[serde(rename = "iss")]
|
|
||||||
issuer: Url,
|
|
||||||
#[serde(rename = "sub")]
|
|
||||||
subject: String,
|
|
||||||
#[serde(rename = "aud")]
|
|
||||||
audiences: Vec<String>,
|
|
||||||
nonce: Option<String>,
|
|
||||||
#[serde_as(as = "Option<serde_with::TimestampSeconds>")]
|
|
||||||
auth_time: Option<DateTime<Utc>>,
|
|
||||||
at_hash: String,
|
|
||||||
c_hash: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub(crate) enum RouteError {
|
pub(crate) enum RouteError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
|
@@ -100,10 +100,7 @@ impl PasswordManager {
|
|||||||
///
|
///
|
||||||
/// Returns an error if the password manager is disabled
|
/// Returns an error if the password manager is disabled
|
||||||
fn get_inner(&self) -> Result<Arc<InnerPasswordManager>, PasswordManagerDisabledError> {
|
fn get_inner(&self) -> Result<Arc<InnerPasswordManager>, PasswordManagerDisabledError> {
|
||||||
self.inner
|
self.inner.clone().ok_or(PasswordManagerDisabledError)
|
||||||
.as_ref()
|
|
||||||
.map(Arc::clone)
|
|
||||||
.ok_or(PasswordManagerDisabledError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hash a password with the default hashing scheme.
|
/// Hash a password with the default hashing scheme.
|
||||||
|
@@ -76,7 +76,7 @@ pub(crate) enum RouteError {
|
|||||||
#[error("Template {template:?} rendered to an empty string")]
|
#[error("Template {template:?} rendered to an empty string")]
|
||||||
RequiredAttributeEmpty { template: String },
|
RequiredAttributeEmpty { template: String },
|
||||||
|
|
||||||
/// Required claim was missing in id_token
|
/// Required claim was missing in `id_token`
|
||||||
#[error("Template {template:?} could not be rendered from the upstream provider's response for required claim")]
|
#[error("Template {template:?} could not be rendered from the upstream provider's response for required claim")]
|
||||||
RequiredAttributeRender {
|
RequiredAttributeRender {
|
||||||
template: String,
|
template: String,
|
||||||
|
@@ -275,10 +275,7 @@ impl Tree {
|
|||||||
path: I,
|
path: I,
|
||||||
) -> Option<&Node> {
|
) -> Option<&Node> {
|
||||||
let mut iterator = path.into_iter();
|
let mut iterator = path.into_iter();
|
||||||
let Some(next) = iterator.next() else {
|
let next = iterator.next()?;
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
self.walk_path_inner(next, iterator)
|
self.walk_path_inner(next, iterator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -98,6 +98,8 @@ impl Display for File {
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#![allow(clippy::doc_markdown)]
|
||||||
|
|
||||||
//! Enums from the {:?} IANA registry
|
//! Enums from the {:?} IANA registry
|
||||||
//! See <{}>
|
//! See <{}>
|
||||||
|
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#![allow(clippy::doc_markdown)]
|
||||||
|
|
||||||
//! Enums from the "JSON Object Signing and Encryption" IANA registry
|
//! Enums from the "JSON Object Signing and Encryption" IANA registry
|
||||||
//! See <https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml>
|
//! See <https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml>
|
||||||
|
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#![allow(clippy::doc_markdown)]
|
||||||
|
|
||||||
//! Enums from the "OAuth Parameters" IANA registry
|
//! Enums from the "OAuth Parameters" IANA registry
|
||||||
//! See <https://www.iana.org/assignments/jose/jose.xhtml>
|
//! See <https://www.iana.org/assignments/jose/jose.xhtml>
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ use tokio::io::{AsyncRead, AsyncReadExt};
|
|||||||
use super::ProxyProtocolV1Info;
|
use super::ProxyProtocolV1Info;
|
||||||
use crate::rewind::Rewind;
|
use crate::rewind::Rewind;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
pub struct ProxyAcceptor {
|
pub struct ProxyAcceptor {
|
||||||
_private: (),
|
_private: (),
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#![allow(clippy::blocks_in_conditions)]
|
||||||
|
|
||||||
use http::{header::AUTHORIZATION, request::Builder, Method, Request, StatusCode};
|
use http::{header::AUTHORIZATION, request::Builder, Method, Request, StatusCode};
|
||||||
use mas_axum_utils::http_client_factory::HttpClientFactory;
|
use mas_axum_utils::http_client_factory::HttpClientFactory;
|
||||||
use mas_http::{EmptyBody, HttpServiceExt};
|
use mas_http::{EmptyBody, HttpServiceExt};
|
||||||
|
@@ -52,7 +52,7 @@ pub enum ScopeToken {
|
|||||||
/// `offline_access`
|
/// `offline_access`
|
||||||
///
|
///
|
||||||
/// Requests that an OAuth 2.0 refresh token be issued that can be used to
|
/// Requests that an OAuth 2.0 refresh token be issued that can be used to
|
||||||
/// obtain an access token that grants access to the end-user's UserInfo
|
/// obtain an access token that grants access to the end-user's `UserInfo`
|
||||||
/// Endpoint even when the end-user is not present (not logged in).
|
/// Endpoint even when the end-user is not present (not logged in).
|
||||||
OfflineAccess,
|
OfflineAccess,
|
||||||
|
|
||||||
|
@@ -165,7 +165,7 @@
|
|||||||
//! [`Uuid`]: uuid::Uuid
|
//! [`Uuid`]: uuid::Uuid
|
||||||
|
|
||||||
#![deny(clippy::future_not_send, missing_docs)]
|
#![deny(clippy::future_not_send, missing_docs)]
|
||||||
#![allow(clippy::module_name_repetitions)]
|
#![allow(clippy::module_name_repetitions, clippy::blocks_in_conditions)]
|
||||||
|
|
||||||
use sqlx::migrate::Migrator;
|
use sqlx::migrate::Migrator;
|
||||||
|
|
||||||
|
@@ -43,10 +43,7 @@ impl<J: Job> TracedJob for JobWithSpanContext<J> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_span_for_job_request<J: TracedJob>(req: &JobRequest<J>) -> tracing::Span
|
fn make_span_for_job_request<J: TracedJob>(req: &JobRequest<J>) -> tracing::Span {
|
||||||
where
|
|
||||||
J: Job,
|
|
||||||
{
|
|
||||||
let span = info_span!(
|
let span = info_span!(
|
||||||
"job.run",
|
"job.run",
|
||||||
"otel.kind" = "consumer",
|
"otel.kind" = "consumer",
|
||||||
|
@@ -633,7 +633,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"proxy_protocol": {
|
"proxy_protocol": {
|
||||||
"description": "Accept HAProxy's Proxy Protocol V1",
|
"description": "Accept `HAProxy`'s Proxy Protocol V1",
|
||||||
"default": false,
|
"default": false,
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
@@ -1279,7 +1279,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"port": {
|
"port": {
|
||||||
"description": "SMTP transport: Port to connect to. Default is 25 for plain, 465 for TLS and 587 for StartTLS",
|
"description": "SMTP transport: Port to connect to. Default is 25 for plain, 465 for TLS and 587 for `StartTLS`",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "uint16",
|
"format": "uint16",
|
||||||
"maximum": 65535.0,
|
"maximum": 65535.0,
|
||||||
@@ -1337,7 +1337,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "StartTLS (starts as plain text then upgrade to TLS)",
|
"description": "`StartTLS` (starts as plain text then upgrade to TLS)",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"starttls"
|
"starttls"
|
||||||
|
Reference in New Issue
Block a user