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

Using latest version of Azure SDK to use MSAL4j internally #24095

Closed
3 tasks done
narigala opened this issue Sep 13, 2021 · 12 comments
Closed
3 tasks done

Using latest version of Azure SDK to use MSAL4j internally #24095

narigala opened this issue Sep 13, 2021 · 12 comments
Assignees
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@narigala
Copy link

Describe the bug
Using latest version of Azure SDK to use MSAL4j internally
Could you please confirm and clarify the following queries?
Current code which uses ADAL
ApplicationTokenCredentials auth = new ApplicationTokenCredentials(connection.getClientId(),
connection.getTenantId(),
connection.getClientKey(),
null);
return Azure.configure()
.withLogLevel(LogLevel.BASIC)
.withReadTimeout(READ_TIMEOUT_SEC, TimeUnit.SECONDS)
.authenticate(auth)
.withSubscription(connection.getSubcriptionId());
NEW CODE as per the links:
ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("<YOUR_CLIENT_ID>")
.clientSecret("<YOUR_CLIENT_SECRET>")
.tenantId("<YOUR_TENANT_ID>")
.build();

// Azure SDK client builders accept the credential as a parameter
SecretClient client = new SecretClientBuilder()
    .vaultUrl("https://{YOUR_VAULT_NAME}.vault.azure.net")
    .credential(clientSecretCredential)
    .buildClient();

It would internally use MSAL not ADAL is that correct?
Currently I only have Tenant Id, Client Id, Client Secret, Subscription ID in my old code and implementation from where can I find YOUR_VAULT_NAME? is there a way to skip the vault name in new implementation ?
I only need to authenticate using only Tenant Id, Client Id, Client Secret, Subscription ID, Please share sample lines of code.
I added below new maven dependencies but I could not import all the classes required for above new migration code. Could you please confirm maven dependencies for ClientSecretCredential and ClientSecretCredentialBuilder

com.azure.resourcemanager azure-resourcemanager 2.7.0 com.azure azure-identity 1.3.4 com.azure azure-core-http-netty 1.10.2

Exception or Stack Trace
Not able to import all the classes even after adding required dependencies

To Reproduce
Migrate old code to new code

Code Snippet
ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId("<YOUR_CLIENT_ID>")
.clientSecret("<YOUR_CLIENT_SECRET>")
.tenantId("<YOUR_TENANT_ID>")
.build();

// Azure SDK client builders accept the credential as a parameter
SecretClient client = new SecretClientBuilder()
    .vaultUrl("https://{YOUR_VAULT_NAME}.vault.azure.net")
    .credential(clientSecretCredential)
    .buildClient();

Expected behavior
After adding the corresponding lines of code with latest Azure SDK for MSAL it should work as it was previously with ADAL4j
Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: [e.g. iOS] windows or Linux
  • IDE: [e.g. IntelliJ] Any IntelliJ
  • Library/Libraries: [e.g. com.azure:azure-core:1.16.0 (groupId:artifactId:version)] libraries are added above
    com.azure.resourcemanager
    azure-resourcemanager
    2.7.0
com.azure azure-identity 1.3.4 com.azure azure-core-http-netty 1.10.2 - Java version: [e.g. 8] Java 11 - App Server/Environment: [e.g. Tomcat, WildFly, Azure Function, Apache Spark, Databricks, IDE plugin or anything special] - Frameworks: [e.g. Spring Boot, Micronaut, Quarkus, etc] Dev servers

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please provide

  • dependency tree (mvn dependency:tree)

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@ghost ghost added 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 13, 2021
@narigala
Copy link
Author

Just to give you more context on the reason why we need to fix this issue.
Currently when we use below code to authenticate to Azure.
ApplicationTokenCredentials auth = new ApplicationTokenCredentials(connection.getClientId(),
connection.getTenantId(),
connection.getClientKey(),
null);
return Azure.configure()
.withLogLevel(LogLevel.BASIC)
.withReadTimeout(READ_TIMEOUT_SEC, TimeUnit.SECONDS)
.authenticate(auth)
.withSubscription(connection.getSubcriptionId());

