You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-31 09:24:31 +03:00
Move to Rust edition 2021
Also bump MSRV to 1.56 and use the same clippy lints in every crate
This commit is contained in:
4
.github/workflows/check.yaml
vendored
4
.github/workflows/check.yaml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
- name: Install toolchain
|
- name: Install toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: "1.54.0" # MSRV
|
toolchain: "1.56.0" # MSRV
|
||||||
target: x86_64-unknown-linux-musl
|
target: x86_64-unknown-linux-musl
|
||||||
profile: minimal
|
profile: minimal
|
||||||
override: true
|
override: true
|
||||||
@ -192,7 +192,7 @@ jobs:
|
|||||||
fail-fast: false # Continue other jobs if one fails to help filling the cache
|
fail-fast: false # Continue other jobs if one fails to help filling the cache
|
||||||
matrix:
|
matrix:
|
||||||
toolchain:
|
toolchain:
|
||||||
- "1.54.0" # MSRV
|
- "1.56.0" # MSRV
|
||||||
- stable
|
- stable
|
||||||
- beta
|
- beta
|
||||||
- nightly
|
- nightly
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
|
|
||||||
members = ["crates/*"]
|
members = ["crates/*"]
|
||||||
|
|
||||||
resolver = "2"
|
|
||||||
|
@ -1 +1 @@
|
|||||||
msrv = "1.54.0"
|
msrv = "1.56.0"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
name = "mas-cli"
|
name = "mas-cli"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Quentin Gliech <quenting@element.io>"]
|
authors = ["Quentin Gliech <quenting@element.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
name = "mas-config"
|
name = "mas-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Quentin Gliech <quenting@element.io>"]
|
authors = ["Quentin Gliech <quenting@element.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
use std::{convert::TryInto, path::PathBuf, time::Duration};
|
use std::{path::PathBuf, time::Duration};
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
@ -12,6 +12,14 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
#![deny(clippy::all)]
|
||||||
|
#![deny(rustdoc::broken_intra_doc_links)]
|
||||||
|
#![warn(clippy::pedantic)]
|
||||||
|
#![allow(clippy::module_name_repetitions)]
|
||||||
|
#![allow(clippy::missing_panics_doc)]
|
||||||
|
#![allow(clippy::missing_errors_doc)]
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use jwt_compact::{
|
use jwt_compact::{
|
||||||
@ -67,6 +65,7 @@ pub struct Jwks {
|
|||||||
pub struct KeySet(Vec<Key>);
|
pub struct KeySet(Vec<Key>);
|
||||||
|
|
||||||
impl KeySet {
|
impl KeySet {
|
||||||
|
#[must_use]
|
||||||
pub fn to_public_jwks(&self) -> Jwks {
|
pub fn to_public_jwks(&self) -> Jwks {
|
||||||
let keys = self.0.iter().map(Key::to_public_jwk).collect();
|
let keys = self.0.iter().map(Key::to_public_jwk).collect();
|
||||||
Jwks { keys }
|
Jwks { keys }
|
||||||
@ -345,6 +344,7 @@ pub struct OAuth2Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl OAuth2Config {
|
impl OAuth2Config {
|
||||||
|
#[must_use]
|
||||||
pub fn discovery_url(&self) -> Url {
|
pub fn discovery_url(&self) -> Url {
|
||||||
self.issuer
|
self.issuer
|
||||||
.join(".well-known/openid-configuration")
|
.join(".well-known/openid-configuration")
|
||||||
|
@ -107,10 +107,10 @@ impl ConfigurationSection<'_> for TelemetryConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn generate() -> anyhow::Result<Self> {
|
async fn generate() -> anyhow::Result<Self> {
|
||||||
Ok(Default::default())
|
Ok(Self::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test() -> Self {
|
fn test() -> Self {
|
||||||
Default::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
name = "mas-core"
|
name = "mas-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Quentin Gliech <quenting@element.io>"]
|
authors = ["Quentin Gliech <quenting@element.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -12,10 +12,7 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
use std::{
|
use std::collections::{HashMap, HashSet};
|
||||||
collections::{HashMap, HashSet},
|
|
||||||
convert::TryFrom,
|
|
||||||
};
|
|
||||||
|
|
||||||
use chrono::Duration;
|
use chrono::Duration;
|
||||||
use hyper::{
|
use hyper::{
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
|
||||||
|
|
||||||
use hyper::http::uri::{Parts, PathAndQuery, Uri};
|
use hyper::http::uri::{Parts, PathAndQuery, Uri};
|
||||||
use mas_config::{CookiesConfig, CsrfConfig};
|
use mas_config::{CookiesConfig, CsrfConfig};
|
||||||
use mas_data_model::{errors::WrapFormError, BrowserSession, StorageBackend};
|
use mas_data_model::{errors::WrapFormError, BrowserSession, StorageBackend};
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
|
||||||
|
|
||||||
use hyper::http::uri::{Parts, PathAndQuery};
|
use hyper::http::uri::{Parts, PathAndQuery};
|
||||||
use mas_config::{CookiesConfig, CsrfConfig};
|
use mas_config::{CookiesConfig, CsrfConfig};
|
||||||
use mas_data_model::{BrowserSession, StorageBackend};
|
use mas_data_model::{BrowserSession, StorageBackend};
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
|
||||||
|
|
||||||
use argon2::Argon2;
|
use argon2::Argon2;
|
||||||
use hyper::http::uri::{Parts, PathAndQuery, Uri};
|
use hyper::http::uri::{Parts, PathAndQuery, Uri};
|
||||||
use mas_config::{CookiesConfig, CsrfConfig};
|
use mas_config::{CookiesConfig, CsrfConfig};
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use chrono::{DateTime, Duration, Utc};
|
use chrono::{DateTime, Duration, Utc};
|
||||||
use mas_data_model::{AccessToken, Authentication, BrowserSession, Client, Session, User};
|
use mas_data_model::{AccessToken, Authentication, BrowserSession, Client, Session, User};
|
||||||
|
@ -14,10 +14,7 @@
|
|||||||
|
|
||||||
#![allow(clippy::unused_async)]
|
#![allow(clippy::unused_async)]
|
||||||
|
|
||||||
use std::{
|
use std::num::NonZeroU32;
|
||||||
convert::{TryFrom, TryInto},
|
|
||||||
num::NonZeroU32,
|
|
||||||
};
|
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
use std::{borrow::BorrowMut, convert::TryInto};
|
use std::borrow::BorrowMut;
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use argon2::Argon2;
|
use argon2::Argon2;
|
||||||
|
@ -37,8 +37,6 @@
|
|||||||
|
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
use std::convert::TryInto;
|
|
||||||
|
|
||||||
use crc::{Crc, CRC_32_ISO_HDLC};
|
use crc::{Crc, CRC_32_ISO_HDLC};
|
||||||
use oauth2_types::requests::TokenTypeHint;
|
use oauth2_types::requests::TokenTypeHint;
|
||||||
use rand::{distributions::Alphanumeric, Rng};
|
use rand::{distributions::Alphanumeric, Rng};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
name = "mas-data-model"
|
name = "mas-data-model"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Quentin Gliech <quenting@element.io>"]
|
authors = ["Quentin Gliech <quenting@element.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -12,6 +12,15 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
#![deny(clippy::all)]
|
||||||
|
#![deny(rustdoc::broken_intra_doc_links)]
|
||||||
|
#![warn(clippy::pedantic)]
|
||||||
|
#![allow(clippy::module_name_repetitions)]
|
||||||
|
#![allow(clippy::missing_panics_doc)]
|
||||||
|
#![allow(clippy::missing_errors_doc)]
|
||||||
|
#![allow(clippy::trait_duplication_in_bounds)]
|
||||||
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub(crate) mod oauth2;
|
pub(crate) mod oauth2;
|
||||||
pub(crate) mod tokens;
|
pub(crate) mod tokens;
|
||||||
|
@ -30,6 +30,7 @@ pub struct Pkce {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Pkce {
|
impl Pkce {
|
||||||
|
#[must_use]
|
||||||
pub fn new(challenge_method: CodeChallengeMethod, challenge: String) -> Self {
|
pub fn new(challenge_method: CodeChallengeMethod, challenge: String) -> Self {
|
||||||
Pkce {
|
Pkce {
|
||||||
challenge_method,
|
challenge_method,
|
||||||
@ -37,6 +38,7 @@ impl Pkce {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn verify(&self, verifier: &str) -> bool {
|
pub fn verify(&self, verifier: &str) -> bool {
|
||||||
self.challenge_method.verify(&self.challenge, verifier)
|
self.challenge_method.verify(&self.challenge, verifier)
|
||||||
}
|
}
|
||||||
@ -77,6 +79,7 @@ impl<T: StorageBackend> Default for AuthorizationGrantStage<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: StorageBackend> AuthorizationGrantStage<T> {
|
impl<T: StorageBackend> AuthorizationGrantStage<T> {
|
||||||
|
#[must_use]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::Pending
|
Self::Pending
|
||||||
}
|
}
|
||||||
@ -119,7 +122,7 @@ impl<T: StorageBackend> AuthorizationGrantStage<T> {
|
|||||||
|
|
||||||
impl<S: StorageBackendMarker> From<AuthorizationGrantStage<S>> for AuthorizationGrantStage<()> {
|
impl<S: StorageBackendMarker> From<AuthorizationGrantStage<S>> for AuthorizationGrantStage<()> {
|
||||||
fn from(s: AuthorizationGrantStage<S>) -> Self {
|
fn from(s: AuthorizationGrantStage<S>) -> Self {
|
||||||
use AuthorizationGrantStage::*;
|
use AuthorizationGrantStage::{Cancelled, Exchanged, Fulfilled, Pending};
|
||||||
match s {
|
match s {
|
||||||
Pending => Pending,
|
Pending => Pending,
|
||||||
Fulfilled {
|
Fulfilled {
|
||||||
|
@ -30,6 +30,7 @@ impl<T: StorageBackend> User<T>
|
|||||||
where
|
where
|
||||||
T::UserData: Default,
|
T::UserData: Default,
|
||||||
{
|
{
|
||||||
|
#[must_use]
|
||||||
pub fn samples() -> Vec<Self> {
|
pub fn samples() -> Vec<Self> {
|
||||||
vec![User {
|
vec![User {
|
||||||
data: Default::default(),
|
data: Default::default(),
|
||||||
@ -92,6 +93,7 @@ where
|
|||||||
T::BrowserSessionData: Default,
|
T::BrowserSessionData: Default,
|
||||||
T::UserData: Default,
|
T::UserData: Default,
|
||||||
{
|
{
|
||||||
|
#[must_use]
|
||||||
pub fn samples() -> Vec<Self> {
|
pub fn samples() -> Vec<Self> {
|
||||||
User::<T>::samples()
|
User::<T>::samples()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
name = "oauth2-types"
|
name = "oauth2-types"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Quentin Gliech <quenting@element.io>"]
|
authors = ["Quentin Gliech <quenting@element.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
name = "mas-static-files"
|
name = "mas-static-files"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Quentin Gliech <quenting@element.io>"]
|
authors = ["Quentin Gliech <quenting@element.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -27,7 +27,7 @@ use warp::{filters::BoxedFilter, Filter, Reply};
|
|||||||
|
|
||||||
#[cfg(not(feature = "dev"))]
|
#[cfg(not(feature = "dev"))]
|
||||||
mod builtin {
|
mod builtin {
|
||||||
use std::{convert::TryInto, fmt::Write, str::FromStr};
|
use std::{fmt::Write, str::FromStr};
|
||||||
|
|
||||||
use headers::{ContentLength, ContentType, ETag, HeaderMapExt};
|
use headers::{ContentLength, ContentType, ETag, HeaderMapExt};
|
||||||
use rust_embed::RustEmbed;
|
use rust_embed::RustEmbed;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
name = "mas-templates"
|
name = "mas-templates"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Quentin Gliech <quenting@element.io>"]
|
authors = ["Quentin Gliech <quenting@element.io>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
Reference in New Issue
Block a user