I am trying run azure active directory for my spring boot with web services. The problem is when I login successfully, It throws an error which is:
I have added following properties (tetant-id, client-id, client-secret, user-group.allowed-group-names) with
azure.activedirectory.redirect-uri-template=http://localhost:8080/login/oauth2/code/
and my configuration is:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true)
public class AADSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers("/health");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/oauth2/**", "/login/**")
.permitAll()
.anyRequest()
.authenticated()
.and()
.oauth2Login();
}
}
simple controller request is:
@GetMapping("/list")
@PreAuthorize("hasRole('Admin') or hasRole('Users')")
public String getListPage() {
return "list";
}
versions of the dependencies are:
<spring.security.version>5.6.0</spring.security.version>
<spring.boot.version>2.5.4</spring.boot.version>
<azure.version>3.10.0</azure.version>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-boot-starter-active-directory</artifactId>
<version>${azure.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
<version>5.6.0</version>
</dependency>
Could you enlighten me with the issue so that I could get around please?
Update: solved using msal4j.
the sample example is:
https://github.com/Azure-Samples/ms-identity-java-webapp/tree/master/msal-java-webapp-sample