We are actually using Azure SDK of Client Authentication by adding the below maven dependencies which internally calls ADAL4j which we want to get rid off and internally call MSAL4j.( so that we can fix one critical security defect)

com.microsoft.azure
azure-client-authentication
<version1.7.12version>

Our application is being currently used by many applications since 2017-18, so with minimal code changes which is corresponding to Azure SDK Java API/code for MSAL4J with required maven dependencies would help.
We are good to add new maven dependencies and corresponding MSAL 4j SDK API code (which uses same TenantId, ClientId, Client Secret, Subscription Id) .

@narigala
Copy link
Author

Can someone please assign this issue and take this as priority?

@joshfree joshfree added Azure.Identity Client This issue points to a problem in the data-plane of the library. labels Sep 16, 2021
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Sep 16, 2021
@joshfree
Copy link
Member

It would internally use MSAL not ADAL is that correct?

Hi @narigalam yes, this is correct.

Currently I only have Tenant Id, Client Id, Client Secret, Subscription ID in my old code and implementation from where can I find YOUR_VAULT_NAME? is there a way to skip the vault name in new implementation ?
I only need to authenticate using only Tenant Id, Client Id, Client Secret, Subscription ID, Please share sample lines of code.

You can see https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity/README.md for more information on how to get started. the Key Vault Name is the Vault Name that was specified when the keyvault store was created.

com.microsoft.azure

Please note that you cannot mix the old "com.microsoft.azure" SDKs with the new Unified SDKs which start with "com.azure". You'll need to continue to use ADAL or upgrade from the older "com.microsoft.azure.*" client library to a newer version which can be found here https://aka.ms/azsdk.

Please let us know if you have any other questions.

@joshfree
Copy link
Member

@AlexGhiondea it looks like the GitHub issue bot failed to add the needs-triage label when this issue was filed.

@joshfree joshfree added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Sep 16, 2021
@narigala
Copy link
Author

narigala commented Sep 16, 2021 via email

@ghost ghost removed the needs-author-feedback Workflow: More information is needed from author to address the issue. label Sep 16, 2021
@narigala
Copy link
Author

narigala commented Sep 16, 2021 via email

@narigala
Copy link
Author

narigala commented Sep 20, 2021 via email

@narigala
Copy link
Author

Hi.. Is there any update on this ticket?
Can I get assigned developer details so that I can interact through emails?

@narigala
Copy link
Author

@g2vinay @joshfree Please let me know if there is any ETA on this issue?

@g2vinay
Copy link
Member

g2vinay commented Sep 21, 2021

@narigala

Thanks for posting this issue.
we are working on a sample for your use case.
Will update you soon.

@narigala
Copy link
Author

I am getting this error even after having the below dependencies and adding jackson libraries to 2.12

com.azure
azure-identity
1.3.6
provided


com.azure
azure-core-http-netty
1.11.0


com.azure
azure-core-http-netty
1.11.0


com.microsoft.azure
msal4j
1.11.0


com.azure
azure-core-management
1.4.1


com.azure.resourcemanager
azure-resourcemanager
2.8.0


com.azure
azure-core
1.20.0

java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/cfg/MapperBuilder

at com.azure.identity.implementation.IdentityClient.<clinit>(IdentityClient.java:96)
at com.azure.identity.implementation.IdentityClientBuilder.build(IdentityClientBuilder.java:113)
at com.azure.identity.ClientSecretCredential.<init>(ClientSecretCredential.java:50)
at com.azure.identity.ClientSecretCredentialBuilder.build(ClientSecretCredentialBuilder.java:76)

@g2vinay
Copy link
Member

g2vinay commented Oct 25, 2021

Closing this, as the issue was resolved on direct contact with the customer.

@g2vinay g2vinay closed this as completed Oct 25, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team 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

3 participants