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

Changed Azure AD Login Flow #808

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

Conversation

shabirjan
Copy link

Added Hybrid Flow for Authorization grant to reterive user id_token.
Changed Redirect from Get to Post as Hybrid Flow needs form_post instead of query and returns the response as Form body.

…Changed Redirect from Get to Post as Hybrid Flow needs form_post instead of query and returns the response as Form body.

Added Hybrid Flow for Authorization grant to reterive user id_token.
Changed Redirect from Get to Post as Hybrid Flow needs form_post instead of query and returns the response as Form body.
Copy link
Collaborator

@tpatel tpatel left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution ✨

I've suggested some changes to make sure we don't break other oauth providers.

backend/chainlit/server.py Outdated Show resolved Hide resolved
backend/chainlit/server.py Show resolved Hide resolved
Added Get for Callback
Added Id_token to Callback signature
@tpatel
Copy link
Collaborator

tpatel commented Apr 2, 2024

hello @shabirjan, I think there was a misunderstanding, in your code in backend/chainlit/server.py, you are changing the behavior for folks who are doing GET /auth/oauth/{provider_id}/callback, and this isn't something we can do.

Could you separate the code from GET /auth/oauth/{provider_id}/callback and POST /auth/oauth/azure-ad/callback to make sure we don't break other oauth providers?

@shabirjan
Copy link
Author

hello @shabirjan, I think there was a misunderstanding, in your code in backend/chainlit/server.py, you are changing the behavior for folks who are doing GET /auth/oauth/{provider_id}/callback, and this isn't something we can do.

Could you separate the code from GET /auth/oauth/{provider_id}/callback and POST /auth/oauth/azure-ad/callback to make sure we don't break other oauth providers?

Hi @tpatel , Can you please explain a bit, what exactly you need me to do? What code should I separate?

@tpatel
Copy link
Collaborator

tpatel commented Apr 29, 2024

hi @shabirjan, I've been working on this PR so that we can merge your changes. However I tried to look for the reason behind the PR and I could gather that you're interested by getting the user role?

Would this following snippet (without the code changes from this PR) work for your needs?

@cl.oauth_callback
def oauth_callback(
  provider_id: str,
  token: str,
  raw_user_data: Dict[str, str],
  default_user: cl.User,
) -> Optional[cl.User]:
  
  import httpx
  res = httpx.get("https://graph.microsoft.com/v1.0/me/appRoleAssignments", headers={"Authorization": f"Bearer {token}"})
  print(res.json()) # This contains the user "App Roles Assignments"

  return default_user

@shabirjan
Copy link
Author

hi @tpatel , We already discussed almost 2-3 month ago on the call, that we can't use that endpoint as it returns user roles for all the AAD Applications in the tenant for that specific user, which we are not looking for. Our use case for that implementation was check the role assigned to the currently logged in user on behalf of the Specific AAD App Registration.

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