Skip to content

remove prefix when forwarding the login_hint #4571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions crates/handlers/src/upstream_oauth2/authorize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.

use std::sync::Arc;

use axum::{
extract::{Path, Query, State},
response::{IntoResponse, Redirect},
};
use hyper::StatusCode;
use mas_axum_utils::{cookies::CookieJar, record_error};
use mas_data_model::UpstreamOAuthProvider;
use mas_data_model::{UpstreamOAuthProvider, oauth2::LoginHint};
use mas_matrix::HomeserverConnection;
use mas_oidc_client::requests::authorization_code::AuthorizationRequestData;
use mas_router::{PostAuthAction, UrlBuilder};
use mas_storage::{
Expand Down Expand Up @@ -66,6 +69,7 @@ pub(crate) async fn get(
cookie_jar: CookieJar,
Path(provider_id): Path<Ulid>,
Query(query): Query<OptionalPostAuthAction>,
State(homeserver): State<Arc<dyn HomeserverConnection>>,
) -> Result<impl IntoResponse, RouteError> {
let provider = repo
.upstream_oauth_provider()
Expand Down Expand Up @@ -96,13 +100,11 @@ pub(crate) async fn get(
// sees fit
if provider.forward_login_hint {
if let Some(PostAuthAction::ContinueAuthorizationGrant { id }) = &query.post_auth_action {
if let Some(login_hint) = repo
.oauth2_authorization_grant()
.lookup(*id)
.await?
.and_then(|grant| grant.login_hint)
{
data = data.with_login_hint(login_hint);
if let Some(grant) = repo.oauth2_authorization_grant().lookup(*id).await? {
match grant.parse_login_hint(homeserver.homeserver()) {
LoginHint::MXID(mxid) => data = data.with_login_hint(mxid.to_string()),
LoginHint::None => (),
}
}
}
}
Expand Down
Loading