Skip to content
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

Add admin option to disable SSO registrations #604

Merged
merged 5 commits into from
Mar 19, 2024

Conversation

e-five256
Copy link
Member

@e-five256 e-five256 commented Mar 18, 2024

Add admin option to disable SSO registrations while still allowing SSO logins

image

Right now as described in the linked issue, disabling site registration does not stop new account creation via SSO methods. This adds a new overall admin setting to disable all sso options new account registration, while allowing logins to still function for existing users

the authenticators have 3 stages:

  1. sso id already existed, login
  2. email already in use, remap to sso
  3. new account completely

I chose to implement the check between options 2 and 3, as if the user was already able to make a native account with the email, it seems like there's no harm in allowing to remap to the SSO option, but I could move it up between 1 and 2 instead if people think that is more correct

suggest hiding whitespace changes when looking at the diff


when attempting to register with an account that does not exist, users get redirected to login and shown this message

image


Fixes #518

fix function type return and if statements
add persist to keycloak on existing email
@e-five256 e-five256 added the sso Single-sign-on issues or pull requests label Mar 18, 2024
@e-five256 e-five256 marked this pull request as ready for review March 18, 2024 21:12
@@ -75,11 +78,16 @@ public function authenticate(Request $request): Passport
if ($user) {
$user->oauthKeycloakId = $keycloakUser->getId();

$this->entityManager->persist($user);
Copy link
Member Author

Choose a reason for hiding this comment

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

this was missing from keycloak but appears in all the other authenticators, so seemed like it might be needed

@e-five256 e-five256 changed the title Add admin option to disable SSO registrations while still allowing logins Add admin option to disable SSO registrations Mar 18, 2024
@ghost
Copy link

ghost commented Mar 18, 2024

This will remove (or at least handicap) a vector currently being used by spammers to bypass our email verification and captcha checks while giving legit users the ability to still use SSO after normal registration... a much needed feature for those of us with SSO enabled.

@ghost ghost self-requested a review March 18, 2024 21:57
@ghost ghost added enhancement New feature or request security Issues and pull requests that address security concerns labels Mar 18, 2024
@e-five256
Copy link
Member Author

@BentiGorlich @thepaperpilot since you both were involved with the discussion on the issue wanted to make sure this made sense to both of you for how it was implemented

and ofc don't worry about getting this in the zitadel stuff, I'll make sure to do that if it comes before or after

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Functional review using dev environment with Github provider works as expected.

@e-five256 e-five256 merged commit af46166 into main Mar 19, 2024
7 checks passed
@e-five256 e-five256 deleted the e5/sso-registration-disabled-setting branch March 19, 2024 21:24
@BentiGorlich
Copy link
Member

Does this new setting default to true or will it have to be enabled for instances that have some SSO providers enabled?

Also @nobodyatroot can you explain what you mean exactly?

@ghost
Copy link

ghost commented Mar 19, 2024

@BentiGorlich When register with SSO is enabled (or just having Google/Facebook/Github SSO enabled before this PR), there is no email verification or captcha check... I've been hammered multiple times with spammers signing up using this feature because it bypasses our simple spam "checks", I would turn SSO off but I have legit users using Google to signin.

@BentiGorlich
Copy link
Member

Ah ok. Yeah I have noticed that most spam accounts on mastodon use gmail addresses. I would have expected that Hoogle would do a better job at preventing spam accounts

@ghost
Copy link

ghost commented Mar 19, 2024

Ah ok. Yeah I have noticed that most spam accounts on mastodon use gmail addresses. I would have expected that Hoogle would do a better job at preventing spam accounts

Me too, but I guess if they're not actively using the Gmail account to spam emails, then they don't care....

@e-five256
Copy link
Member Author

e-five256 commented Mar 20, 2024

Does this new setting default to true or will it have to be enabled for instances that have some SSO providers enabled?

Yep! (to it defaulting to enabled)

$this->find($results, 'MBIN_SSO_REGISTRATIONS_ENABLED', FILTER_VALIDATE_BOOLEAN) ?? true

should be no unexpected changes for admins pulling this in. I could see it being a little confusing for admins that don't use SSO at all, since it saying sso registration enabled (which it is by default) when there is none configured has no effect.

There isn't a great way to check whether SSO is enabled without checking every single provider, but I could add that and hide the admin option if none are set, or just change the option to have a description that says only has an effect when having an sso provider enabled

@BentiGorlich
Copy link
Member

I think it is fine as is, but a description doesn't burt nobody 😁

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request security Issues and pull requests that address security concerns sso Single-sign-on issues or pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Third party login methods allow for new accounts when registration is disabled
2 participants