0
votes

I follow this guide to setup Security with Azure AD - https://docs.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-active-directory

After login to Microsoft account system redirects me to url like this https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=25802571-a250-4e99-ba72-87c6eee9f1db&scope=openid%20https://graph.microsoft.com/user.read&state=0HA8WfPariUK8QXcwMlOseVIPNVm0f4XSa_T7JZZvyE%3D&redirect_uri=http://localhost:8079/login/oauth2/code/azure&nonce=eREVP5yO5L3WvOXH6HJfb_LAT8Gk7iu6jrdu259RePM but this url doesn't redirects me to my server

UPDATE 1: I turn on debug logs and on redirect I can see below logs in console

2020-10-08 22:39:59.700 DEBUG 756 --- [onPool-worker-9] c.m.a.m.ConfidentialClientApplication    : [Correlation ID: 7e63aac3-6ace-46e6-ab45-9c86aadfeed6] Access Token was returned
2020-10-08 22:40:01.542 DEBUG 756 --- [onPool-worker-9] c.m.a.m.ConfidentialClientApplication    : [Correlation ID: 712291cd-969f-4158-b26e-4b00aadfeed6] Access Token was returned
2020-10-08 22:40:02.762 DEBUG 756 --- [onPool-worker-9] c.m.a.m.ConfidentialClientApplication    : [Correlation ID: fafb0b37-254c-4e8d-bf15-ec5faadfeed6] Access Token was returned
1

1 Answers

1
votes

I try the spring boot sample, and it works well. It redirects to http://localhost:8080/ after login with the test user.

enter image description here

You need to set the redirect URL as http://localhost:8080/login/oauth2/code/azure in the portal. Make sure the permissions are also configured and granted admin consent.

If you want to change the redirect URL, you need to add spring.security.oauth2.client.registration.azure.redirect-uri-template in the application.properties and set the redirect URL in the portal.