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 domain allowlist #1237

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

Conversation

aablsk
Copy link

@aablsk aablsk commented Feb 23, 2024

What does this PR do?

This PR introduces a new environment variable "AUTH_ALLOWED_DOMAINS" that acts as an "allowlist" for domains to login to the langfuse instance.

Motivation: I'd love a more secure way to onboard people for the self-hosted instance. A boolean toggle to turn off/on signups is insufficient for our requirements. Restricting signups to certain domain(s) is sufficient for CHAPTR's requirements.

🚨 Important security considerations 🚨

This domain allowlisting has certain nuances to it, depending on the provider used.

  1. It is not secure if AUTH_DISABLE_USERNAME_PASSWORD is not set to true as there is no email verification. Anyone with knowledge of the allowed domains could still sign up with a non-existent email as long as the email's string has an allowed domain in it.
  2. For the Google provider we use the hd claim on the profile as this seems to be the only secure way to validate the domain according to this Github Thread.
  3. For Azure AD provider this has not been tested as I don't have access to an Azure AD and related credentials. Additionally, it seems like this might have the same issues as the Google OAuth Provider (https://www.descope.com/blog/post/noauth) in which case the email may not be trusted and thus the implementation of the domain validation could be exploited. I am unaware how a domain can be properly verified for the Azure AD provider.

UI considerations

Currently, if the sign-in fails, the following screen is shown, which does not adhere to the langfuse visual identity:
image

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update (we should document the new env var, what it does and the above limitations and security concerns)

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

✅ I haven't read the contributing guide
✅ My code doesn't follow the style guidelines of this project (npm run prettier)
✅ I haven't commented my code, particularly in hard-to-understand areas
✅ I haven't checked if my PR needs changes to the documentation
✅ I haven't checked if my changes generate no new warnings (npm run lint)
❌ I haven't added tests that prove my fix is effective or that my feature works
-> I'd like to understand which tests and what coverage would be expected for this feature
🤷 I haven't checked if new and existing unit tests pass locally with my changes (same number of tests fail before and after the change for me locally)

aablsk and others added 16 commits February 19, 2024 12:58
…e to restrict Google sign-in to specific domains
…ngfuse app

This commit adds a Cloud Build configuration file that specifies the steps for building and deploying the Langfuse app. The steps include building the Docker image, pushing it to a container registry, and deploying it to Google Cloud Run. The image that is built and deployed is "europe-west1-docker.pkg.dev/langfuse-test/langfuse/langfuse:latest".
The build and push steps for the Langfuse image have been re-introduced.
…e to restrict Google sign-in to specific domains
…ngfuse app

This commit adds a Cloud Build configuration file that specifies the steps for building and deploying the Langfuse app. The steps include building the Docker image, pushing it to a container registry, and deploying it to Google Cloud Run. The image that is built and deployed is "europe-west1-docker.pkg.dev/langfuse-test/langfuse/langfuse:latest".
The build and push steps for the Langfuse image have been re-introduced.
Copy link

vercel bot commented Feb 23, 2024

@aablsk is attempting to deploy a commit to the langfuse Team on Vercel.

A member of the Team first needs to authorize it.

@marcklingen marcklingen self-requested a review February 23, 2024 15:07
@aablsk aablsk marked this pull request as ready for review February 26, 2024 07:40
@aablsk
Copy link
Author

aablsk commented Mar 11, 2024

@marcklingen is there anything I can do to push this forward?

@marcklingen
Copy link
Member

Hi @aablsk, thanks again for your contribution on this and sorry for the delay.

I understand that it is very unclear if we can extend this logic to AzureAD, thereby Langfuse might get less secure when this setting is misinterpreted.

Until now, I recommended teams to restrict the OAuth app they create to their own google workspace account or AzureAD tenant. Thereby the OAuth app itself blocks all external users. I think this is secure and I'd probably go for adding this to the docs and closing this PR. What do you think? Is there a case that would require AUTH_ALLOWED_DOMAINS?

@aablsk
Copy link
Author

aablsk commented Mar 14, 2024

Thank you for getting back to me, @marcklingen! 🙇

I understand that it is very unclear if we can extend this logic to AzureAD, thereby Langfuse might get less secure when this setting is misinterpreted.

I agree, which is why I originally proposed only adding this logic for the Google provider with a google-specific domain allow-list.

Until now, I recommended teams to restrict the OAuth app they create to their own google workspace account or AzureAD tenant. Thereby the OAuth app itself blocks all external users. I think this is secure and I'd probably go for adding this to the docs and closing this PR. What do you think? Is there a case that would require AUTH_ALLOWED_DOMAINS?

Unfortunately, for us this is not an option as we need to allow different domains that belong to multiple Workspace accounts due to the infrastructure setup of the business organisation in which we're embedded. This might be just a corner case, which means that we're happy to continue with maintaining our own fork.

@marcklingen
Copy link
Member

Thanks for the clarification and then let's add this to Langfuse (maintaining a fork isn't fun). I'd suggest to go for AUTH_GOOGLE_ALLOWED_DOMAINS and only apply this flag to Google users to make sure this is not misunderstood leading to decreased security. What do you think?

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