I've used following link https://learn.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-active-directory
In this I was able to authorize, but when the page opens, instead of the HTML page I want to show, I see this:
But in controller I'm calling newhome.html
:
if (LOG.isTraceEnabled()) {
}
LOG.trace("<<< onInit() Navigating to Home");
return "newhome";
} else {
if (LOG.isTraceEnabled()) {
}
LOG.trace("<< onInit() Navigating to Error");
return "error";
}
Controller code:
@RequestMapping(value = "/")
@ResponseBody
@PreAuthorize("hasRole('ROLE_group1')"
+ "|| hasRole('ROLE_group2')"
+ "|| hasRole('ROLE_group3')")
public String onInit(
Model model,
@RequestHeader(value = "LIST", defaultValue = "group1") String groups,
@RequestHeader(value = "USERNAME", defaultValue = "shubham") String userName) {
if (userName != null && !userName.isEmpty()) {
if (LOG.isTraceEnabled()) {
LOG.trace("<< onInit() Navigating to Home");
return "newhome";
} else {
LOG.trace("<< onInit() Navigating to Error");
return "error";
}
}
}
Here newhome
and error
are HTML pages.
It was working fine before adding Azure AD authentication, but now after implementing, it is just showing the of the HTML page.
I would be thankfull for any help.
By using @ResponseBody you are returning a simple String. I’m assuming you want to return a template page called “newhome” instead. Just remove the @ResponseBody and it should work