Spring安全性中有多个身份验证提供程序的引用,但Java配置中没有示例.
以下链接提供了XML表示法: Spring Security中的多个身份验证提供程序
我们需要使用LDAP或DB进行身份验证
以下是我们的示例代码:
@Configuration
@EnableWebSecurity
public class XSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthenticationProvider authenticationProvider;
@Autowired
private AuthenticationProvider authenticationProviderDB;
@Override
@Order(1)
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authenticationProvider);
}
@Order(2)
protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authenticationProviderDB);
}
@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/scripts/**","/styles/**","/images/**","/error/**");
}
______
@Override
@Order(1)
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.antMatchers("/","/logout","/time").permitAll()
.antMatchers("/admin").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/index")
.loginProcessingUrl("/perform_login")
.usernameParameter("email")
.passwordParameter("password")
.failureUrl("/index?failed=true")
.defaultSuccessUrl("/summary",true)
.permitAll()
.and() …Run Code Online (Sandbox Code Playgroud) Following is the payload for generic template. How to give attachment ID instead of image URL.
Run Code Online (Sandbox Code Playgroud)
https://developers.facebook.com/docs/messenger-platform/send-messages/template/generic#payload显示如何提供通用模板 POST 请求和https://developers.facebook.com/docs/messenger-platform/ send-messages#attachment_reuse展示了如何使用保存的资源进行发送。如何在通用模板中将它们组合起来
{
"recipient":
{
"id":"psid"
},
"message":
{
"attachment":
{
"type":"template",
"payload":
{
"template_type":"generic",
"elements":
[
{
"title":"Welcome to PeterHats",
"image_url":"https://i.ytimg.com/vi/EGpy98wrHDo/hqdefault.jpg",
"subtitle":"Actor \n Director",
"default_action":
{
"type": "web_url",
"url": "https://www.google.co.in",
"messenger_extensions": true,
"webview_height_ratio": "tall",
"fallback_url": "https://www.facebook.com/"
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
}