Upgrade to Rust 1.85 and edition 2024

This commit is contained in:
Quentin Gliech
2025-02-21 16:15:02 +01:00
parent 1a00b7a90b
commit 56d9c7e63b
267 changed files with 908 additions and 817 deletions

View File

@@ -4,9 +4,9 @@ on:
push:
branches:
- main
- 'release/**'
- "release/**"
tags:
- 'v*'
- "v*"
pull_request:
concurrency:
@@ -31,10 +31,7 @@ jobs:
- name: Checkout the code
uses: actions/checkout@v4.2.2
- name: Setup OPA
uses: open-policy-agent/setup-opa@v2.2.0
with:
version: 0.70.0
- uses: ./.github/actions/build-policies
- name: Setup Regal
uses: StyraInc/setup-regal@v1
@@ -73,7 +70,6 @@ jobs:
working-directory: ./frontend
run: npm run lint
frontend-test:
name: Run the frontend test suite
runs-on: ubuntu-24.04
@@ -98,7 +94,6 @@ jobs:
working-directory: ./frontend
run: npm test
frontend-knip:
name: Check the frontend for unused dependencies
runs-on: ubuntu-24.04
@@ -123,7 +118,6 @@ jobs:
working-directory: ./frontend
run: npm run knip
rustfmt:
name: Check Rust style
runs-on: ubuntu-24.04
@@ -143,7 +137,6 @@ jobs:
- name: Check style
run: cargo fmt --all -- --check
cargo-deny:
name: Run `cargo deny` checks
runs-on: ubuntu-24.04
@@ -162,7 +155,6 @@ jobs:
- name: Run `cargo-deny`
uses: EmbarkStudios/cargo-deny-action@v2.0.5
check-schema:
name: Check schema
runs-on: ubuntu-24.04
@@ -203,7 +195,6 @@ jobs:
exit 1
fi
clippy:
name: Run Clippy
needs: [rustfmt, opa-lint]
@@ -221,14 +212,7 @@ jobs:
with:
components: clippy
- name: Setup OPA
uses: open-policy-agent/setup-opa@v2.2.0
with:
version: 0.64.1
- name: Compile OPA policies
working-directory: ./policies
run: make
- uses: ./.github/actions/build-policies
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.7
@@ -237,7 +221,6 @@ jobs:
run: |
cargo clippy --workspace --tests --bins --lib -- -D warnings
compile-test-artifacts:
name: Compile test artifacts
runs-on: ubuntu-24.04
@@ -263,7 +246,7 @@ jobs:
- name: Build and archive tests
run: cargo nextest archive --workspace --archive-file nextest-archive.tar.zst
env:
SQLX_OFFLINE: '1'
SQLX_OFFLINE: "1"
- name: Upload archive to workflow
uses: actions/upload-artifact@v4.6.0
@@ -271,7 +254,6 @@ jobs:
name: nextest-archive
path: nextest-archive.tar.zst
test:
name: Run test suite with Rust stable
needs: [rustfmt, opa-lint, compile-test-artifacts]

View File

@@ -2,9 +2,9 @@ name: Coverage
on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -26,10 +26,7 @@ jobs:
- name: Checkout the code
uses: actions/checkout@v4.2.2
- name: Setup OPA
uses: open-policy-agent/setup-opa@v2.2.0
with:
version: 0.70.0
- uses: ./.github/actions/build-policies
- name: Run OPA tests with coverage
working-directory: ./policies
@@ -119,10 +116,10 @@ jobs:
run: |
cargo test --no-fail-fast --workspace
env:
RUSTFLAGS: '-Cinstrument-coverage'
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw"
DATABASE_URL: postgresql://postgres:postgres@localhost/postgres
SQLX_OFFLINE: '1'
SQLX_OFFLINE: "1"
- name: Build grcov report
run: |

View File

@@ -7,12 +7,12 @@ resolver = "2"
package.version = "0.14.1"
package.license = "AGPL-3.0-only"
package.authors = ["Element Backend Team"]
package.edition = "2021"
package.edition = "2024"
package.homepage = "https://element-hq.github.io/matrix-authentication-service/"
package.repository = "https://github.com/element-hq/matrix-authentication-service/"
[workspace.lints.rust]
unsafe_code = "forbid"
unsafe_code = "deny"
[workspace.lints.clippy]
# We use groups as good defaults, but with a lower priority so that we can override them

View File

@@ -8,9 +8,9 @@
# The Debian version and version name must be in sync
ARG DEBIAN_VERSION=12
ARG DEBIAN_VERSION_NAME=bookworm
ARG RUSTC_VERSION=1.84.0
ARG RUSTC_VERSION=1.85.0
ARG NODEJS_VERSION=20.15.0
ARG OPA_VERSION=0.64.1
ARG OPA_VERSION=1.1.0
ARG CARGO_AUDITABLE_VERSION=0.6.6
##########################################

View File

@@ -7,24 +7,24 @@
use std::collections::HashMap;
use axum::{
BoxError, Json,
extract::{
rejection::{FailedToDeserializeForm, FormRejection},
Form, FromRequest, FromRequestParts,
rejection::{FailedToDeserializeForm, FormRejection},
},
response::IntoResponse,
BoxError, Json,
};
use axum_extra::typed_header::{TypedHeader, TypedHeaderRejectionReason};
use headers::{authorization::Basic, Authorization};
use headers::{Authorization, authorization::Basic};
use http::{Request, StatusCode};
use mas_data_model::{Client, JwksOrJwksUri};
use mas_http::RequestBuilderExt;
use mas_iana::oauth::OAuthClientAuthenticationMethod;
use mas_jose::{jwk::PublicJsonWebKeySet, jwt::Jwt};
use mas_keystore::Encrypter;
use mas_storage::{oauth2::OAuth2ClientRepository, RepositoryAccess};
use mas_storage::{RepositoryAccess, oauth2::OAuth2ClientRepository};
use oauth2_types::errors::{ClientError, ClientErrorCode};
use serde::{de::DeserializeOwned, Deserialize};
use serde::{Deserialize, de::DeserializeOwned};
use serde_json::Value;
use thiserror::Error;
@@ -371,7 +371,7 @@ where
Err(FormRejection::InvalidFormContentType(_err)) => (None, None, None, None, None),
// If the form could not be read, return a Bad Request error
Err(FormRejection::FailedToDeserializeForm(err)) => {
return Err(ClientAuthorizationError::BadForm(err))
return Err(ClientAuthorizationError::BadForm(err));
}
// Other errors (body read twice, byte stream broke) return an internal error
Err(e) => return Err(ClientAuthorizationError::Internal(Box::new(e))),

View File

@@ -14,7 +14,7 @@ use axum::{
};
use axum_extra::extract::cookie::{Cookie, Key, PrivateCookieJar, SameSite};
use http::request::Parts;
use serde::{de::DeserializeOwned, Serialize};
use serde::{Serialize, de::DeserializeOwned};
use thiserror::Error;
use url::Url;

View File

