I am trying to implement azure ad authentication in spring boot web application. I have registered application and added below redirect uri
https://xxxxxxxxxxxxx/xxxxxxxxx/login/oauth2/code/azure/
http://localhost:8080/login/oauth2/code/azure/
When tested in localhost, everything is working fine. Below is the content of application.properties
application.properties
#disable the white label error page entirely
server.error.whitelabel.enabled=false
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
# Specifies your Active Directory ID:
azure.activedirectory.tenant-id=x-xxxxx-xxxxx-xxx-xxxxxxx
# Specifies your App Registration's Application ID:
azure.activedirectory.client-id=xxxxx-xxxx-xxxx-xxxx-xxxxxxx
# Specifies your App Registration's secret key:
azure.activedirectory.client-secret=xxxxxxxxxxxxx
POM.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-active-directory-spring-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
when i deploy the code, i am getting microsoft login prompts which reuquest url as
Redirect URI in request header is http while what i have configured is portal is https. SO thats giving reply url mismatch error. How can i force https redirect uri in request?
I tried adding
azure.activedirectory.redirect-uri-template= https://xxxxxxxxxxxx/xxxxxxx/login/oauth2/code/azure/
This didn't worked as well. Thanks in advance
Subham
server.forward-headers-strategy=native
in applications.properties. For more details, please refer to stackoverflow.com/questions/64403718/… – Jim Xusecurity.oauth2.client.pre-established-redirect-uri=https://yourappurl.net/login security.oauth2.client.registered-redirect-uri=https://yourappurl.net/login security.oauth2.client.use-current-uri=false server.tomcat.remote-ip-header=x-forwarded-for server.tomcat.protocol-header=x-forwarded-proto server.tomcat.use-relative-redirects=true server.use-forward-headers=true server.tomcat.internal-proxies=.*
– Jim Xu