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

SSO authentication for private WebApp #3074

Closed
4 tasks done
phamduyphuong251 opened this issue Apr 2, 2024 · 3 comments
Closed
4 tasks done

SSO authentication for private WebApp #3074

phamduyphuong251 opened this issue Apr 2, 2024 · 3 comments
Labels
💪 enhancement New feature or request 🙋‍♂️ question This issue does not contain proper reproduce steps or it only has limited words without details.

Comments

@phamduyphuong251
Copy link

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Pleas do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing?

Hi, I want to ask about SSO authentication for my private WebApp

2. Describe the feature you'd like to see

Well, the chatbot needs to sign in because of private documentation. I want my users when sign in my WebApp, the Chatbot will have their information to log it.

3. How will this feature improve your workflow or experience?

My boss need it :(

4. Additional context or comments

No response

5. Can you help us with this feature?

  • I am interested in contributing to this feature.
Copy link

dosubot bot commented Apr 2, 2024

Hey @phamduyphuong251, great to see you diving into another challenge with Dify! Let's tackle this SSO authentication together.

To integrate SSO authentication in your private WebApp, allowing the chatbot to sign in using the user's credentials after they've logged into the WebApp, you would typically follow these steps:

  1. Choose an SSO Strategy: Decide on the SSO protocol you want to use (e.g., SAML, OAuth2.0, OpenID Connect). This decision often depends on the technologies your WebApp and the identity provider support.

  2. Identity Provider (IdP) Integration: Integrate with an Identity Provider that supports your chosen SSO protocol. This could be a service like Okta, Auth0, or Google.

  3. Securely Store Credentials: Ensure that any credentials used for the integration, such as client IDs and secrets for OAuth, are securely stored and not exposed in the frontend.

  4. Backend Changes: Implement the SSO flow in your backend. This typically involves:

    • Redirecting the user to the IdP's login page.
    • Handling the callback from the IdP after successful authentication, which includes an authentication token.
    • Validating the token and creating a session for the user in your app.
  5. Frontend Changes: Modify your frontend to handle the SSO flow, which includes:

    • Initiating the SSO process.
    • Handling any redirects or token storage as required by your backend.
  6. API Key Management: As per the hint in the provided context, API keys should be called through the backend rather than being directly exposed in the frontend. This means your backend should manage the API keys and possibly associate different keys with different user sessions as needed.

  7. Modify API Calls for SSO: Adjust your API calls to include the user's session or token that indicates they are authenticated. This might involve adding headers or tokens to your API requests. For example, modifying the curl command to include an authorization header that contains the user's session token.

Here's a hypothetical example of how you might modify the API call to include SSO authentication, assuming the use of a bearer token obtained after SSO authentication:

curl --location --request POST 'https://api.dify.ai/v1/chat-messages' \
--header 'Authorization: Bearer YOUR-SSO-SESSION-TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
    "inputs": {},
    "query": "eh",
    "response_mode": "streaming",
    "conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276"
    "user": "abc-123"
}'

In this example, YOUR-SSO-SESSION-TOKEN would be the token that your backend generates or receives after the user successfully authenticates with the SSO. This token is then used to make authenticated API calls to Dify.

Regarding your question about contributing to Dify, I'm afraid I don't have the necessary information to guide you on this. You might want to reach out to the Dify development team or community for more information on how you can contribute.

As for your questions about the SSO protocols supported by Dify and how Dify handles session management and token validation for authenticated users, I wasn't able to find specific information within the repository. However, these are important considerations and I recommend reaching out to the Dify team for more information.

I hope this helps! If you have any more questions, feel free to ask.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added 💪 enhancement New feature or request 🙋‍♂️ question This issue does not contain proper reproduce steps or it only has limited words without details. labels Apr 2, 2024
@phamduyphuong251
Copy link
Author

I have one question: I want to embed a chatbot in my Web app by iframe. Is it possible for a chatbot to detect the user?

@crazywoola
Copy link
Member

Hello there, the SSO function requires business license. Please contact business@dify.ai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request 🙋‍♂️ question This issue does not contain proper reproduce steps or it only has limited words without details.
Projects
None yet
Development

No branches or pull requests

2 participants