You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-23 11:02:35 +03:00
Fix minor code style issues
This commit is contained in:
@@ -93,7 +93,8 @@ pub struct ErroredForm<FieldType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T> ErroredForm<T> {
|
impl<T> ErroredForm<T> {
|
||||||
#[must_use] pub fn new() -> Self {
|
#[must_use]
|
||||||
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
form: Vec::new(),
|
form: Vec::new(),
|
||||||
fields: Vec::new(),
|
fields: Vec::new(),
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ impl EncryptedCookie {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn maybe_encrypted<T>(
|
#[must_use]
|
||||||
|
pub fn maybe_encrypted<T>(
|
||||||
options: &CookiesConfig,
|
options: &CookiesConfig,
|
||||||
) -> impl Filter<Extract = (Option<T>,), Error = Infallible> + Clone + Send + Sync + 'static
|
) -> impl Filter<Extract = (Option<T>,), Error = Infallible> + Clone + Send + Sync + 'static
|
||||||
where
|
where
|
||||||
@@ -83,7 +84,8 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn encrypted<T>(
|
#[must_use]
|
||||||
|
pub fn encrypted<T>(
|
||||||
options: &CookiesConfig,
|
options: &CookiesConfig,
|
||||||
) -> impl Filter<Extract = (T,), Error = Rejection> + Clone + Send + Sync + 'static
|
) -> impl Filter<Extract = (T,), Error = Rejection> + Clone + Send + Sync + 'static
|
||||||
where
|
where
|
||||||
@@ -97,7 +99,8 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn with_cookie_saver(
|
#[must_use]
|
||||||
|
pub fn with_cookie_saver(
|
||||||
options: &CookiesConfig,
|
options: &CookiesConfig,
|
||||||
) -> impl Filter<Extract = (EncryptedCookieSaver,), Error = Infallible> + Clone + Send + Sync + 'static
|
) -> impl Filter<Extract = (EncryptedCookieSaver,), Error = Infallible> + Clone + Send + Sync + 'static
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ impl CsrfToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the value to include in HTML forms
|
/// Get the value to include in HTML forms
|
||||||
#[must_use] pub fn form_value(&self) -> String {
|
#[must_use]
|
||||||
|
pub fn form_value(&self) -> String {
|
||||||
BASE64URL_NOPAD.encode(&self.token[..])
|
BASE64URL_NOPAD.encode(&self.token[..])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +113,8 @@ impl<T> CsrfForm<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn csrf_token(
|
#[must_use]
|
||||||
|
pub fn csrf_token(
|
||||||
cookies_config: &CookiesConfig,
|
cookies_config: &CookiesConfig,
|
||||||
) -> impl Filter<Extract = (CsrfToken,), Error = Rejection> + Clone + Send + Sync + 'static {
|
) -> impl Filter<Extract = (CsrfToken,), Error = Rejection> + Clone + Send + Sync + 'static {
|
||||||
super::cookies::encrypted(cookies_config).and_then(move |token: CsrfToken| async move {
|
super::cookies::encrypted(cookies_config).and_then(move |token: CsrfToken| async move {
|
||||||
@@ -121,7 +123,8 @@ impl<T> CsrfForm<T> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn updated_csrf_token(
|
#[must_use]
|
||||||
|
pub fn updated_csrf_token(
|
||||||
cookies_config: &CookiesConfig,
|
cookies_config: &CookiesConfig,
|
||||||
csrf_config: &CsrfConfig,
|
csrf_config: &CsrfConfig,
|
||||||
) -> impl Filter<Extract = (CsrfToken,), Error = Rejection> + Clone + Send + Sync + 'static {
|
) -> impl Filter<Extract = (CsrfToken,), Error = Rejection> + Clone + Send + Sync + 'static {
|
||||||
@@ -144,7 +147,8 @@ impl<T> CsrfForm<T> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn protected_form<T>(
|
#[must_use]
|
||||||
|
pub fn protected_form<T>(
|
||||||
cookies_config: &CookiesConfig,
|
cookies_config: &CookiesConfig,
|
||||||
) -> impl Filter<Extract = (T,), Error = Rejection> + Clone + Send + Sync + 'static
|
) -> impl Filter<Extract = (T,), Error = Rejection> + Clone + Send + Sync + 'static
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -33,14 +33,16 @@ use crate::{
|
|||||||
templates::Templates,
|
templates::Templates,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[must_use] pub fn with_templates(
|
#[must_use]
|
||||||
|
pub fn with_templates(
|
||||||
templates: &Templates,
|
templates: &Templates,
|
||||||
) -> impl Filter<Extract = (Templates,), Error = Infallible> + Clone + Send + Sync + 'static {
|
) -> impl Filter<Extract = (Templates,), Error = Infallible> + Clone + Send + Sync + 'static {
|
||||||
let templates = templates.clone();
|
let templates = templates.clone();
|
||||||
warp::any().map(move || templates.clone())
|
warp::any().map(move || templates.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn with_keys(
|
#[must_use]
|
||||||
|
pub fn with_keys(
|
||||||
oauth2_config: &OAuth2Config,
|
oauth2_config: &OAuth2Config,
|
||||||
) -> impl Filter<Extract = (KeySet,), Error = Infallible> + Clone + Send + Sync + 'static {
|
) -> impl Filter<Extract = (KeySet,), Error = Infallible> + Clone + Send + Sync + 'static {
|
||||||
let keyset = oauth2_config.keys.clone();
|
let keyset = oauth2_config.keys.clone();
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ pub struct SessionCookie {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SessionCookie {
|
impl SessionCookie {
|
||||||
#[must_use] pub fn from_session_info(info: &SessionInfo) -> Self {
|
#[must_use]
|
||||||
|
pub fn from_session_info(info: &SessionInfo) -> Self {
|
||||||
Self {
|
Self {
|
||||||
current: info.key(),
|
current: info.key(),
|
||||||
}
|
}
|
||||||
@@ -52,7 +53,8 @@ impl EncryptableCookieValue for SessionCookie {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn with_optional_session(
|
#[must_use]
|
||||||
|
pub fn with_optional_session(
|
||||||
pool: &PgPool,
|
pool: &PgPool,
|
||||||
cookies_config: &CookiesConfig,
|
cookies_config: &CookiesConfig,
|
||||||
) -> impl Filter<Extract = (Option<SessionInfo>,), Error = Rejection> + Clone + Send + Sync + 'static
|
) -> impl Filter<Extract = (Option<SessionInfo>,), Error = Rejection> + Clone + Send + Sync + 'static
|
||||||
@@ -71,7 +73,8 @@ impl EncryptableCookieValue for SessionCookie {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn with_session(
|
#[must_use]
|
||||||
|
pub fn with_session(
|
||||||
pool: &PgPool,
|
pool: &PgPool,
|
||||||
cookies_config: &CookiesConfig,
|
cookies_config: &CookiesConfig,
|
||||||
) -> impl Filter<Extract = (SessionInfo,), Error = Rejection> + Clone + Send + Sync + 'static {
|
) -> impl Filter<Extract = (SessionInfo,), Error = Rejection> + Clone + Send + Sync + 'static {
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ mod views;
|
|||||||
|
|
||||||
use self::{health::filter as health, oauth2::filter as oauth2, views::filter as views};
|
use self::{health::filter as health, oauth2::filter as oauth2, views::filter as views};
|
||||||
|
|
||||||
#[must_use] pub fn root(
|
#[must_use]
|
||||||
|
pub fn root(
|
||||||
pool: &PgPool,
|
pool: &PgPool,
|
||||||
templates: &Templates,
|
templates: &Templates,
|
||||||
config: &RootConfig,
|
config: &RootConfig,
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ pub struct OAuth2AccessTokenLookup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl OAuth2AccessTokenLookup {
|
impl OAuth2AccessTokenLookup {
|
||||||
#[must_use] pub fn exp(&self) -> DateTime<Utc> {
|
#[must_use]
|
||||||
|
pub fn exp(&self) -> DateTime<Utc> {
|
||||||
self.created_at + Duration::seconds(i64::from(self.expires_after))
|
self.created_at + Duration::seconds(i64::from(self.expires_after))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ impl OAuth2Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn max_auth_time(&self) -> Option<DateTime<Utc>> {
|
#[must_use]
|
||||||
|
pub fn max_auth_time(&self) -> Option<DateTime<Utc>> {
|
||||||
self.max_age
|
self.max_age
|
||||||
.map(|d| Duration::seconds(i64::from(d)))
|
.map(|d| Duration::seconds(i64::from(d)))
|
||||||
.map(|d| self.created_at - d)
|
.map(|d| self.created_at - d)
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ pub struct SessionInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SessionInfo {
|
impl SessionInfo {
|
||||||
#[must_use] pub fn key(&self) -> i64 {
|
#[must_use]
|
||||||
|
pub fn key(&self) -> i64 {
|
||||||
self.id
|
self.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ impl Task for CleanupExpired {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn cleanup_expired(pool: &Pool<Postgres>) -> impl Task + Clone {
|
#[must_use]
|
||||||
|
pub fn cleanup_expired(pool: &Pool<Postgres>) -> impl Task + Clone {
|
||||||
CleanupExpired(pool.clone())
|
CleanupExpired(pool.clone())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,7 +212,8 @@ pub struct IndexContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl IndexContext {
|
impl IndexContext {
|
||||||
#[must_use] pub fn new(discovery_url: Url) -> Self {
|
#[must_use]
|
||||||
|
pub fn new(discovery_url: Url) -> Self {
|
||||||
Self { discovery_url }
|
Self { discovery_url }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,7 +231,8 @@ pub struct LoginContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl LoginContext {
|
impl LoginContext {
|
||||||
#[must_use] pub fn with_form_error(form: ErroredForm<LoginFormField>) -> Self {
|
#[must_use]
|
||||||
|
pub fn with_form_error(form: ErroredForm<LoginFormField>) -> Self {
|
||||||
Self { form }
|
Self { form }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,22 +269,26 @@ pub struct ErrorContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ErrorContext {
|
impl ErrorContext {
|
||||||
#[must_use] pub fn new() -> Self {
|
#[must_use]
|
||||||
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn with_code(mut self, code: &'static str) -> Self {
|
#[must_use]
|
||||||
|
pub fn with_code(mut self, code: &'static str) -> Self {
|
||||||
self.code = Some(code);
|
self.code = Some(code);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use] pub fn with_description(mut self, description: String) -> Self {
|
#[must_use]
|
||||||
|
pub fn with_description(mut self, description: String) -> Self {
|
||||||
self.description = Some(description);
|
self.description = Some(description);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[must_use] pub fn with_details(mut self, details: String) -> Self {
|
#[must_use]
|
||||||
|
pub fn with_details(mut self, details: String) -> Self {
|
||||||
self.details = Some(details);
|
self.details = Some(details);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user