Hello all,
Has anyone recently tested Azure AD OpenID (org.pac4j.oidc.client.AzureAdClient) by creating a brand new application in Microsoft Application Console (
https://apps.dev.microsoft.com/) and using it (that is, not testing an older application)? It seems that Microsoft is not permitting to have redirect URLs with query strings. Upon entering
The error in the Microsoft Application Console when adding the above Redirect URL is:
"Your URL must be in a valid URL format, begin with https://, and be limited to 255 characters in length."
Then permissions are asked for, then I log in successfully using the Azure AD account, but, then, still on the Microsoft side the following error is presented, indicating that an exact match is required:
<<
Sign In
Sorry, but we’re having trouble signing you in.
We received a bad request.
Additional technical information:
Correlation ID: 4395b519-6f27-4428-83a6-185f8c41af42
Timestamp: 2017-04-24 15:47:00Z
>>
Note that I used the latest spring-security-pac4j-demo where I configured tomcat for SSL authentication (as it was easier than configuring jetty plugin) and Microsoft is requiring SSL, then I configured the beans and their references for AzureAdClient in securityContext.xml:
<bean id="azureSecurityFilter" class="org.pac4j.springframework.security.web.SecurityFilter">
<property name="config" ref="config" />
<property name="clients" value="AzureADClient" />
</bean>
<security:http create-session="always" pattern="/azure/**" entry-point-ref="noEntryPoint">
<security:custom-filter position="BASIC_AUTH_FILTER" ref="azureSecurityFilter" />
</security:http>
<bean id="azureClient" class="org.pac4j.oidc.client.AzureAdClient">
<property name="name" value="AzureADClient"/>
<property name="clientID" value="82a7d68d-41bb-4c2b-91a8-69d07f5daf62"/>
<property name="secret" value="..."/>
</bean>
And I added <ref bean="azureClient" /> to the "clients" bean.
If using the discoveryURI without v2.0 upon successful Microsoft authentication I am redirected to localhost but with no client_name parameter (it is removed from the redirect uri parameter) and the Stack trace is accordingly:
SEVERE: Servlet.service() for servlet [default] in context with path [] threw exception
org.pac4j.core.exception.TechnicalException: name cannot be blank
at org.pac4j.core.util.CommonHelper.assertTrue(CommonHelper.java:134)
at org.pac4j.core.util.CommonHelper.assertNotBlank(CommonHelper.java:145
)
at org.pac4j.core.client.Clients.findClient(Clients.java:131)
at org.pac4j.core.engine.DefaultCallbackLogic.perform(DefaultCallbackLogic.java:70)
at org.pac4j.springframework.security.web.CallbackFilter.doFilter(CallbackFilter.java:88)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
...
I also tested the discoveryURI without v2.0 with an application created in the old style in Azure AD (v2.0 must not be created in Azure AD), which apparently lets me set a reply URL with ?client_name in it and the same as above - no client_name parameter upon return.
Note that the Microsoft rules seems now different related to where you create the the application. These URLs seem that no longer describe the correct application registration for v2.0:
But rather these ones:
I am somehow hoping that I am doing something wrong or at least there is still a solution to use pac4j for AzureAD OpenID Connect other than using a default client because we are developing a multi tenant application and there may be more customers requiring Azure AD authentication and we need one client instance for each.
Thank you,
David Dascalescu