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

Org-Level Auth Enforcement for SAML Orgs and Enhancements for SAML SSO #1372

Merged
merged 17 commits into from
Feb 9, 2024

Conversation

dangtony98
Copy link
Collaborator

Description 📣

Foremost, this PR enforces users that want to access the resources of an organization with an org-level auth method enabled to have to log in via that organization's specified auth method such as SAML SSO to do so. This means that if a user is part of two organizations, one that does not have SAML-enabled and one that does, then they cannot log into the non-SAML-enabled organization and switch organizations to access the SAML-based one's resources.

This PR also sprinkles in a few other related improvements for working with org-level authentication. More specifically, the changes covered include:

  • Accessing an organization with an org-level auth method enabled for users now requires an access token to be issued with the correct organizationId in its payload. This field is only attached onto access tokens if users log in via an organization auth method such as SAML SSO.

  • We now separate the concepts of activating SAML SSO (referred to as isActive on the samlConfig table) in an organization with enforcing it (referred to as authEnforced on the organization table) to prevent users setting up SAML SSO from getting locked out of their organization. Previously, you could configure SAML, activate it, then log out — only to realize that you've locked yourself out because the SAML configuration required to log you back in wasn't valid. With this update, you must now successfully test the SAML configuration by logging in correctly, thus registering a lastUsed timestamp on the SAML object in the DB, before enforcing it for the organization. Once enforced, users must log in via SAML to access the organization's resources.

  • Logging in with SAML (Infisical-initiated) now requires users to input their organization slug which is much easier to keep track of than the SAML SSO config ID. Related: I've added an update organization slug section in the Organization Settings.

Type ✨

  • Bug fix
  • New feature
  • Breaking change
  • Documentation

Copy link

gitguardian bot commented Feb 7, 2024

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
8529478 Triggered Generic High Entropy Secret f1c41be .env.example View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@dangtony98 dangtony98 changed the title Org-Level Auth Enforcement and Enhancements for SAML SSO Org-Level Auth Enforcement for SAML Orgs and Enhancements for SAML SSO Feb 8, 2024
Copy link
Collaborator

@maidul98 maidul98 left a comment

Choose a reason for hiding this comment

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

Left small comments. I have tested the CLI with these changes and it works as expected. I also tried sign up and that too works. I couldn't try invite user to org because i got 500 so you might have to see what is up with that.

Did not try the SAML flow in gamma, i think it might be better if you test that.

FYI: these this branch has been deployed to gamma

backend/src/ee/routes/v1/license-router.ts Outdated Show resolved Hide resolved
backend/src/services/org/org-service.ts Outdated Show resolved Hide resolved
@@ -342,7 +348,7 @@ export const samlConfigServiceFactory = ({
email,
firstName,
lastName,
authMethods: [authProvider]
authMethods: [AuthMethod.EMAIL]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did we change this was authProvider not email already?

Copy link
Collaborator Author

@dangtony98 dangtony98 Feb 8, 2024

Choose a reason for hiding this comment

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

No. Previously, we updated a field on users to specify that their authentication method is now SAML but this is incorrect because SAML authentication should be bound at the organization-level instead of the user-level since a user can be part of multiple organizations, some of which may have SAML enforcement and others which may not. So, users can now retain their personal login methods like Email / Google / GitHub / GitLab whilst being SAML-enforced for specific organizations that have that enforcement.

You'll notice that in this PR we change how we deal with SAML auth validation in the underlying data structure. This adds flexibility such that users can use regular email/password to log into non-org level auth enforced organizations and be required to login with SAML for those that have that enforcement.

The specific line here means that, if the user does not yet exist, a new one is created with the default email/password auth method instead of having SAML as their auth method because, as I mentioned above, SAML is bound at the org-level not at the user-level.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious, what happens if I am apart of a org that has SAML sso configured? Will i just not see those orgs or will it prompt me to login when i switch to that org?

Copy link
Collaborator

@maidul98 maidul98 left a comment

Choose a reason for hiding this comment

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

lgtm

@maidul98 maidul98 merged commit fb50375 into main Feb 9, 2024
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants