I am using the authentications quickstart of microsoft for spring and it always redirected me to http://localhost:8080/login. Even when I specify that I need to access another page for example http://localhost:8080/secure_page, whenever I press the login button and start the login process with my microsoft account it redirects me to http://localhost:8080/login, what is wrong. someone knows how I can make it redirect me to other pages. I have tried everything but it still doesn't work. Thank you for your help
this is my application.properties
logging.level.org.springframework.*=DEBUG
server.address=localhost
server.port=8080
homePage=http://${server.address}:${server.port}
ssoServiceUrl=https://login.microsoftonline.com/common
endSessionEndpoint=https://login.microsoftonline.com/common/oauth2/v2.0/logout
security.oauth2.client.client-id=......
security.oauth2.client.client-secret=.....
security.oauth2.client.scope=openid profile
security.oauth2.client.authentication-scheme=header
security.oauth2.client.client-authentication-scheme=form
security.oauth2.issuer=https://login.microsoftonline.com/......./v2.0
security.oauth2.client.access-token-uri=${ssoServiceUrl}/oauth2/v2.0/token
security.oauth2.client.user-authorization-uri=${ssoServiceUrl}/oauth2/v2.0/authorize
security.oauth2.resource.user-info-uri=https://graph.microsoft.com/oidc/userinfo
aad.msGraphEndpointHost="https://graph.microsoft.com/"
server.servlet.session.cookie.secure=true
when I write "...." it means that it is sensitive data and I have not wrote it for security. this is my controller class.
@Controller
public class SecurePageController {
@RequestMapping("/secure_page")
public ModelAndView securePage(){
ModelAndView mav = new ModelAndView("secure_page");
return mav;
}
@RequestMapping("/")
public ModelAndView indexPage() {
ModelAndView mav = new ModelAndView("index");
return mav;
}
}
this one is the index of the example
....
<body>
<h3 style="text-align:center;">Authentication</h3>
<br>
<br>
<form style="text-align:center;" action="/secure_page">
<input type="submit" value="Login" class="btn btn-primary">
</form>
</body>
</html>
at least this is the configuration
@Configuration
@EnableOAuth2Sso
@Order(value = 0)
public class AppConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private Environment env;
@Override
public void configure(HttpSecurity http) throws Exception {
String logoutUrl = env.getProperty("endSessionEndpoint") + "?post_logout_redirect_uri=" +
URLEncoder.encode(env.getProperty("homePage"), "UTF-8");
http.antMatcher("/**")
.authorizeRequests()
.antMatchers("/", "/login**", "/error**")
.permitAll()
.anyRequest()
.authenticated()
.and()
.logout()
.deleteCookies()
.invalidateHttpSession(true)
.logoutSuccessUrl(logoutUrl);
}
}
The example is working but ever with the false url redirection. I would appreciate any kind of information because I always get the same result even if in the index I specifically call /secure_page, always the url_redirect in the url is /login and not /secure_page.
If you have Application Administrator rights can change in the Azure Portal.
Azure Active Directory, App Registrations,
You will need to search for your App name
Authentication.
There will be a section for 'Redirect URIs'