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

[FEATURE REQ] Authentication in a Stateless API using the Microsoft Graph API #15169

Closed
fgoulet opened this issue Sep 14, 2020 · 15 comments
Closed
Assignees
Labels
azure-spring All azure-spring related issues azure-spring-aad Spring active directory related issues. customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request This issue requires a new behavior in the product in order be resolved. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@fgoulet
Copy link

fgoulet commented Sep 14, 2020

We have an Angular 10 application that use MSAL Angular library to authenticate with Azure AD. We need a Spring Boot Rest API
that will accept IDToken v2 from the angular app. So our rest api must use the Microsoft Graph API. We also need that our rest api be configured for Stateless authentication.

I could not found any sample for this scenario. Is that cover by the this sdk ?

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 14, 2020
@joshfree joshfree added azure-spring All azure-spring related issues Graph labels Sep 14, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 14, 2020
@joshfree
Copy link
Member

Thanks for posting your question @fgoulet. @jialindai could you please assist routing this?

@chenrujun chenrujun self-assigned this Sep 15, 2020
@chenrujun
Copy link

Hi, @fgoulet .

Stateless authentication is supported.
Please check related readme for more information.

@chenrujun chenrujun added azure-spring-aad Spring active directory related issues. and removed Graph labels Sep 15, 2020
@fgoulet
Copy link
Author

fgoulet commented Sep 15, 2020

Hi chenrujun,

Unless I'm wrong, Staleless is supported only for Azure AD endpoints, ID Tokens v1.0.

We need support for Microsoft identity Platform endpoints, ID Tokens v2.0, the one you obtains with Microsoft Graph.

You already have support for V2 tokens in your backend authentication (and state full) solution. We would need the same but with front end authentication.

@yiliuTo
Copy link
Member

yiliuTo commented Sep 17, 2020

Hi @fgoulet just to make certain, we currently support backend authentication via both Azure AD (V1) and Microsoft identity Platform (V2) endpoints to Microsoft Graph API and Azrue AD Graph API. And your expectation is that we could support front end authentication in a stateless API using Microsoft Graph API on Microsoft identity Platform (V2) endpoints?

@fgoulet
Copy link
Author

fgoulet commented Sep 17, 2020

Yes, exactly.

@yiliuTo
Copy link
Member

yiliuTo commented Sep 18, 2020

Hi @fgoulet . For stateless authentication with front end, we provide an AADAppRoleStatelessAuthenticationFilter using appRole instead of user group to implement authentication. The appRole feature of Azure AD requires additional configuration in the App manifest. Please refer to our sample for the detailed use.

@fgoulet
Copy link
Author

fgoulet commented Sep 18, 2020

Hi @yiliu,

This sample is for Azure AD endpoints with v1 id_token. Our Angular 10 application use the MSAL library that require Microsoft identity Platform endpoints with v2 id_token. AADAppRoleStatelessAuthenticationFilter decode v1 token only.

The difference is documented here

The v1.0 and v2.0 id_token have differences in the amount of information they will carry as seen from the examples above. The version is based on the endpoint from where it was requested. While existing applications likely use the Azure AD endpoint, new applications should use the v2.0 "Microsoft identity platform" endpoint.

v1.0: Azure AD endpoints: https://login.microsoftonline.com/common/oauth2/authorize
v2.0: Microsoft identity Platform endpoints: https://login.microsoftonline.com/common/oauth2/v2.0/authorize

@yiliuTo
Copy link
Member

yiliuTo commented Sep 21, 2020

Hi @fgoulet , sorry I forgot to clarify it clearly in the last reply. The stateless authentication sample can work for both v1 and v2 id_token by specifying different sign in url in the index.html. And after replace the sighInUrl to Microsoft Identity Platform authorize endpoint you mentioned, the sample can obtain v2 id_token and verify the appRole claim.

@fgoulet
Copy link
Author

fgoulet commented Sep 22, 2020

Hi @yiliuTo ,
That's precisely what we do with our Angular app and we got this error when trying to access our Spring Boot Rest API
com.nimbusds.jose.proc.BadJWSException: Signed JWT rejected: Invalid signature

That could be related to this issue microsoft/azure-spring-boot#476

I think a complete working sample for this scenario is much needed.

@yiliuTo
Copy link
Member

yiliuTo commented Sep 23, 2020

Hi @fgoulet , thanks for your reporting, and I am afraid not just a sample is needed here, but our AADAppRoleStatelessAuthenticationFilter cannot cover your case currently. This is because the stateless filter needs to parse the roles claim in tokens, however, in your case if the spring boot rest API needs to access Microsoft Graph API, then it requires an access token which doesn't contain the roles claim under this circumstance, that's why the error of Signed JWT rejected: Invalid signature occurs.

And if your spring boot rest API doesn't use Microsoft Graph API but has own logic, then you can modify content of the scope parameter with {your-client-id}/.default, which our stateless filter can work for you.

For your feature request, we could have a further discusstion. What do you think if we replace the checking for AppRole to scope in the stateless filter to meet your requirements, given this claim appears on both id and access tokens all the time? Or if the scope checking is not fine-grained enough, you could consider using the on-behalf-of flow to acquire an access token to Graph API on top of the stateless filter.

@fgoulet
Copy link
Author

fgoulet commented Sep 23, 2020

Thanks @yiliuTo , your explanations make things a little more clearer. I realize that I do not have the needed knowledge right now to formulate a feature request that would fit our needs. I will do some more readings and I will get back to you hopefully with a meaningful request.

@yiliuTo
Copy link
Member

yiliuTo commented Sep 24, 2020

@fgoulet Here are some docs about the scp claim in access tokens and on-behalf-of flow, hope these could help. Our team will discuss towards this feature request too.

@yiliuTo
Copy link
Member

yiliuTo commented Sep 25, 2020

Hi @fgoulet , having discussed with our team, we put this feature that support OBO flow to acquire access tokens for Microsoft Graph API on top of the implicit flow in our roadmap. If you are urgent for the feature then I suggest that you could develop this yourself. Also PRs are welcome ^v^

@yiliuTo yiliuTo added the feature-request This issue requires a new behavior in the product in order be resolved. label Sep 29, 2020
@saragluna
Copy link
Member

@fgoulet
Copy link
Author

fgoulet commented Jan 6, 2021

Yes, it looks like it cover our needs.

Thank you.

@fgoulet fgoulet closed this as completed Jan 6, 2021
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-java that referenced this issue Jul 14, 2021
[security RP] mgmt, fix for java with directive (Azure#15169)

* [security] mgmt, fix for java with directive

* fix readme
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
azure-spring All azure-spring related issues azure-spring-aad Spring active directory related issues. customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request This issue requires a new behavior in the product in order be resolved. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

5 participants