Skip to content

Forward the login_hint upstream. #4512

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

Merged
merged 10 commits into from
May 7, 2025

Conversation

pixlwave
Copy link
Member

@pixlwave pixlwave commented May 6, 2025

I think this is correct but haven't got a way to test it and I can't see any tests that I could add to to confirm it is doing the right thing (happy to add one if I'm looking in the wrong place).

///
/// Defaults to `false`.
#[serde(default)]
pub forward_login_hint: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine this should be a template to allow people to configure what exactly gets forwarded based on their upstream provider's requirements

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think later on we'd want a behaviour which looks up the user based on a mxid: login hint, and forwards to the upstream provider with either a id_token_hint (the last id_token we've seen for this user) or a templated login_hint. This obviously has some privacy implications, which is why we want to be careful with this

But for now, this simple feature of just forwarding the login_hint as-is could already be valuable for some deployments

Copy link
Member

@sandhose sandhose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very small nitpicks, otherwise lgtm, thanks!

.nova

# OS garbage
.DS_Store
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have those in my global git-config, that's why I never bothered :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whaaat, there's a global gitignore?! Why did nobody ever tell me this before?!! 😂😂

Would you like me to revert this or is it useful for anyone who doesn't have (or know about) global ignores?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's a thing!

I'm fine with keeping it though :)

@@ -0,0 +1,8 @@
-- Copyright 2024 New Vector Ltd.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- Copyright 2024 New Vector Ltd.
-- Copyright 2025 New Vector Ltd.

Note that your local deployment may complain if you change a migration file after applying it, so you may have to reset your local DB

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good catch, fixed in 2d4f24e, sqlx seemed happy as it didn't regenerate anything new.

Totally unrelated and I forgot to mention it earlier, there's some migrations in here still with the old Apache headers, not sure if that's intentional or they got missed by the update script.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's just that the migration files are immutable once applied: there is a hash of the file saved in the database to make sure we don't end up in a state where in-progress migration files were applied

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, got it. Hence it only potentially having been an issue with my local DB 👍

pixlwave added 2 commits May 7, 2025 10:21
sqlx migrate/prepare are both still happy.
@pixlwave pixlwave requested a review from sandhose May 7, 2025 09:37
@pixlwave
Copy link
Member Author

pixlwave commented May 7, 2025

Alright, updated. Feel free to squash merge this BTW, the history is messy 😅

@@ -565,4 +565,11 @@ pub struct Provider {
/// Orders of the keys are not preserved.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub additional_authorization_parameters: BTreeMap<String, String>,

/// Whether the login_hint should be forwarded to the provider in the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I just thought of, can you please update the reference documentation here? https://github.com/element-hq/matrix-authentication-service/blob/main/docs/reference/configuration.md#upstream_oauth2providers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in e3c7b80

@pixlwave pixlwave requested a review from sandhose May 7, 2025 10:21
Copy link
Member

@sandhose sandhose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tyvm!

@sandhose sandhose merged commit 4396ba1 into element-hq:main May 7, 2025
19 checks passed
@sandhose sandhose added A-Upstream-OAuth Related to login via upstream OAuth 2.0 providers T-Enhancement New feature of request labels May 7, 2025
@pixlwave
Copy link
Member Author

pixlwave commented May 7, 2025

You're welcome, thanks for all the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Upstream-OAuth Related to login via upstream OAuth 2.0 providers T-Enhancement New feature of request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants