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

Fix OAuth credentials to support web apps #7246

Closed
wants to merge 10 commits into from

Conversation

jianghaolu
Copy link
Contributor

@jianghaolu jianghaolu commented Jan 7, 2020

This PR brings an overhaul of the IdentityClient, allowing different authenticateWithXxx() methods to share the same instance of ConfidentialClientApplication.
The reason behind this change is the need of using a ConfidentialClientApplication instead of a PublicClientApplication for OAuth2 auth code flow. However, ConfidentialClientApplication is created in the method usually, whose token cache and refresh token will be lost after authentication. This PR allows using a ConfidentialClientApplication's token cache and refresh token for acquiring a new access token.
In the case of an invalid certificate for a client application, this PR also fails early at ClientCertificateCredentialBuilder.build() instead of later at getToken().

Additive changes to user facing APIs

Methods to specify a client secret, or a client certificate, are now added to AuthorizationCodeCredentialBuilder, through AuthorizationCodeCredentialBuilder.clientSecret(String), AuthorizationCodeCredentialBuilder.pemCertificate(String), AuthorizationCodeCredentialBuilder.pfxCertificate(String, String).

@jianghaolu jianghaolu changed the title Fix AuthorizationCodeCredential to support credential [After Jan 7] Fix AuthorizationCodeCredential to support credential Jan 7, 2020
@jianghaolu jianghaolu changed the title [After Jan 7] Fix AuthorizationCodeCredential to support credential [After Jan 7] Fix OAuth credentials to support web apps Jan 9, 2020
@jianghaolu jianghaolu changed the title [After Jan 7] Fix OAuth credentials to support web apps Fix OAuth credentials to support web apps Jan 9, 2020
* @param clientSecret the secret value of the AAD application.
* @return the AuthorizationCodeCredentialBuilder itself
*/
public AuthorizationCodeCredentialBuilder clientSecret(String clientSecret) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to fix this in other languages too ?
Feels like a missed feature, that should exist in parity across languages.
@schaabs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's funny since in the beginning .NET and Python supporting providing a client secret and Java didn't. Now Java supports providing a client secret or a certificate :)

* @param certificatePath the PEM file containing the certificate
* @return the InteractiveBrowserCredentialBuilder itself
*/
public InteractiveBrowserCredentialBuilder pemCertificate(String certificatePath) {
Copy link
Member

Choose a reason for hiding this comment

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

need to add this in other languages too ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, .NET only supports client secret when using the AzuthorizationCodeCredential not certificate. Adding support for this makes sense but we'd need to discuss how to best do it. I see there's been an ask to allow certificates to be loaded from an InputStream for ClientCertificateCredential, in addition to file path. Would we need to have all these overloads on both?

@g2vinay g2vinay requested a review from srnagar January 14, 2020 21:36
@joshfree joshfree added Azure.Identity Client This issue points to a problem in the data-plane of the library. labels Jul 9, 2020
@joshfree
Copy link
Member

joshfree commented Jul 9, 2020

Closing old PR from mid-January with no activity since then

@joshfree joshfree closed this Jul 9, 2020
@jianghaolu jianghaolu reopened this Jul 9, 2020
@jianghaolu jianghaolu added Do Not Merge blocked Issue/PR is blocked on something - see comments labels Sep 1, 2020
@jianghaolu
Copy link
Contributor Author

Waiting for other languages to prioritize this fix - do not merge now for consistency with other languages.

@JonathanGiles
Copy link
Member

@jianghaolu Can we get a status update on this PR? It's one of our oldest PRs in the repo, so finding a conclusion for this PR soon would be great! Thanks.

@jianghaolu
Copy link
Contributor Author

jianghaolu commented Aug 27, 2021

Actions needed for this PR:

  • verify if this is still broken - at the time of authoring this PR - without this fix AAD web apps will not support OAuth.
  • convince other languages if this is still broken
  • prioritize in an upcoming release

@jianghaolu
Copy link
Contributor Author

jianghaolu commented Aug 27, 2021

@jianghaolu Can we get a status update on this PR? It's one of our oldest PRs in the repo, so finding a conclusion for this PR soon would be great! Thanks.

Tried to push for this a few times but at the time I couldn't get other languages to understand the issue, thus not prioritized. No customer complained about this either so I'm not sure if a fix is still worth it.

@g2vinay
Copy link
Member

g2vinay commented Oct 25, 2021

Closing this until it becomes a feature request.

@g2vinay g2vinay closed this Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Identity blocked Issue/PR is blocked on something - see comments Client This issue points to a problem in the data-plane of the library. Do Not Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants