天蓝色的广告配置问题
azure ad config problems
抱歉,我不会说英语。
但是我遇到了一些问题
目前正在使用 Microsoft Azure AD 登录
但是遇到如下问题
Method springSecurityFilterChain in org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration required a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' in your configuration.
application.yml
server:
port: 8080
forward-headers-strategy: native
spring:
security:
oauth2:
client:
provider:
azure-ad:
authorization-uri: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
token-uri: https://login.microsoftonline.com/common/oauth2/v2.0/token
jwk-set-uri: https://login.microsoftonline.com/common/discovery/v2.0/keys
registration:
azure-client:
provider: azure-ad
client-id: 'xxxxxxxxxx'
client-secret: 'xxxxxxxxxxxxxxxx'
authorization-grant-type: authorization_code
redirect-uri: '{baseUrl}/login/oauth2/code/'
scope: openid,profile
SecurityConfig.java
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class AzureADSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure( HttpSecurity http ) throws Exception {
http.authorizeRequests()
.antMatchers("/","/login").permitAll()
.anyRequest().authenticated()
.and()
.oauth2Login();
//.defaultSuccessUrl("/monitor");
}
}
Controller.java
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class AzureADController {
@GetMapping("/Admin")
public String Admin() {
System.out.println("================== Azure ad ==================");
return "Admin message";
}
}
请问大家有什么想法吗?非常感谢。
客户端注册似乎多了一个缩进。注册和提供商应该在 spring.security.oauth2.client
下的同一级别
spring.security.oauth2.client.provider.azure-ad
spring.security.oauth2.client.registration.azure-client
参见:https://docs.spring.io/spring-security/site/docs/5.2.12.RELEASE/reference/html/oauth2.html
抱歉,我不会说英语。 但是我遇到了一些问题
目前正在使用 Microsoft Azure AD 登录 但是遇到如下问题
Method springSecurityFilterChain in org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration required a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' in your configuration.
application.yml
server:
port: 8080
forward-headers-strategy: native
spring:
security:
oauth2:
client:
provider:
azure-ad:
authorization-uri: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
token-uri: https://login.microsoftonline.com/common/oauth2/v2.0/token
jwk-set-uri: https://login.microsoftonline.com/common/discovery/v2.0/keys
registration:
azure-client:
provider: azure-ad
client-id: 'xxxxxxxxxx'
client-secret: 'xxxxxxxxxxxxxxxx'
authorization-grant-type: authorization_code
redirect-uri: '{baseUrl}/login/oauth2/code/'
scope: openid,profile
SecurityConfig.java
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class AzureADSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure( HttpSecurity http ) throws Exception {
http.authorizeRequests()
.antMatchers("/","/login").permitAll()
.anyRequest().authenticated()
.and()
.oauth2Login();
//.defaultSuccessUrl("/monitor");
}
}
Controller.java
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class AzureADController {
@GetMapping("/Admin")
public String Admin() {
System.out.println("================== Azure ad ==================");
return "Admin message";
}
}
请问大家有什么想法吗?非常感谢。
客户端注册似乎多了一个缩进。注册和提供商应该在 spring.security.oauth2.client
下的同一级别spring.security.oauth2.client.provider.azure-ad
spring.security.oauth2.client.registration.azure-client
参见:https://docs.spring.io/spring-security/site/docs/5.2.12.RELEASE/reference/html/oauth2.html