@@ -5,11 +5,11 @@
// Please see LICENSE in the repository root for full details.
use chrono::{DateTime, Duration, Utc};
use data_encoding::{DecodeError, BASE64URL_NOPAD};
use data_encoding::{BASE64URL_NOPAD, DecodeError};
use mas_storage::Clock;
use rand::{Rng, RngCore};
use rand::{Rng, RngCore, distributions::Standard, prelude::Distribution as _};
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, TimestampSeconds};
use serde_with::{TimestampSeconds, serde_as};
use thiserror::Error;
use crate::cookies::{CookieDecodeError, CookieJar};
@@ -56,7 +56,7 @@ impl CsrfToken {
/// Generate a new random token valid for a specified duration
fn generate(now: DateTime<Utc>, mut rng: impl Rng, ttl: Duration) -> Self {
let token = rng.gen();
let token = Standard.sample(&mut rng);
Self::new(token, now, ttl)
}

View File

@@ -5,9 +5,9 @@
// Please see LICENSE in the repository root for full details.
use axum::{
Extension,
http::StatusCode,
response::{IntoResponse, Response},
Extension,
};
use axum_extra::typed_header::TypedHeader;
use headers::ContentType;

View File

@@ -7,7 +7,7 @@
use std::cmp::Reverse;
use headers::{Error, Header};
use http::{header::ACCEPT_LANGUAGE, HeaderName, HeaderValue};
use http::{HeaderName, HeaderValue, header::ACCEPT_LANGUAGE};
use icu_locid::Locale;
#[derive(PartialEq, Eq, Debug)]
@@ -155,7 +155,7 @@ impl Header for AcceptLanguage {
#[cfg(test)]
mod tests {
use headers::HeaderMapExt;
use http::{header::ACCEPT_LANGUAGE, HeaderMap, HeaderValue};
use http::{HeaderMap, HeaderValue, header::ACCEPT_LANGUAGE};
use icu_locid::locale;
use super::*;

View File

@@ -5,7 +5,7 @@
// Please see LICENSE in the repository root for full details.
use mas_data_model::BrowserSession;
use mas_storage::{user::BrowserSessionRepository, RepositoryAccess};
use mas_storage::{RepositoryAccess, user::BrowserSessionRepository};
use serde::{Deserialize, Serialize};
use ulid::Ulid;

View File

@@ -8,20 +8,20 @@ use std::{collections::HashMap, error::Error};
use axum::{
extract::{
rejection::{FailedToDeserializeForm, FormRejection},
Form, FromRequest, FromRequestParts,
rejection::{FailedToDeserializeForm, FormRejection},
},
response::{IntoResponse, Response},
};
use axum_extra::typed_header::{TypedHeader, TypedHeaderRejectionReason};
use headers::{authorization::Bearer, Authorization, Header, HeaderMapExt, HeaderName};
use http::{header::WWW_AUTHENTICATE, HeaderMap, HeaderValue, Request, StatusCode};
use headers::{Authorization, Header, HeaderMapExt, HeaderName, authorization::Bearer};
use http::{HeaderMap, HeaderValue, Request, StatusCode, header::WWW_AUTHENTICATE};
use mas_data_model::Session;
use mas_storage::{
oauth2::{OAuth2AccessTokenRepository, OAuth2SessionRepository},
Clock, RepositoryAccess,
oauth2::{OAuth2AccessTokenRepository, OAuth2SessionRepository},
};
use serde::{de::DeserializeOwned, Deserialize};
use serde::{Deserialize, de::DeserializeOwned};
use thiserror::Error;
#[derive(Debug, Deserialize)]
@@ -319,7 +319,7 @@ where
Err(FormRejection::InvalidFormContentType(_err)) => (None, None),
// If the form could not be read, return a Bad Request error
Err(FormRejection::FailedToDeserializeForm(err)) => {
return Err(UserAuthorizationError::BadForm(err))
return Err(UserAuthorizationError::BadForm(err));
}
// Other errors (body read twice, byte stream broke) return an internal error
Err(e) => return Err(UserAuthorizationError::Internal(Box::new(e))),

View File

@@ -11,7 +11,11 @@ fn main() -> anyhow::Result<()> {
// empty, so we unset it here.
if let Ok(ver) = std::env::var("VERGEN_GIT_DESCRIBE") {
if ver.is_empty() {
std::env::remove_var("VERGEN_GIT_DESCRIBE");
#[allow(unsafe_code)]
// SAFETY: This is safe because the build script is running a single thread
unsafe {
std::env::remove_var("VERGEN_GIT_DESCRIBE");
}
}
}

View File

@@ -10,8 +10,8 @@ use axum::extract::{FromRef, FromRequestParts};
use ipnetwork::IpNetwork;
use mas_data_model::SiteConfig;
use mas_handlers::{
passwords::PasswordManager, ActivityTracker, BoundActivityTracker, CookieManager, ErrorWrapper,
GraphQLSchema, Limiter, MetadataCache, RequesterFingerprint,
ActivityTracker, BoundActivityTracker, CookieManager, ErrorWrapper, GraphQLSchema, Limiter,
MetadataCache, RequesterFingerprint, passwords::PasswordManager,
};
use mas_i18n::Translator;
use mas_keystore::{Encrypter, Keystore};
@@ -22,7 +22,7 @@ use mas_router::UrlBuilder;
use mas_storage::{BoxClock, BoxRepository, BoxRng, SystemClock};
use mas_storage_pg::PgRepository;
use mas_templates::Templates;
use opentelemetry::{metrics::Histogram, KeyValue};
use opentelemetry::{KeyValue, metrics::Histogram};
use rand::SeedableRng;
use sqlx::PgPool;
use tracing::Instrument;
@@ -343,7 +343,9 @@ impl FromRequestParts<AppState> for RequesterFingerprint {
} else {
// If we can't infer the IP address, we'll just use an empty fingerprint and
// warn about it
tracing::warn!("Could not infer client IP address for an operation which rate-limits based on IP addresses");
tracing::warn!(
"Could not infer client IP address for an operation which rate-limits based on IP addresses"
);
Ok(RequesterFingerprint::EMPTY)
}
}

View File

@@ -15,7 +15,7 @@ use mas_storage::SystemClock;
use mas_storage_pg::MIGRATOR;
use rand::SeedableRng;
use tokio::io::AsyncWriteExt;
use tracing::{info, info_span, Instrument};
use tracing::{Instrument, info, info_span};
use crate::util::database_connection_from_config;

View File

@@ -11,7 +11,7 @@ use clap::Parser;
use figment::Figment;
use mas_config::{ConfigurationSectionExt, DatabaseConfig};
use mas_storage_pg::MIGRATOR;
use tracing::{info_span, Instrument};
use tracing::{Instrument, info_span};
use crate::util::database_connection_from_config;

View File

@@ -29,7 +29,9 @@ impl Options {
#[allow(clippy::too_many_lines)]
pub async fn run(self, figment: &Figment) -> anyhow::Result<ExitCode> {
let _span = info_span!("cli.doctor").entered();
info!("💡 Running diagnostics, make sure that both MAS and Synapse are running, and that MAS is using the same configuration files as this tool.");
info!(
"💡 Running diagnostics, make sure that both MAS and Synapse are running, and that MAS is using the same configuration files as this tool."
);
let config = RootConfig::extract(figment)?;

View File

@@ -8,8 +8,8 @@ use std::{collections::BTreeMap, process::ExitCode};
use anyhow::Context;
use clap::{ArgAction, CommandFactory, Parser};
use console::{pad_str, style, Alignment, Style, Term};
use dialoguer::{theme::ColorfulTheme, Confirm, FuzzySelect, Input, Password};
use console::{Alignment, Style, Term, pad_str, style};
use dialoguer::{Confirm, FuzzySelect, Input, Password, theme::ColorfulTheme};
use figment::Figment;
use mas_config::{
ConfigurationSection, ConfigurationSectionExt, DatabaseConfig, MatrixConfig, PasswordsConfig,
@@ -19,6 +19,7 @@ use mas_email::Address;
use mas_matrix::HomeserverConnection;
use mas_matrix_synapse::SynapseConnection;
use mas_storage::{
Clock, RepositoryAccess, SystemClock,
compat::{CompatAccessTokenRepository, CompatSessionFilter, CompatSessionRepository},
oauth2::OAuth2SessionFilter,
queue::{
@@ -26,11 +27,10 @@ use mas_storage::{
SyncDevicesJob,
},
user::{BrowserSessionFilter, UserEmailRepository, UserPasswordRepository, UserRepository},
Clock, RepositoryAccess, SystemClock,
};
use mas_storage_pg::{DatabaseError, PgRepository};
use rand::{RngCore, SeedableRng};
use sqlx::{types::Uuid, Acquire};
use sqlx::{Acquire, types::Uuid};
use tracing::{error, info, info_span, warn};
use crate::util::{database_connection_from_config, password_manager_from_config};
@@ -266,7 +266,9 @@ impl Options {
)
.entered();
tracing::warn!("The 'verify-email' command is deprecated and will be removed in a future version. Use 'add-email' instead.");
tracing::warn!(
"The 'verify-email' command is deprecated and will be removed in a future version. Use 'add-email' instead."
);
Ok(ExitCode::SUCCESS)
}

View File

@@ -9,8 +9,8 @@ use std::process::ExitCode;
use camino::Utf8PathBuf;
use clap::Parser;
use figment::{
providers::{Env, Format, Yaml},
Figment,
providers::{Env, Format, Yaml},
};
mod config;

View File

@@ -20,7 +20,7 @@ use mas_router::UrlBuilder;
use mas_storage::SystemClock;
use mas_storage_pg::MIGRATOR;
use sqlx::migrate::Migrate;
use tracing::{info, info_span, warn, Instrument};
use tracing::{Instrument, info, info_span, warn};
use crate::{
app_state::AppState,
@@ -63,7 +63,9 @@ impl Options {
info!(version = crate::VERSION, "Starting up");
if self.migrate {
warn!("The `--migrate` flag is deprecated and will be removed in a future release. Please use `--no-migrate` to disable automatic migrations on startup.");
warn!(
"The `--migrate` flag is deprecated and will be removed in a future release. Please use `--no-migrate` to disable automatic migrations on startup."
);
}
// Connect to the database
@@ -78,7 +80,9 @@ impl Options {
let has_missing_migrations = MIGRATOR.iter().any(|m| !applied.contains(&m.version));
if has_missing_migrations {
// Refuse to start if there are pending migrations
return Err(anyhow::anyhow!("The server is running with `--no-migrate` but there are pending. Please run them first with `mas-cli database migrate`, or omit the `--no-migrate` flag to apply them automatically on startup."));
return Err(anyhow::anyhow!(
"The server is running with `--no-migrate` but there are pending. Please run them first with `mas-cli database migrate`, or omit the `--no-migrate` flag to apply them automatically on startup."
));
}
} else {
info!("Running pending database migrations");

View File

@@ -11,9 +11,9 @@ use mas_config::{
use mas_storage::SystemClock;
use mas_storage_pg::MIGRATOR;
use rand::thread_rng;
use sqlx::{postgres::PgConnectOptions, types::Uuid, Connection, Either, PgConnection};
use syn2mas::{synapse_config, LockedMasDatabase, MasWriter, SynapseReader};
use tracing::{error, info_span, warn, Instrument};
use sqlx::{Connection, Either, PgConnection, postgres::PgConnectOptions, types::Uuid};
use syn2mas::{LockedMasDatabase, MasWriter, SynapseReader, synapse_config};
use tracing::{Instrument, error, info_span, warn};
use crate::util::database_connection_from_config;
@@ -82,7 +82,9 @@ const NUM_WRITER_CONNECTIONS: usize = 8;
impl Options {
#[allow(clippy::too_many_lines)]
pub async fn run(self, figment: &Figment) -> anyhow::Result<ExitCode> {
warn!("This version of the syn2mas tool is EXPERIMENTAL and INCOMPLETE. Do not use it, except for TESTING.");
warn!(
"This version of the syn2mas tool is EXPERIMENTAL and INCOMPLETE. Do not use it, except for TESTING."
);
if !self.experimental_accepted {
error!("Please agree that you can only use this tool for testing.");
return Ok(ExitCode::FAILURE);
@@ -179,7 +181,9 @@ impl Options {
}
if !check_warnings.is_empty() {
eprintln!("===== Warnings =====");
eprintln!("These potential issues should be considered before migrating from Synapse to MAS right now:\n");
eprintln!(
"These potential issues should be considered before migrating from Synapse to MAS right now:\n"
);
for warning in &check_warnings {
eprintln!("{warning}\n");
}

View File

@@ -13,7 +13,7 @@ use clap::Parser;
use mas_config::{ConfigurationSection, TelemetryConfig};
use sentry_tracing::EventFilter;
use tracing_subscriber::{
filter::LevelFilter, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer, Registry,
EnvFilter, Layer, Registry, filter::LevelFilter, layer::SubscriberExt, util::SubscriberInitExt,
};
mod app_state;

View File

@@ -12,22 +12,22 @@ use std::{
use anyhow::Context;
use axum::{
Extension, Router,
error_handling::HandleErrorLayer,
extract::{FromRef, MatchedPath},
Extension, Router,
};
use hyper::{
header::{HeaderValue, CACHE_CONTROL, USER_AGENT},
Method, Request, Response, StatusCode, Version,
header::{CACHE_CONTROL, HeaderValue, USER_AGENT},
};
use listenfd::ListenFd;
use mas_config::{HttpBindConfig, HttpResource, HttpTlsConfig, UnixOrTcp};
use mas_listener::{unix_or_tcp::UnixOrTcpListener, ConnectionInfo};
use mas_listener::{ConnectionInfo, unix_or_tcp::UnixOrTcpListener};
use mas_router::Route;
use mas_templates::Templates;
use mas_tower::{
make_span_fn, metrics_attributes_fn, DurationRecorderLayer, InFlightCounterLayer, TraceLayer,
KV,
DurationRecorderLayer, InFlightCounterLayer, KV, TraceLayer, make_span_fn,
metrics_attributes_fn,
};
use opentelemetry::{Key, KeyValue};
use opentelemetry_http::HeaderExtractor;

View File

@@ -11,11 +11,11 @@ use std::collections::{BTreeMap, BTreeSet};
use mas_config::{ClientsConfig, UpstreamOAuth2Config};
use mas_keystore::Encrypter;
use mas_storage::{
upstream_oauth2::{UpstreamOAuthProviderFilter, UpstreamOAuthProviderParams},
Clock, Pagination, RepositoryAccess,
upstream_oauth2::{UpstreamOAuthProviderFilter, UpstreamOAuthProviderParams},
};
use mas_storage_pg::PgRepository;
use sqlx::{postgres::PgAdvisoryLock, Connection, PgConnection};
use sqlx::{Connection, PgConnection, postgres::PgAdvisoryLock};
use tracing::{error, info, info_span, warn};
fn map_import_action(
@@ -155,9 +155,13 @@ pub async fn config_sync(
} else {
let len = existing_disabled.len();
match len {
0 => {},
1 => warn!("A provider is soft-deleted in the database. Run `mas-cli config sync --prune` to delete it."),
n => warn!("{n} providers are soft-deleted in the database. Run `mas-cli config sync --prune` to delete them."),
0 => {}
1 => warn!(
"A provider is soft-deleted in the database. Run `mas-cli config sync --prune` to delete it."
),
n => warn!(
"{n} providers are soft-deleted in the database. Run `mas-cli config sync --prune` to delete them."
),
}
}
@@ -318,9 +322,13 @@ pub async fn config_sync(
} else {
let len = to_delete.count();
match len {
0 => {},
1 => warn!("A static client in the database is not in the config. Run with `--prune` to delete it."),
n => warn!("{n} static clients in the database are not in the config. Run with `--prune` to delete them."),
0 => {}
1 => warn!(
"A static client in the database is not in the config. Run with `--prune` to delete it."
),
n => warn!(
"{n} static clients in the database are not in the config. Run with `--prune` to delete them."
),
}
}

View File

@@ -12,24 +12,24 @@ use std::{
use anyhow::Context as _;
use bytes::Bytes;
use http_body_util::Full;
use hyper::{header::CONTENT_TYPE, Response};
use hyper::{Response, header::CONTENT_TYPE};
use mas_config::{
MetricsConfig, MetricsExporterKind, Propagator, TelemetryConfig, TracingConfig,
TracingExporterKind,
};
use opentelemetry::{
InstrumentationScope, KeyValue,
metrics::Meter,
propagation::{TextMapCompositePropagator, TextMapPropagator},
trace::TracerProvider as _,
InstrumentationScope, KeyValue,
};
use opentelemetry_otlp::{WithExportConfig, WithHttpConfig};
use opentelemetry_prometheus::PrometheusExporter;
use opentelemetry_sdk::{
Resource,
metrics::{ManualReader, PeriodicReader, SdkMeterProvider},
propagation::{BaggagePropagator, TraceContextPropagator},
trace::{Sampler, Tracer, TracerProvider},
Resource,
};
use opentelemetry_semantic_conventions as semcov;
use prometheus::Registry;
@@ -80,7 +80,7 @@ fn match_propagator(propagator: Propagator) -> Box<dyn TextMapPropagator + Send
}
}
fn propagator(propagators: &[Propagator]) -> impl TextMapPropagator {
fn propagator(propagators: &[Propagator]) -> TextMapCompositePropagator {
let propagators = propagators.iter().copied().map(match_propagator).collect();
TextMapCompositePropagator::new(propagators)
@@ -185,7 +185,9 @@ fn prometheus_service_fn<T>(_req: T) -> PromServiceFuture {
pub fn prometheus_service<T>() -> tower::util::ServiceFn<fn(T) -> PromServiceFuture> {
if PROMETHEUS_REGISTRY.get().is_none() {
tracing::warn!("A Prometheus resource was mounted on a listener, but the Prometheus exporter was not setup in the config");
tracing::warn!(
"A Prometheus resource was mounted on a listener, but the Prometheus exporter was not setup in the config"
);
}
tower::service_fn(prometheus_service_fn as _)

View File

@@ -19,10 +19,10 @@ use mas_policy::PolicyFactory;
use mas_router::UrlBuilder;
use mas_templates::{SiteConfigExt, TemplateLoadingError, Templates};
use sqlx::{
postgres::{PgConnectOptions, PgPoolOptions},
ConnectOptions, PgConnection, PgPool,
postgres::{PgConnectOptions, PgPoolOptions},
};
use tracing::{log::LevelFilter, Instrument};
use tracing::{Instrument, log::LevelFilter};
pub async fn password_manager_from_config(
config: &PasswordsConfig,
@@ -280,7 +280,9 @@ fn database_connect_options_from_config(
(Some(pem), None) => options.ssl_client_cert_from_pem(pem.as_bytes()),
(None, Some(path)) => options.ssl_client_cert(path),
(Some(_), Some(_)) => {
anyhow::bail!("invalid database configuration: both `ssl_certificate` and `ssl_certificate_file` are set")
anyhow::bail!(
"invalid database configuration: both `ssl_certificate` and `ssl_certificate_file` are set"
)
}
};

View File

@@ -4,15 +4,15 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use schemars::gen::SchemaSettings;
use schemars::r#gen::SchemaSettings;
fn main() {
let settings = SchemaSettings::draft07().with(|s| {
s.option_nullable = false;
s.option_add_null_type = false;
});
let gen = settings.into_generator();
let schema = gen.into_root_schema_for::<mas_config::RootConfig>();
let generator = settings.into_generator();
let schema = generator.into_root_schema_for::<mas_config::RootConfig>();
serde_json::to_writer_pretty(std::io::stdout(), &schema).expect("Failed to serialize schema");
}

View File

@@ -7,9 +7,9 @@
//! Useful JSON Schema definitions
use schemars::{
gen::SchemaGenerator,
schema::{InstanceType, Schema, SchemaObject},
JsonSchema,
r#gen::SchemaGenerator,
schema::{InstanceType, Schema, SchemaObject},
};
/// A network hostname
@@ -20,8 +20,8 @@ impl JsonSchema for Hostname {
"Hostname".to_string()
}
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
hostname(gen)
fn json_schema(generator: &mut SchemaGenerator) -> Schema {
hostname(generator)
}
}

View File

@@ -5,7 +5,7 @@
// Please see LICENSE in the repository root for full details.
use schemars::JsonSchema;
use serde::{de::Error, Deserialize, Serialize};
use serde::{Deserialize, Serialize, de::Error};
use crate::ConfigurationSection;

View File

@@ -10,7 +10,7 @@ use figment::Figment;
use mas_iana::oauth::OAuthClientAuthenticationMethod;
use mas_jose::jwk::PublicJsonWebKeySet;
use schemars::JsonSchema;
use serde::{de::Error, Deserialize, Serialize};
use serde::{Deserialize, Serialize, de::Error};
use ulid::Ulid;
use url::Url;
@@ -249,8 +249,8 @@ mod tests {
use std::str::FromStr;
use figment::{
providers::{Format, Yaml},
Figment, Jail,
providers::{Format, Yaml},
};
use super::*;

View File

@@ -280,8 +280,8 @@ impl ConfigurationSection for DatabaseConfig {
#[cfg(test)]
mod tests {
use figment::{
providers::{Format, Yaml},
Figment, Jail,
providers::{Format, Yaml},
};
use super::*;

View File

@@ -10,7 +10,7 @@ use std::{num::NonZeroU16, str::FromStr};
use lettre::message::Mailbox;
use schemars::JsonSchema;
use serde::{de::Error, Deserialize, Serialize};
use serde::{Deserialize, Serialize, de::Error};
use super::ConfigurationSection;

View File

@@ -5,8 +5,8 @@
// Please see LICENSE in the repository root for full details.
use rand::{
distributions::{Alphanumeric, DistString},
Rng,
distributions::{Alphanumeric, DistString},
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
@@ -67,8 +67,8 @@ impl MatrixConfig {
#[cfg(test)]
mod tests {
use figment::{
providers::{Format, Yaml},
Figment, Jail,
providers::{Format, Yaml},
};
use super::*;

View File

@@ -8,7 +8,7 @@ use std::{num::NonZeroU32, time::Duration};
use governor::Quota;
use schemars::JsonSchema;
use serde::{de::Error as _, Deserialize, Serialize};
use serde::{Deserialize, Serialize, de::Error as _};
use crate::ConfigurationSection;

View File

@@ -6,13 +6,14 @@
use std::borrow::Cow;
use anyhow::{bail, Context};
use anyhow::{Context, bail};
use camino::Utf8PathBuf;
use mas_jose::jwk::{JsonWebKey, JsonWebKeySet};
use mas_keystore::{Encrypter, Keystore, PrivateKey};
use rand::{
distributions::{Alphanumeric, DistString},
Rng, SeedableRng,
distributions::{Alphanumeric, DistString, Standard},
prelude::Distribution as _,
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
@@ -245,7 +246,7 @@ impl SecretsConfig {
};
Ok(Self {
encryption: rng.gen(),
encryption: Standard.sample(&mut rng),
keys: vec![rsa_key, ec_p256_key, ec_p384_key, ec_k256_key],
})
}

View File

@@ -8,7 +8,7 @@ use std::collections::BTreeMap;
use mas_iana::jose::JsonWebSignatureAlg;
use schemars::JsonSchema;
use serde::{de::Error, Deserialize, Serialize};
use serde::{Deserialize, Serialize, de::Error};
use serde_with::skip_serializing_none;
use ulid::Ulid;
use url::Url;
@@ -60,7 +60,9 @@ impl ConfigurationSection for UpstreamOAuth2Config {
| TokenAuthMethod::PrivateKeyJwt
| TokenAuthMethod::SignInWithApple => {
if provider.client_secret.is_some() {
return annotate(figment::Error::custom("Unexpected field `client_secret` for the selected authentication method"));
return annotate(figment::Error::custom(
"Unexpected field `client_secret` for the selected authentication method",
));
}
}
TokenAuthMethod::ClientSecretBasic

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use figment::{error::Error as FigmentError, Figment};
use figment::{Figment, error::Error as FigmentError};
use serde::de::DeserializeOwned;
/// Trait implemented by all configuration section to help loading specific part

View File

@@ -6,8 +6,8 @@
use oauth2_types::scope::ScopeToken;
use rand::{
distributions::{Alphanumeric, DistString},
RngCore,
distributions::{Alphanumeric, DistString},
};
use serde::{Deserialize, Serialize};
use thiserror::Error;

View File

@@ -11,11 +11,11 @@ use mas_iana::oauth::PkceCodeChallengeMethod;
use oauth2_types::{
pkce::{CodeChallengeError, CodeChallengeMethodExt},
requests::ResponseMode,
scope::{Scope, OPENID, PROFILE},
scope::{OPENID, PROFILE, Scope},
};
use rand::{
distributions::{Alphanumeric, DistString},
RngCore,
distributions::{Alphanumeric, DistString},
};
use ruma_common::UserId;
use serde::Serialize;

View File

@@ -121,6 +121,7 @@ impl Client {
}
/// Create a client metadata object for this client
#[must_use]
pub fn into_metadata(self) -> ClientMetadata {
let (jwks, jwks_uri) = match self.jwks {
Some(JwksOrJwksUri::Jwks(jwks)) => (Some(jwks), None),
@@ -130,7 +131,7 @@ impl Client {
ClientMetadata {
redirect_uris: Some(self.redirect_uris.clone()),
response_types: None,
grant_types: Some(self.grant_types.into_iter().map(Into::into).collect()),
grant_types: Some(self.grant_types.clone()),
application_type: self.application_type.clone(),
client_name: self.client_name.map(|n| Localized::new(n, [])),
logo_uri: self.logo_uri.map(|n| Localized::new(n, [])),

View File

@@ -6,9 +6,9 @@
use base64ct::{Base64Url, Encoding};
use chrono::{DateTime, Utc};
use crc::{Crc, CRC_32_ISO_HDLC};
use crc::{CRC_32_ISO_HDLC, Crc};
use mas_iana::oauth::OAuthTokenTypeHint;
use rand::{distributions::Alphanumeric, Rng, RngCore};
use rand::{Rng, RngCore, distributions::Alphanumeric};
use thiserror::Error;
use ulid::Ulid;
@@ -444,7 +444,9 @@ mod tests {
));
// Whilst this is a macaroon, it's not a Synapse macaroon
assert!(! is_likely_synapse_macaroon("MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVzZWQgb3VyIHNlY3JldCBrZXkKMDAyZnNpZ25hdHVyZSDj2eApCFJsTAA5rhURQRXZf91ovyujebNCqvD2F9BVLwo"));
assert!(!is_likely_synapse_macaroon(
"MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVzZWQgb3VyIHNlY3JldCBrZXkKMDAyZnNpZ25hdHVyZSDj2eApCFJsTAA5rhURQRXZf91ovyujebNCqvD2F9BVLwo"
));
// None of these are macaroons
assert!(!is_likely_synapse_macaroon(

View File

@@ -12,7 +12,7 @@ mod mailer;
mod transport;
pub use lettre::{
message::Mailbox, transport::smtp::authentication::Credentials as SmtpCredentials, Address,
Address, message::Mailbox, transport::smtp::authentication::Credentials as SmtpCredentials,
};
pub use mas_templates::EmailVerificationContext;

View File

@@ -7,8 +7,8 @@
//! Send emails to users
use lettre::{
message::{Mailbox, MessageBuilder, MultiPart},
AsyncTransport, Message,
message::{Mailbox, MessageBuilder, MultiPart},
};
use mas_templates::{EmailRecoveryContext, EmailVerificationContext, Templates, WithLanguage};
use thiserror::Error;

View File

@@ -10,12 +10,12 @@ use std::{ffi::OsString, num::NonZeroU16, sync::Arc};
use async_trait::async_trait;
use lettre::{
AsyncTransport, Tokio1Executor,
address::Envelope,
transport::{
sendmail::AsyncSendmailTransport,
smtp::{authentication::Credentials, AsyncSmtpTransport},
smtp::{AsyncSmtpTransport, authentication::Credentials},
},
AsyncTransport, Tokio1Executor,
};
use thiserror::Error;

View File

@@ -7,18 +7,18 @@
use std::{collections::HashMap, net::IpAddr};
use chrono::{DateTime, Utc};
use mas_storage::{user::BrowserSessionRepository, RepositoryAccess};
use mas_storage::{RepositoryAccess, user::BrowserSessionRepository};
use opentelemetry::{
metrics::{Counter, Histogram},
Key, KeyValue,
metrics::{Counter, Histogram},
};
use sqlx::PgPool;
use tokio_util::sync::CancellationToken;
use ulid::Ulid;
use crate::{
activity_tracker::{Message, SessionKind},
METER,
activity_tracker::{Message, SessionKind},
};
/// The maximum number of pending activity records before we flush them to the

View File

@@ -8,12 +8,12 @@ use std::convert::Infallible;
use aide::OperationIo;
use axum::{
Json,
extract::FromRequestParts,
response::{IntoResponse, Response},
Json,
};
use axum_extra::TypedHeader;
use headers::{authorization::Bearer, Authorization};
use headers::{Authorization, authorization::Bearer};
use hyper::StatusCode;
use mas_data_model::{Session, User};
use mas_storage::{BoxClock, BoxRepository, RepositoryError};

View File

@@ -10,10 +10,10 @@ use aide::{
transform::TransformOpenApi,
};
use axum::{
Json, Router,
extract::{FromRef, FromRequestParts, State},
http::HeaderName,
response::Html,
Json, Router,
};
use hyper::header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE};
use indexmap::IndexMap;
@@ -119,7 +119,8 @@ where
aide::generate::infer_responses(false);
aide::generate::in_context(|ctx| {
ctx.schema = schemars::gen::SchemaGenerator::new(schemars::gen::SchemaSettings::openapi3());
ctx.schema =
schemars::r#gen::SchemaGenerator::new(schemars::r#gen::SchemaSettings::openapi3());
});
let mut api = OpenApi::default();

View File

@@ -11,12 +11,12 @@ use std::num::NonZeroUsize;
use aide::OperationIo;
use axum::{
Json,
extract::{
rejection::{PathRejection, QueryRejection},
FromRequestParts, Path, Query,
rejection::{PathRejection, QueryRejection},
},
response::IntoResponse,
Json,
};
use axum_macros::FromRequestParts;
use hyper::StatusCode;

View File

@@ -7,9 +7,9 @@
//! Common schema definitions
use schemars::{
gen::SchemaGenerator,
schema::{InstanceType, Metadata, Schema, SchemaObject, StringValidation},
JsonSchema,
r#gen::SchemaGenerator,
schema::{InstanceType, Metadata, Schema, SchemaObject, StringValidation},
};
/// A type to use for schema definitions of ULIDs

View File

@@ -3,8 +3,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use axum::{response::IntoResponse, Json};
use aide::{OperationIo, transform::TransformOperation};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use ulid::Ulid;
@@ -85,7 +85,7 @@ mod tests {
use sqlx::PgPool;
use ulid::Ulid;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_get(pool: PgPool) {

View File

@@ -3,15 +3,15 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use aide::{OperationIo, transform::TransformOperation};
use axum::{
extract::{rejection::QueryRejection, Query},
response::IntoResponse,
Json,
extract::{Query, rejection::QueryRejection},
response::IntoResponse,
};
use axum_macros::FromRequestParts;
use hyper::StatusCode;
use mas_storage::{compat::CompatSessionFilter, Page};
use mas_storage::{Page, compat::CompatSessionFilter};
use schemars::JsonSchema;
use serde::Deserialize;
use ulid::Ulid;
@@ -222,7 +222,7 @@ mod tests {
use mas_data_model::Device;
use sqlx::PgPool;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_compat_session_list(pool: PgPool) {

View File

@@ -5,8 +5,8 @@
// Please see LICENSE in the repository root for full details.
use aide::axum::{
routing::{get_with, post_with},
ApiRouter,
routing::{get_with, post_with},
};
use axum::extract::{FromRef, FromRequestParts};
use mas_matrix::BoxHomeserverConnection;

View File

@@ -4,8 +4,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use axum::{response::IntoResponse, Json};
use aide::{OperationIo, transform::TransformOperation};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use ulid::Ulid;
@@ -83,7 +83,7 @@ mod tests {
use sqlx::PgPool;
use ulid::Ulid;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_get(pool: PgPool) {

View File

@@ -6,15 +6,15 @@
use std::str::FromStr;
use aide::{transform::TransformOperation, OperationIo};
use aide::{OperationIo, transform::TransformOperation};
use axum::{
extract::{rejection::QueryRejection, Query},
response::IntoResponse,
Json,
extract::{Query, rejection::QueryRejection},
response::IntoResponse,
};
use axum_macros::FromRequestParts;
use hyper::StatusCode;
use mas_storage::{oauth2::OAuth2SessionFilter, Page};
use mas_storage::{Page, oauth2::OAuth2SessionFilter};
use oauth2_types::scope::{Scope, ScopeToken};
use schemars::JsonSchema;
use serde::Deserialize;
@@ -314,7 +314,7 @@ mod tests {
use hyper::{Request, StatusCode};
use sqlx::PgPool;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_oauth2_simple_session_list(pool: PgPool) {

View File

@@ -3,8 +3,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use axum::{response::IntoResponse, Json};
use aide::{OperationIo, transform::TransformOperation};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use ulid::Ulid;
@@ -83,7 +83,7 @@ mod tests {
use ulid::Ulid;
use super::super::test_utils;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_get(pool: PgPool) {

View File

@@ -3,15 +3,15 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use aide::{OperationIo, transform::TransformOperation};
use axum::{
extract::{rejection::QueryRejection, Query},
response::IntoResponse,
Json,
extract::{Query, rejection::QueryRejection},
response::IntoResponse,
};
use axum_macros::FromRequestParts;
use hyper::StatusCode;
use mas_storage::{upstream_oauth2::UpstreamOAuthLinkFilter, Page};
use mas_storage::{Page, upstream_oauth2::UpstreamOAuthLinkFilter};
use schemars::JsonSchema;
use serde::Deserialize;
use ulid::Ulid;
@@ -199,7 +199,7 @@ mod tests {
use sqlx::PgPool;
use super::super::test_utils;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_list(pool: PgPool) {

View File

@@ -19,7 +19,7 @@ mod test_utils {
};
use mas_iana::jose::JsonWebSignatureAlg;
use mas_storage::upstream_oauth2::UpstreamOAuthProviderParams;
use oauth2_types::scope::{Scope, OPENID};
use oauth2_types::scope::{OPENID, Scope};
pub(crate) fn oidc_provider_params(name: &str) -> UpstreamOAuthProviderParams {
UpstreamOAuthProviderParams {

View File

@@ -5,13 +5,13 @@
use std::str::FromStr as _;
use aide::{transform::TransformOperation, NoApi, OperationIo};
use axum::{response::IntoResponse, Json};
use aide::{NoApi, OperationIo, transform::TransformOperation};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use mas_storage::{
BoxRng,
queue::{ProvisionUserJob, QueueJobRepositoryExt as _},
user::UserEmailFilter,
BoxRng,
};
use schemars::JsonSchema;
use serde::Deserialize;
@@ -165,7 +165,7 @@ mod tests {
use sqlx::PgPool;
use ulid::Ulid;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_create(pool: PgPool) {
setup();

View File

@@ -3,12 +3,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, NoApi, OperationIo};
use axum::{response::IntoResponse, Json};
use aide::{NoApi, OperationIo, transform::TransformOperation};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use mas_storage::{
queue::{ProvisionUserJob, QueueJobRepositoryExt as _},
BoxRng,
queue::{ProvisionUserJob, QueueJobRepositoryExt as _},
};
use ulid::Ulid;
@@ -83,7 +83,7 @@ mod tests {
use sqlx::PgPool;
use ulid::Ulid;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_delete(pool: PgPool) {
setup();

View File

@@ -3,8 +3,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use axum::{response::IntoResponse, Json};
use aide::{OperationIo, transform::TransformOperation};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use ulid::Ulid;
@@ -77,7 +77,7 @@ mod tests {
use sqlx::PgPool;
use ulid::Ulid;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_get(pool: PgPool) {

View File

@@ -3,15 +3,15 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use aide::{OperationIo, transform::TransformOperation};
use axum::{
extract::{rejection::QueryRejection, Query},
response::IntoResponse,
Json,
extract::{Query, rejection::QueryRejection},
response::IntoResponse,
};
use axum_macros::FromRequestParts;
use hyper::StatusCode;
use mas_storage::{user::UserEmailFilter, Page};
use mas_storage::{Page, user::UserEmailFilter};
use schemars::JsonSchema;
use serde::Deserialize;
use ulid::Ulid;
@@ -164,7 +164,7 @@ mod tests {
use hyper::{Request, StatusCode};
use sqlx::PgPool;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_list(pool: PgPool) {

View File

@@ -3,8 +3,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use axum::{response::IntoResponse, Json};
use aide::{OperationIo, transform::TransformOperation};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use ulid::Ulid;
@@ -80,7 +80,7 @@ mod tests {
use insta::assert_json_snapshot;
use sqlx::PgPool;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_get(pool: PgPool) {

View File

@@ -3,11 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use aide::{OperationIo, transform::TransformOperation};
use axum::{
extract::{rejection::QueryRejection, Query},
response::IntoResponse,
Json,
extract::{Query, rejection::QueryRejection},
response::IntoResponse,
};
use axum_macros::FromRequestParts;
use hyper::StatusCode;
@@ -191,7 +191,7 @@ mod tests {
use insta::assert_json_snapshot;
use sqlx::PgPool;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_user_session_list(pool: PgPool) {

View File

@@ -4,13 +4,13 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, NoApi, OperationIo};
use axum::{extract::State, response::IntoResponse, Json};
use aide::{NoApi, OperationIo, transform::TransformOperation};
use axum::{Json, extract::State, response::IntoResponse};
use hyper::StatusCode;
use mas_matrix::BoxHomeserverConnection;
use mas_storage::{
queue::{ProvisionUserJob, QueueJobRepositoryExt as _},
BoxRng,
queue::{ProvisionUserJob, QueueJobRepositoryExt as _},
};
use schemars::JsonSchema;
use serde::Deserialize;
@@ -179,10 +179,10 @@ pub async fn handler(
#[cfg(test)]
mod tests {
use hyper::{Request, StatusCode};
use mas_storage::{user::UserRepository, RepositoryAccess};
use mas_storage::{RepositoryAccess, user::UserRepository};
use sqlx::PgPool;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_add_user(pool: PgPool) {

View File

@@ -4,8 +4,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use axum::{extract::Path, response::IntoResponse, Json};
use aide::{OperationIo, transform::TransformOperation};
use axum::{Json, extract::Path, response::IntoResponse};
use hyper::StatusCode;
use schemars::JsonSchema;
use serde::Deserialize;

View File

@@ -4,12 +4,12 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, NoApi, OperationIo};
use axum::{response::IntoResponse, Json};
use aide::{NoApi, OperationIo, transform::TransformOperation};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use mas_storage::{
queue::{DeactivateUserJob, QueueJobRepositoryExt as _},
BoxRng,
queue::{DeactivateUserJob, QueueJobRepositoryExt as _},
};
use tracing::info;
use ulid::Ulid;
@@ -103,10 +103,10 @@ pub async fn handler(
mod tests {
use chrono::Duration;
use hyper::{Request, StatusCode};
use mas_storage::{user::UserRepository, Clock, RepositoryAccess};
use sqlx::{types::Json, PgPool};
use mas_storage::{Clock, RepositoryAccess, user::UserRepository};
use sqlx::{PgPool, types::Json};
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_deactivate_user(pool: PgPool) {

View File

@@ -4,8 +4,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use axum::{response::IntoResponse, Json};
use aide::{OperationIo, transform::TransformOperation};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use ulid::Ulid;

View File

@@ -4,15 +4,15 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use aide::{OperationIo, transform::TransformOperation};
use axum::{
extract::{rejection::QueryRejection, Query},
response::IntoResponse,
Json,
extract::{Query, rejection::QueryRejection},
response::IntoResponse,
};
use axum_macros::FromRequestParts;
use hyper::StatusCode;
use mas_storage::{user::UserFilter, Page};
use mas_storage::{Page, user::UserFilter};
use schemars::JsonSchema;
use serde::Deserialize;

View File

@@ -4,8 +4,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use axum::{response::IntoResponse, Json};
use aide::{OperationIo, transform::TransformOperation};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use ulid::Ulid;
@@ -92,10 +92,10 @@ pub async fn handler(
mod tests {
use chrono::Duration;
use hyper::{Request, StatusCode};
use mas_storage::{user::UserRepository, Clock, RepositoryAccess};
use mas_storage::{Clock, RepositoryAccess, user::UserRepository};
use sqlx::PgPool;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_lock_user(pool: PgPool) {

View File

@@ -4,8 +4,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use axum::{response::IntoResponse, Json};
use aide::{OperationIo, transform::TransformOperation};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use schemars::JsonSchema;
use serde::Deserialize;
@@ -100,10 +100,10 @@ pub async fn handler(
#[cfg(test)]
mod tests {
use hyper::{Request, StatusCode};
use mas_storage::{user::UserRepository, RepositoryAccess};
use mas_storage::{RepositoryAccess, user::UserRepository};
use sqlx::PgPool;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_change_can_request_admin(pool: PgPool) {

View File

@@ -4,8 +4,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, NoApi, OperationIo};
use axum::{extract::State, response::IntoResponse, Json};
use aide::{NoApi, OperationIo, transform::TransformOperation};
use axum::{Json, extract::State, response::IntoResponse};
use hyper::StatusCode;
use mas_storage::BoxRng;
use schemars::JsonSchema;
@@ -138,13 +138,13 @@ pub async fn handler(
#[cfg(test)]
mod tests {
use hyper::{Request, StatusCode};
use mas_storage::{user::UserPasswordRepository, RepositoryAccess};
use mas_storage::{RepositoryAccess, user::UserPasswordRepository};
use sqlx::PgPool;
use zeroize::Zeroizing;
use crate::{
passwords::PasswordManager,
test_utils::{setup, RequestBuilderExt, ResponseExt, TestState},
test_utils::{RequestBuilderExt, ResponseExt, TestState, setup},
};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]

View File

@@ -4,8 +4,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use aide::{transform::TransformOperation, OperationIo};
use axum::{extract::State, response::IntoResponse, Json};
use aide::{OperationIo, transform::TransformOperation};
use axum::{Json, extract::State, response::IntoResponse};
use hyper::StatusCode;
use mas_matrix::BoxHomeserverConnection;
use ulid::Ulid;
@@ -99,10 +99,10 @@ pub async fn handler(
mod tests {
use hyper::{Request, StatusCode};
use mas_matrix::{HomeserverConnection, ProvisionRequest};
use mas_storage::{user::UserRepository, RepositoryAccess};
use mas_storage::{RepositoryAccess, user::UserRepository};
use sqlx::PgPool;
use crate::test_utils::{setup, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup};
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_unlock_user(pool: PgPool) {

View File

@@ -39,7 +39,9 @@ pub enum Error {
#[error("The CAPTCHA provider returned an invalid response")]
InvalidResponse,
#[error("The hostname in the CAPTCHA response ({got:?}) does not match the site hostname ({expected:?})")]
#[error(
"The hostname in the CAPTCHA response ({got:?}) does not match the site hostname ({expected:?})"
)]
HostnameMismatch { expected: String, got: String },
#[error("The CAPTCHA provider returned an error")]

View File

@@ -5,9 +5,9 @@
// Please see LICENSE in the repository root for full details.
use axum::{
extract::{rejection::JsonRejection, State},
response::IntoResponse,
Json,
extract::{State, rejection::JsonRejection},
response::IntoResponse,
};
use axum_extra::{extract::WithRejection, typed_header::TypedHeader};
use chrono::Duration;
@@ -18,23 +18,23 @@ use mas_data_model::{
};
use mas_matrix::BoxHomeserverConnection;
use mas_storage::{
BoxClock, BoxRepository, BoxRng, Clock, RepositoryAccess,
compat::{
CompatAccessTokenRepository, CompatRefreshTokenRepository, CompatSessionRepository,
CompatSsoLoginRepository,
},
user::{UserPasswordRepository, UserRepository},
BoxClock, BoxRepository, BoxRng, Clock, RepositoryAccess,
};
use rand::{CryptoRng, RngCore};
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, skip_serializing_none, DurationMilliSeconds};
use serde_with::{DurationMilliSeconds, serde_as, skip_serializing_none};
use thiserror::Error;
use zeroize::Zeroizing;
use super::MatrixError;
use crate::{
impl_from_error_for_route, passwords::PasswordManager, rate_limit::PasswordCheckLimitedError,
BoundActivityTracker, Limiter, RequesterFingerprint,
BoundActivityTracker, Limiter, RequesterFingerprint, impl_from_error_for_route,
passwords::PasswordManager, rate_limit::PasswordCheckLimitedError,
};
#[derive(Debug, Serialize)]
@@ -520,7 +520,7 @@ mod tests {
use sqlx::PgPool;
use super::*;
use crate::test_utils::{setup, test_site_config, RequestBuilderExt, ResponseExt, TestState};
use crate::test_utils::{RequestBuilderExt, ResponseExt, TestState, setup, test_site_config};
/// Test that the server advertises the right login flows.
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]

View File

@@ -13,16 +13,16 @@ use axum::{
};
use chrono::Duration;
use mas_axum_utils::{
FancyError, SessionInfoExt,
cookies::CookieJar,
csrf::{CsrfExt, ProtectedForm},
FancyError, SessionInfoExt,
};
use mas_data_model::Device;
use mas_matrix::BoxHomeserverConnection;
use mas_router::{CompatLoginSsoAction, UrlBuilder};
use mas_storage::{
compat::{CompatSessionRepository, CompatSsoLoginRepository},
BoxClock, BoxRepository, BoxRng, Clock, RepositoryAccess,
compat::{CompatSessionRepository, CompatSsoLoginRepository},
};
use mas_templates::{CompatSsoContext, ErrorContext, TemplateContext, Templates};
use serde::{Deserialize, Serialize};

View File

@@ -11,7 +11,7 @@ use axum::{
use hyper::StatusCode;
use mas_axum_utils::sentry::SentryEventID;
use mas_router::{CompatLoginSsoAction, CompatLoginSsoComplete, UrlBuilder};
use mas_storage::{compat::CompatSsoLoginRepository, BoxClock, BoxRepository, BoxRng};
use mas_storage::{BoxClock, BoxRepository, BoxRng, compat::CompatSsoLoginRepository};
use rand::distributions::{Alphanumeric, DistString};
use serde::Deserialize;
use serde_with::serde;

View File

@@ -4,21 +4,21 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use axum::{response::IntoResponse, Json};
use axum::{Json, response::IntoResponse};
use axum_extra::typed_header::TypedHeader;
use headers::{authorization::Bearer, Authorization};
use headers::{Authorization, authorization::Bearer};
use hyper::StatusCode;
use mas_axum_utils::sentry::SentryEventID;
use mas_data_model::TokenType;
use mas_storage::{
BoxClock, BoxRepository, BoxRng, Clock, RepositoryAccess,
compat::{CompatAccessTokenRepository, CompatSessionRepository},
queue::{QueueJobRepositoryExt as _, SyncDevicesJob},
BoxClock, BoxRepository, BoxRng, Clock, RepositoryAccess,
};
use thiserror::Error;
use super::MatrixError;
use crate::{impl_from_error_for_route, BoundActivityTracker};
use crate::{BoundActivityTracker, impl_from_error_for_route};
#[derive(Error, Debug)]
pub enum RouteError {

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use axum::{response::IntoResponse, Json};
use axum::{Json, response::IntoResponse};
use hyper::StatusCode;
use serde::Serialize;

View File

@@ -4,21 +4,21 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use axum::{extract::State, response::IntoResponse, Json};
use axum::{Json, extract::State, response::IntoResponse};
use chrono::Duration;
use hyper::StatusCode;
use mas_axum_utils::sentry::SentryEventID;
use mas_data_model::{SiteConfig, TokenFormatError, TokenType};
use mas_storage::{
compat::{CompatAccessTokenRepository, CompatRefreshTokenRepository, CompatSessionRepository},
BoxClock, BoxRepository, BoxRng, Clock,
compat::{CompatAccessTokenRepository, CompatRefreshTokenRepository, CompatSessionRepository},
};
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DurationMilliSeconds};
use serde_with::{DurationMilliSeconds, serde_as};
use thiserror::Error;
use super::MatrixError;
use crate::{impl_from_error_for_route, BoundActivityTracker};
use crate::{BoundActivityTracker, impl_from_error_for_route};
#[derive(Debug, Deserialize)]
pub struct RequestBody {

View File

@@ -9,24 +9,24 @@
use std::{net::IpAddr, ops::Deref, sync::Arc};
use async_graphql::{
extensions::Tracing,
http::{playground_source, GraphQLPlaygroundConfig, MultipartOptions},
EmptySubscription, InputObject,
extensions::Tracing,
http::{GraphQLPlaygroundConfig, MultipartOptions, playground_source},
};
use axum::{
Extension, Json,
body::Body,
extract::{RawQuery, State as AxumState},
http::StatusCode,
response::{Html, IntoResponse, Response},
Extension, Json,
};
use axum_extra::typed_header::TypedHeader;
use chrono::{DateTime, Utc};
use futures_util::TryStreamExt;
use headers::{authorization::Bearer, Authorization, ContentType, HeaderValue};
use headers::{Authorization, ContentType, HeaderValue, authorization::Bearer};
use hyper::header::CACHE_CONTROL;
use mas_axum_utils::{
cookies::CookieJar, sentry::SentryEventID, FancyError, SessionInfo, SessionInfoExt,
FancyError, SessionInfo, SessionInfoExt, cookies::CookieJar, sentry::SentryEventID,
};
use mas_data_model::{BrowserSession, Session, SiteConfig, User};
use mas_matrix::HomeserverConnection;
@@ -35,10 +35,10 @@ use mas_router::UrlBuilder;
use mas_storage::{BoxClock, BoxRepository, BoxRng, Clock, RepositoryError, SystemClock};
use mas_storage_pg::PgRepository;
use opentelemetry_semantic_conventions::trace::{GRAPHQL_DOCUMENT, GRAPHQL_OPERATION_NAME};
use rand::{thread_rng, SeedableRng};
use rand::{SeedableRng, thread_rng};
use rand_chacha::ChaChaRng;
use sqlx::PgPool;
use tracing::{info_span, Instrument};
use tracing::{Instrument, info_span};
use ulid::Ulid;
mod model;
@@ -53,8 +53,8 @@ use self::{
query::Query,
};
use crate::{
impl_from_error_for_route, passwords::PasswordManager, BoundActivityTracker, Limiter,
RequesterFingerprint,
BoundActivityTracker, Limiter, RequesterFingerprint, impl_from_error_for_route,
passwords::PasswordManager,
};
#[cfg(test)]
@@ -276,7 +276,7 @@ async fn get_requester(
};
// If there is a user for this session, check that it is not locked
let user_valid = user.as_ref().map_or(true, User::is_valid);
let user_valid = user.as_ref().is_none_or(User::is_valid);
if !token.is_valid(clock.now()) || !session.is_valid() || !user_valid {
return Err(RouteError::InvalidToken);

View File

@@ -5,13 +5,13 @@
// Please see LICENSE in the repository root for full details.
use async_graphql::{
connection::{query, Connection, Edge, OpaqueCursor},
Context, Description, Object, ID,
Context, Description, ID, Object,
connection::{Connection, Edge, OpaqueCursor, query},
};
use chrono::{DateTime, Utc};
use mas_data_model::Device;
use mas_storage::{
app_session::AppSessionFilter, user::BrowserSessionRepository, Pagination, RepositoryAccess,
Pagination, RepositoryAccess, app_session::AppSessionFilter, user::BrowserSessionRepository,
};
use super::{

View File

@@ -5,7 +5,7 @@
// Please see LICENSE in the repository root for full details.
use anyhow::Context as _;
use async_graphql::{Context, Description, Enum, Object, ID};
use async_graphql::{Context, Description, Enum, ID, Object};
use chrono::{DateTime, Utc};
use mas_data_model::Device;
use mas_storage::{compat::CompatSessionRepository, user::UserRepository};

View File

@@ -24,7 +24,7 @@ pub use self::{
cursor::{Cursor, NodeCursor},
node::{Node, NodeType},
oauth::{OAuth2Client, OAuth2Session},
site_config::{SiteConfig, SITE_CONFIG_ID},
site_config::{SITE_CONFIG_ID, SiteConfig},
upstream_oauth::{UpstreamOAuth2Link, UpstreamOAuth2Provider},
users::{AppSession, User, UserEmail, UserEmailAuthentication, UserRecoveryTicket},
viewer::{Anonymous, Viewer, ViewerSession},

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use async_graphql::{Interface, ID};
use async_graphql::{ID, Interface};
use serde::{Deserialize, Serialize};
use thiserror::Error;
use ulid::Ulid;

View File

@@ -5,7 +5,7 @@
// Please see LICENSE in the repository root for full details.
use anyhow::Context as _;
use async_graphql::{Context, Description, Enum, Object, ID};
use async_graphql::{Context, Description, Enum, ID, Object};
use chrono::{DateTime, Utc};
use mas_storage::{oauth2::OAuth2ClientRepository, user::BrowserSessionRepository};
use oauth2_types::{oidc::ApplicationType, scope::Scope};
@@ -13,7 +13,7 @@ use ulid::Ulid;
use url::Url;
use super::{BrowserSession, NodeType, SessionState, User, UserAgent};
use crate::graphql::{state::ContextExt, UserId};
use crate::graphql::{UserId, state::ContextExt};
/// An OAuth 2.0 session represents a client session which used the OAuth APIs
/// to login.

View File

@@ -6,7 +6,7 @@
#![allow(clippy::str_to_string)] // ComplexObject macro uses &str.to_string()
use async_graphql::{ComplexObject, Enum, SimpleObject, ID};
use async_graphql::{ComplexObject, Enum, ID, SimpleObject};
use url::Url;
pub const SITE_CONFIG_ID: &str = "site_config";

View File

@@ -5,7 +5,7 @@
// Please see LICENSE in the repository root for full details.
use anyhow::Context as _;
use async_graphql::{Context, Object, ID};
use async_graphql::{Context, ID, Object};
use chrono::{DateTime, Utc};
use mas_storage::{upstream_oauth2::UpstreamOAuthProviderRepository, user::UserRepository};
use url::Url;

View File

@@ -6,27 +6,27 @@
use anyhow::Context as _;
use async_graphql::{
connection::{query, Connection, Edge, OpaqueCursor},
Context, Description, Enum, Object, Union, ID,
Context, Description, Enum, ID, Object, Union,
connection::{Connection, Edge, OpaqueCursor, query},
};
use chrono::{DateTime, Utc};
use mas_data_model::Device;
use mas_storage::{
Pagination, RepositoryAccess,
app_session::AppSessionFilter,
compat::{CompatSessionFilter, CompatSsoLoginFilter, CompatSsoLoginRepository},
oauth2::{OAuth2SessionFilter, OAuth2SessionRepository},
upstream_oauth2::{UpstreamOAuthLinkFilter, UpstreamOAuthLinkRepository},
user::{BrowserSessionFilter, BrowserSessionRepository, UserEmailFilter, UserEmailRepository},
Pagination, RepositoryAccess,
};
use super::{
compat_sessions::{CompatSessionType, CompatSsoLogin},
matrix::MatrixUser,
BrowserSession, CompatSession, Cursor, NodeCursor, NodeType, OAuth2Session,
PreloadedTotalCount, SessionState, UpstreamOAuth2Link,
compat_sessions::{CompatSessionType, CompatSsoLogin},
matrix::MatrixUser,
};
use crate::graphql::{state::ContextExt, DateFilter};
use crate::graphql::{DateFilter, state::ContextExt};
#[derive(Description)]
/// A user is an individual's account.

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use async_graphql::{Object, ID};
use async_graphql::{ID, Object};
/// An anonymous viewer
#[derive(Default, Clone, Copy)]

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use async_graphql::{Context, Enum, InputObject, Object, ID};
use async_graphql::{Context, Enum, ID, InputObject, Object};
use mas_storage::RepositoryAccess;
use crate::graphql::{

View File

@@ -5,11 +5,11 @@
// Please see LICENSE in the repository root for full details.
use anyhow::Context as _;
use async_graphql::{Context, Enum, InputObject, Object, ID};
use async_graphql::{Context, Enum, ID, InputObject, Object};
use mas_storage::{
RepositoryAccess,
compat::CompatSessionRepository,
queue::{QueueJobRepositoryExt as _, SyncDevicesJob},
RepositoryAccess,
};
use crate::graphql::{

View File

@@ -5,12 +5,12 @@
// Please see LICENSE in the repository root for full details.
use anyhow::Context as _;
use async_graphql::{Context, Description, Enum, InputObject, Object, ID};
use async_graphql::{Context, Description, Enum, ID, InputObject, Object};
use crate::graphql::{
UserId,
model::{NodeType, User},
state::ContextExt,
UserId,
};
#[derive(Default)]

View File

@@ -5,17 +5,17 @@
// Please see LICENSE in the repository root for full details.
use anyhow::Context as _;
use async_graphql::{Context, Description, Enum, InputObject, Object, ID};
use async_graphql::{Context, Description, Enum, ID, InputObject, Object};
use chrono::Duration;
use mas_data_model::{Device, TokenType};
use mas_storage::{
RepositoryAccess,
oauth2::{
OAuth2AccessTokenRepository, OAuth2ClientRepository, OAuth2RefreshTokenRepository,
OAuth2SessionRepository,
},
queue::{QueueJobRepositoryExt as _, SyncDevicesJob},
user::UserRepository,
RepositoryAccess,
};
use oauth2_types::scope::Scope;

View File

@@ -5,7 +5,7 @@
// Please see LICENSE in the repository root for full details.
use anyhow::Context as _;
use async_graphql::{Context, Description, Enum, InputObject, Object, ID};
use async_graphql::{Context, Description, Enum, ID, InputObject, Object};
use mas_storage::{
queue::{
DeactivateUserJob, ProvisionUserJob, QueueJobRepositoryExt as _,
@@ -19,9 +19,9 @@ use url::Url;
use zeroize::Zeroizing;
use crate::graphql::{
UserId,
model::{NodeType, User},
state::ContextExt,
UserId,
};
#[derive(Default)]
@@ -679,7 +679,7 @@ impl UserMutations {
let Some(current_password_attempt) = input.current_password else {
return Err(async_graphql::Error::new(
"You must supply `currentPassword` to change your own password if you are not an administrator"
"You must supply `currentPassword` to change your own password if you are not an administrator",
));
};

View File

@@ -5,12 +5,12 @@
// Please see LICENSE in the repository root for full details.
use anyhow::Context as _;
use async_graphql::{Context, Description, Enum, InputObject, Object, ID};
use async_graphql::{Context, Description, Enum, ID, InputObject, Object};
use mas_i18n::DataLocale;
use mas_storage::{
RepositoryAccess,
queue::{ProvisionUserJob, QueueJobRepositoryExt as _, SendEmailAuthenticationCodeJob},
user::{UserEmailFilter, UserEmailRepository, UserRepository},
RepositoryAccess,
};
use crate::graphql::{

View File

@@ -4,7 +4,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use async_graphql::{Context, MergedObject, Object, ID};
use async_graphql::{Context, ID, MergedObject, Object};
use crate::graphql::{
model::{

View File

@@ -4,19 +4,19 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
use async_graphql::{Context, Object, Union, ID};
use async_graphql::{Context, ID, Object, Union};
use mas_data_model::Device;
use mas_storage::{
Pagination, RepositoryAccess,
compat::{CompatSessionFilter, CompatSessionRepository},
oauth2::OAuth2SessionFilter,
Pagination, RepositoryAccess,
};
use oauth2_types::scope::Scope;
use crate::graphql::{
UserId,
model::{CompatSession, NodeType, OAuth2Session},
state::ContextExt,
UserId,
};
#[derive(Default)]

View File

@@ -5,10 +5,10 @@
// Please see LICENSE in the repository root for full details.
use async_graphql::{
connection::{query, Connection, Edge, OpaqueCursor},
Context, Object, ID,
Context, ID, Object,
connection::{Connection, Edge, OpaqueCursor, query},
};
use mas_storage::{upstream_oauth2::UpstreamOAuthProviderFilter, Pagination, RepositoryAccess};
use mas_storage::{Pagination, RepositoryAccess, upstream_oauth2::UpstreamOAuthProviderFilter};
use crate::graphql::{
model::{

View File

@@ -5,15 +5,15 @@
// Please see LICENSE in the repository root for full details.
use async_graphql::{
connection::{query, Connection, Edge, OpaqueCursor},
Context, Enum, Object, ID,
Context, Enum, ID, Object,
connection::{Connection, Edge, OpaqueCursor, query},
};
use mas_storage::{user::UserFilter, Pagination};
use mas_storage::{Pagination, user::UserFilter};
use crate::graphql::{
UserId,
model::{Cursor, NodeCursor, NodeType, PreloadedTotalCount, User},
state::ContextExt as _,
UserId,
};
#[derive(Default)]

View File

@@ -10,7 +10,7 @@ use mas_policy::Policy;
use mas_router::UrlBuilder;
use mas_storage::{BoxClock, BoxRepository, BoxRng, RepositoryError};
use crate::{graphql::Requester, passwords::PasswordManager, Limiter};
use crate::{Limiter, graphql::Requester, passwords::PasswordManager};
#[async_trait::async_trait]
pub trait State {

View File

@@ -10,19 +10,19 @@ use mas_data_model::{AccessToken, Client, TokenType, User};
use mas_matrix::{HomeserverConnection, ProvisionRequest};
use mas_router::SimpleRoute;
use mas_storage::{
oauth2::{OAuth2AccessTokenRepository, OAuth2ClientRepository},
RepositoryAccess,
oauth2::{OAuth2AccessTokenRepository, OAuth2ClientRepository},
};
use oauth2_types::{
registration::ClientRegistrationResponse,
requests::AccessTokenResponse,
scope::{Scope, ScopeToken, OPENID},
scope::{OPENID, Scope, ScopeToken},
};
use sqlx::PgPool;
use crate::{
test_utils,
test_utils::{setup, RequestBuilderExt, ResponseExt, TestState},
test_utils::{RequestBuilderExt, ResponseExt, TestState, setup},
};
async fn create_test_client(state: &TestState) -> Client {

Some files were not shown because too many files have changed in this diff Show More