zoukankan      html  css  js  c++  java
  • 修改Spring Social默认提交地址

     1 package cn.coreqi.social.config;
     2 
     3 import org.springframework.social.security.SocialAuthenticationFilter;
     4 import org.springframework.social.security.SpringSocialConfigurer;
     5 
     6 public class CoreqiSpringSocialConfig extends SpringSocialConfigurer {
     7 
     8     @Override
     9     protected <T> T postProcess(T object) {
    10         SocialAuthenticationFilter filter = (SocialAuthenticationFilter)super.postProcess(object);
    11         filter.setFilterProcessesUrl("/coreqi/auth");
    12         return (T) filter;
    13     }
    14 }

     1 package cn.coreqi.social.config;
     2 
     3 import org.springframework.beans.factory.annotation.Autowired;
     4 import org.springframework.context.annotation.Bean;
     5 import org.springframework.context.annotation.Configuration;
     6 import org.springframework.security.crypto.encrypt.Encryptors;
     7 import org.springframework.social.config.annotation.EnableSocial;
     8 import org.springframework.social.config.annotation.SocialConfigurerAdapter;
     9 import org.springframework.social.connect.ConnectionFactoryLocator;
    10 import org.springframework.social.connect.UsersConnectionRepository;
    11 import org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository;
    12 import org.springframework.social.security.SpringSocialConfigurer;
    13 
    14 import javax.sql.DataSource;
    15 
    16 @Configuration
    17 @EnableSocial
    18 public class SocialConfig extends SocialConfigurerAdapter {
    19 
    20     @Autowired
    21     private DataSource dataSource;
    22 
    23     /**
    24      *
    25      * @param connectionFactoryLocator  作用是去根据条件去查找应该用那个connectionFactory,因为系统中可能有很多的connectionFactory。
    26      * @return
    27      */
    28     @Override
    29     public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) {
    30         //第三个参数的作用是把插入到数据库的数据进行加解密
    31         JdbcUsersConnectionRepository jdbcUsersConnectionRepository = new JdbcUsersConnectionRepository(dataSource,connectionFactoryLocator, Encryptors.noOpText());
    32         //jdbcUsersConnectionRepository.setTablePrefix(); //设置数据表的前缀
    33         return jdbcUsersConnectionRepository;
    34     }
    35 
    36     /**
    37      * 声明后还需要加在SpringSecurity过滤器链上
    38      * @return
    39      */
    40     @Bean
    41     public SpringSocialConfigurer coreqiSocialSecurityConfig(){
    42         return new CoreqiSpringSocialConfig();
    43     }
    44 }

    ⒊在SpringSecurity Config方法上添加过滤器链

  • 相关阅读:
    pytest文档19-pytest分布式执行(pytest-xdist)
    pytest文档18-配置文件pytest.ini
    pytest文档17-fixture之autouse=True
    pytest文档16-用例a失败,跳过测试用例b和c并标记失败xfail
    pytest文档15-使用自定义标记mark
    pytest文档14-函数传参和fixture传参数request
    pytest文档12-skip跳过用例
    pytest文档11-assert断言
    创建express项目
    docker安装脚本
  • 原文地址:https://www.cnblogs.com/fanqisoft/p/10639822.html
Copyright © 2011-2022 走看看