Skip to content

Commit bd73734

Browse files
authored
Always ask for consent, never for reauth (#4386)
2 parents a3202a6 + 26dcba6 commit bd73734

27 files changed

+220
-1323
lines changed

crates/data-model/src/oauth2/authorization_grant.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
// SPDX-License-Identifier: AGPL-3.0-only
55
// Please see LICENSE in the repository root for full details.
66

7-
use std::num::NonZeroU32;
8-
9-
use chrono::{DateTime, Duration, Utc};
7+
use chrono::{DateTime, Utc};
108
use mas_iana::oauth::PkceCodeChallengeMethod;
119
use oauth2_types::{
1210
pkce::{CodeChallengeError, CodeChallengeMethodExt},
@@ -158,11 +156,9 @@ pub struct AuthorizationGrant {
158156
pub scope: Scope,
159157
pub state: Option<String>,
160158
pub nonce: Option<String>,
161-
pub max_age: Option<NonZeroU32>,
162159
pub response_mode: ResponseMode,
163160
pub response_type_id_token: bool,
164161
pub created_at: DateTime<Utc>,
165-
pub requires_consent: bool,
166162
pub login_hint: Option<String>,
167163
}
168164

@@ -174,18 +170,7 @@ impl std::ops::Deref for AuthorizationGrant {
174170
}
175171
}
176172

177-
const DEFAULT_MAX_AGE: Duration = Duration::microseconds(3600 * 24 * 365 * 1000 * 1000);
178-
179173
impl AuthorizationGrant {
180-
#[must_use]
181-
pub fn max_auth_time(&self) -> DateTime<Utc> {
182-
let max_age = self
183-
.max_age
184-
.and_then(|x| Duration::try_seconds(x.get().into()))
185-
.unwrap_or(DEFAULT_MAX_AGE);
186-
self.created_at - max_age
187-
}
188-
189174
#[must_use]
190175
pub fn parse_login_hint(&self, homeserver: &str) -> LoginHint {
191176
let Some(login_hint) = &self.login_hint else {
@@ -274,11 +259,9 @@ impl AuthorizationGrant {
274259
scope: Scope::from_iter([OPENID, PROFILE]),
275260
state: Some(Alphanumeric.sample_string(rng, 10)),
276261
nonce: Some(Alphanumeric.sample_string(rng, 10)),
277-
max_age: None,
278262
response_mode: ResponseMode::Query,
279263
response_type_id_token: false,
280264
created_at: now,
281-
requires_consent: false,
282265
login_hint: Some(String::from("mxid:@example-user:example.com")),
283266
}
284267
}

crates/handlers/src/lib.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,6 @@ where
371371
get(self::views::login::get).post(self::views::login::post),
372372
)
373373
.route(mas_router::Logout::route(), post(self::views::logout::post))
374-
.route(
375-
mas_router::Reauth::route(),
376-
get(self::views::reauth::get).post(self::views::reauth::post),
377-
)
378374
.route(
379375
mas_router::Register::route(),
380376
get(self::views::register::get),
@@ -409,13 +405,10 @@ where
409405
mas_router::OAuth2AuthorizationEndpoint::route(),
410406
get(self::oauth2::authorization::get),
411407
)
412-
.route(
413-
mas_router::ContinueAuthorizationGrant::route(),
414-
get(self::oauth2::authorization::complete::get),
415-
)
416408
.route(
417409
mas_router::Consent::route(),
418-
get(self::oauth2::consent::get).post(self::oauth2::consent::post),
410+
get(self::oauth2::authorization::consent::get)
411+
.post(self::oauth2::authorization::consent::post),
419412
)
420413
.route(
421414
mas_router::CompatLoginSsoComplete::route(),

crates/handlers/src/oauth2/authorization/callback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl CallbackDestination {
101101
})
102102
}
103103

104-
pub async fn go<T: Serialize + Send + Sync>(
104+
pub fn go<T: Serialize + Send + Sync>(
105105
self,
106106
templates: &Templates,
107107
locale: &DataLocale,

crates/handlers/src/oauth2/authorization/complete.rs

Lines changed: 0 additions & 309 deletions
This file was deleted.

0 commit comments

Comments
 (0)