-
Notifications
You must be signed in to change notification settings - Fork 148
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
compatability for jpackaged modular applications #571
Conversation
@microsoft-github-policy-service agree company="Techniker Krankenkasse" |
@microsoft-github-policy-service agree company="Techniker Krankenkasse" |
@Avery-Dunn Hi, could you kindly have a look into this PR if you find the time? |
@@ -0,0 +1,126 @@ | |||
// Copyright (c) Microsoft Corporation. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@siddhijain @Avery-Dunn - please try to respond to community contributions. This looks ok to me, although it's missing tests. What is the context here? I don't see any feedback on this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, Avery and I talked about this PR, but we never responded.
Context - We use a method getProductVersion() to get the msal4j version, and it returns 1 by default (i.e., when it cannot find the implementation version, for eg when running tests or in a jpackaged modular application). According to the person who raised PR, it is throwing exceptions while using IWA flow.
The PR adds another version of the HttpHeaders class that uses Java 9 features to handle this error. However, we avoid maintaining different versions of a class for different Java versions due to reasons like increased code complexity, code duplication, incompatibility issues, upgrade difficulties, and many more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it seems this PR won't be merged, is there any fix you'd propose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RJPG-TK For the time being, please continue using the workaround you provided in your message above, as we find a solution to the issue.
In order to use IWA in a jpackaged modular application that runs on a current JVM (e.g. 17), I propose these changes to be merged.
Problem
MSAL4J uses
in
com.microsoft.aad.msal4j.HttpHeaders
to set the header value forx-client-VER
.However, if it's set to
"1.0"
IWA fails withExecution of class com.microsoft.aad.msal4j.AcquireTokenByAuthorizationGrantSupplier failed. com.microsoft.aad.msal4j.MsalClientException: Password is required for managed user
See also: AzureAD/microsoft-authentication-library-for-dotnet#1860
This is an issue because
Package#getImplementationVersion
returns null in a jpackaged modular application.Solution
From Java 9 onwards, ModuleDescriptor.Version can be used to do pretty much the same. Therefore, I have set up a multi release jar build, with JVM 9+ using ModuleDescriptor.
For this to work, a few plugins needed to be updated (see pom).
Restrictions
Due to bnd not yet properly supporting multi release jars, I used
fixupmessages
as suggested in the related issue bndtools/bnd#2227.Errors like this one: projectlombok/lombok#2681 made me build the project on jdk-11.0.16.1+1.
Furthermore, I skipped the javadoc task - due to this bug https://issues.apache.org/jira/browse/MJAVADOC-586 / https://bugs.openjdk.org/browse/JDK-8220702.
All in all, a
mvn clean package -Dmaven.javadoc.skip=true
should run on jdk-11.0.16.1+1.Workaround for the meantime
We can exploit that extra headers passed to the builder will be passed through to HttpHeaders and eventually override already set headers. This is not a solution, but a temporary workaround, as it relies on an implementation detail that might change some day!
In code:
with something like