当前位置:   article > 正文

SpringCloud oauth2授权(密码模式,验证码模式)_getoauth2authentication

getoauth2authentication

前言

项目基于springcloud,授权决定使用提供的spring-oauth2,了解了oauth2原理之后,基于业务有很多需要重写的点;

1.获取token同时需要获取客户端信息(手机型号,app版本号等)

2.除了提供的password方式登录,还需要提供验证码登录功能

源码理解

对spring-cloud-starter-oauth2包的源码进行了简单的了解:

endpoint: 端点,/oauth/token的接口地址 TokenEndPoint是接口的逻辑

TokenGranter:token授权,默认提供了4种granter(RefreshTokenGranter,ImplicitTokenGranter,ResourceOwnerPasswordTokenGranter,ClientCredentialsTokenGranter)

自定义TokenGranter可以实现获取除了默认参数的其他参数,同时可以增加验证

AuthenticationProvider:身份验证提供者,用于验证身份,密码的匹配等都是再这通过service获取用户信息进行校验

DaoAuthenticationProvider是默认的实现类,通过重写provider来自定义校验逻辑

UserDetailsService:用户信息查询

 

实现

第一步:指定自定义provider

自定义granter

  1. package com.mlines.cloud.granter;
  2. import com.mlines.cloud.token.AppAuthenticationToken;
  3. import org.apache.commons.lang3.StringUtils;
  4. import org.springframework.security.authentication.AbstractAuthenticationToken;
  5. import org.springframework.security.authentication.AccountStatusException;
  6. import org.springframework.security.authentication.AuthenticationManager;
  7. import org.springframework.security.authentication.BadCredentialsException;
  8. import org.springframework.security.core.Authentication;
  9. import org.springframework.security.oauth2.common.exceptions.InvalidGrantException;
  10. import org.springframework.security.oauth2.provider.*;
  11. import org.springframework.security.oauth2.provider.token.AbstractTokenGranter;
  12. import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
  13. import java.util.LinkedHashMap;
  14. import java.util.Map;
  15. /**
  16. * 短信验证码方式
  17. * zhangmx
  18. */
  19. public class SMSCodeTokenGranter extends AbstractTokenGranter {
  20. private static final String GRANT_TYPE = "smscode";
  21. private final AuthenticationManager authenticationManager;
  22. public SMSCodeTokenGranter(AuthenticationManager authenticationManager,
  23. AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
  24. this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
  25. }
  26. protected SMSCodeTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices,
  27. ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, String grantType) {
  28. super(tokenServices, clientDetailsService, requestFactory, grantType);
  29. this.authenticationManager = authenticationManager;
  30. }
  31. /**
  32. * 在这个方法可以进行验证码等其他操作
  33. * @param client
  34. * @param tokenRequest
  35. * @return
  36. */
  37. @Override
  38. protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) {
  39. Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters());
  40. String username = parameters.get("username");
  41. String smscode = parameters.get("smscode");
  42. String deviceId=parameters.get("deviceId");
  43. String type=parameters.get("type");
  44. String sysVersion=parameters.get("sysVersion");
  45. String deviceVersion=parameters.get("deviceVersion");
  46. String appVersion=parameters.get("appVersion");
  47. parameters.put("loginType","sms");
  48. // Protect from downstream leaks of password
  49. parameters.remove("password");
  50. //校验验证码
  51. if(!StringUtils.equals(smscode,"1001")){
  52. throw new InvalidGrantException("验证码不正确");
  53. }
  54. Authentication userAuth = new AppAuthenticationToken(username, smscode,type,deviceId,sysVersion,deviceVersion,appVersion);
  55. ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
  56. try {
  57. userAuth = authenticationManager.authenticate(userAuth);
  58. }
  59. catch (AccountStatusException ase) {
  60. //covers expired, locked, disabled cases (mentioned in section 5.2, draft 31)
  61. throw new InvalidGrantException(ase.getMessage());
  62. }
  63. catch (BadCredentialsException e) {
  64. // If the username/password are wrong the spec says we should send 400/invalid grant
  65. throw new InvalidGrantException(e.getMessage());
  66. }
  67. if (userAuth == null || !userAuth.isAuthenticated()) {
  68. throw new InvalidGrantException("Could not authenticate user: " + username);
  69. }
  70. OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
  71. return new OAuth2Authentication(storedOAuth2Request, userAuth);
  72. }
  73. }

第二步:指定自定义provider

自定义provider:

  1. package com.mlines.cloud.provider;
  2. import com.mlines.cloud.feign.client.SysUserClient;
  3. import com.mlines.cloud.token.AppAuthenticationToken;
  4. import org.apache.commons.lang3.StringUtils;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.security.authentication.BadCredentialsException;
  7. import org.springframework.security.authentication.InternalAuthenticationServiceException;
  8. import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
  9. import org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider;
  10. import org.springframework.security.core.AuthenticationException;
  11. import org.springframework.security.core.userdetails.UserDetails;
  12. import org.springframework.security.core.userdetails.UserDetailsService;
  13. import org.springframework.security.core.userdetails.UsernameNotFoundException;
  14. import org.springframework.security.crypto.password.PasswordEncoder;
  15. import org.springframework.util.Assert;
  16. import java.util.Map;
  17. /**
  18. * Created by fp295 on 2018/11/25.4
  19. * 用户名密码登录
  20. */
  21. public class AppAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider {
  22. @Autowired
  23. private UserDetailsService userDetailsService;
  24. @Autowired
  25. private SysUserClient sysUserClient;
  26. private PasswordEncoder passwordEncoder;
  27. // /**
  28. // * 根据用户名取回用户信息后,进入此方法判断密码是否匹配,如果是验证码登录 判断验证码是否正确
  29. // * @param var1
  30. // * @param authentication
  31. // * @throws AuthenticationException
  32. // */
  33. // @Override
  34. // protected void additionalAuthenticationChecks(UserDetails var1, Authentication authentication) throws AuthenticationException {
  35. //
  36. // if(authentication.getCredentials() == null) {
  37. // this.logger.debug("Authentication failed: no credentials provided");
  38. // throw new BadCredentialsException(this.messages.getMessage("AppAuthenticationProvider.badCredentials", "Bad credentials"));
  39. // } else {
  40. // String presentedPassword = authentication.getCredentials().toString();
  41. // Map<String,Object> otherParams=(Map<String,Object>)authentication.getDetails();//其他参数
  42. // String loginType=(String)otherParams.get("loginType");
  43. // if(StringUtils.equals(loginType,"password")){//密码方式登录
  44. // if (!passwordEncoder.matches(presentedPassword, var1.getPassword())) {
  45. // logger.debug("密码错误");
  46. //
  47. // throw new BadCredentialsException(messages.getMessage(
  48. // "400",
  49. // "密码错误"));
  50. // }
  51. // }
  52. //
  53. // 验证码验证,调用公共服务查询 key 为authentication.getPrincipal()的value, 并判断其与验证码是否匹配
  54. if(!"1000".equals(presentedPassword)){
  55. this.logger.debug("Authentication failed: verifyCode does not match stored value");
  56. throw new BadCredentialsException(this.messages.getMessage("AppAuthenticationProvider.badCredentials", "Bad verifyCode"));
  57. }
  58. // }
  59. // }
  60. //
  61. //
  62. //
  63. // @Override
  64. // protected Authentication createSuccessAuthentication(Object principal, Authentication authentication, UserDetails user,String deviceId) {
  65. // AppAuthenticationToken result = new AppAuthenticationToken(principal, authentication.getCredentials(), user.getAuthorities(),deviceId);
  66. // result.setDetails(authentication.getDetails());
  67. // return result;
  68. // }
  69. //
  70. // @Override
  71. // protected UserDetails retrieveUser(String phone, Authentication authentication) throws AuthenticationException {
  72. // UserDetails loadedUser;
  73. // try {
  74. // loadedUser = userDetailsService.loadUserByUsername(phone);
  75. // } catch (UsernameNotFoundException var6) {
  76. // throw var6;
  77. // } catch (Exception var7) {
  78. // throw new InternalAuthenticationServiceException(var7.getMessage(), var7);
  79. // }
  80. //
  81. // if(loadedUser == null) {
  82. // throw new InternalAuthenticationServiceException("UserDetailsService returned null, which is an interface contract violation");
  83. // } else {
  84. // return loadedUser;
  85. // }
  86. // }
  87. @Override
  88. protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
  89. if(authentication.getCredentials() == null) {
  90. this.logger.debug("Authentication failed: no credentials provided");
  91. throw new BadCredentialsException(this.messages.getMessage("AppAuthenticationProvider.badCredentials", "Bad credentials"));
  92. } else {
  93. String presentedPassword = authentication.getCredentials().toString();
  94. Map<String,Object> otherParams=(Map<String,Object>)authentication.getDetails();//其他参数
  95. String loginType=(String)otherParams.get("loginType");
  96. if(StringUtils.equals(loginType,"password")){//密码方式登录
  97. if (!passwordEncoder.matches(presentedPassword, userDetails.getPassword())) {
  98. logger.debug("密码错误");
  99. throw new BadCredentialsException(messages.getMessage(
  100. "400",
  101. "密码错误"));
  102. }
  103. }
  104. //
  105. // // 验证码验证,调用公共服务查询 key 为authentication.getPrincipal()的value, 并判断其与验证码是否匹配
  106. // if(!"1000".equals(presentedPassword)){
  107. // this.logger.debug("Authentication failed: verifyCode does not match stored value");
  108. // throw new BadCredentialsException(this.messages.getMessage("AppAuthenticationProvider.badCredentials", "Bad verifyCode"));
  109. // }
  110. }
  111. }
  112. @Override
  113. protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
  114. UserDetails loadedUser;
  115. try {
  116. loadedUser = userDetailsService.loadUserByUsername(username);
  117. } catch (UsernameNotFoundException var6) {
  118. throw var6;
  119. } catch (Exception var7) {
  120. throw new InternalAuthenticationServiceException(var7.getMessage(), var7);
  121. }
  122. if(loadedUser == null) {
  123. throw new InternalAuthenticationServiceException("UserDetailsService returned null, which is an interface contract violation");
  124. } else {
  125. return loadedUser;
  126. }
  127. }
  128. @Override
  129. public boolean supports(Class<?> authentication) {
  130. return AppAuthenticationToken.class.isAssignableFrom(authentication);
  131. }
  132. public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
  133. Assert.notNull(passwordEncoder, "passwordEncoder cannot be null");
  134. this.passwordEncoder = passwordEncoder;
  135. }
  136. protected PasswordEncoder getPasswordEncoder() {
  137. return passwordEncoder;
  138. }
  139. //
  140. //
  141. public UserDetailsService getUserDetailsService() {
  142. return userDetailsService;
  143. }
  144. public void setUserDetailsService(UserDetailsService userDetailsService) {
  145. this.userDetailsService = userDetailsService;
  146. }
  147. }

自定义service

 

其他代码片段

  1. package com.mlines.cloud.config;
  2. import com.mlines.cloud.granter.AppResourceOwnerPasswordTokenGranter;
  3. import com.mlines.cloud.granter.SMSCodeTokenGranter;
  4. import com.mlines.cloud.handler.CustomWebResponseExceptionTranslator;
  5. import com.mlines.cloud.provider.AppAuthenticationProvider;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.context.annotation.Bean;
  8. import org.springframework.context.annotation.Configuration;
  9. import org.springframework.security.authentication.AuthenticationManager;
  10. import org.springframework.security.authentication.AuthenticationProvider;
  11. import org.springframework.security.authentication.ProviderManager;
  12. import org.springframework.security.core.userdetails.UserDetailsService;
  13. import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  14. import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
  15. import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
  16. import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
  17. import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
  18. import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
  19. import org.springframework.security.oauth2.provider.ClientDetailsService;
  20. import org.springframework.security.oauth2.provider.CompositeTokenGranter;
  21. import org.springframework.security.oauth2.provider.OAuth2RequestFactory;
  22. import org.springframework.security.oauth2.provider.TokenGranter;
  23. import org.springframework.security.oauth2.provider.client.ClientCredentialsTokenGranter;
  24. import org.springframework.security.oauth2.provider.code.AuthorizationCodeServices;
  25. import org.springframework.security.oauth2.provider.code.AuthorizationCodeTokenGranter;
  26. import org.springframework.security.oauth2.provider.implicit.ImplicitTokenGranter;
  27. import org.springframework.security.oauth2.provider.refresh.RefreshTokenGranter;
  28. import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
  29. import org.springframework.security.oauth2.provider.token.TokenEnhancer;
  30. import org.springframework.security.oauth2.provider.token.TokenEnhancerChain;
  31. import org.springframework.security.oauth2.provider.token.TokenStore;
  32. import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
  33. import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
  34. import java.util.ArrayList;
  35. import java.util.Arrays;
  36. import java.util.List;
  37. @Configuration
  38. @EnableAuthorizationServer
  39. public class OAuthConfiguration extends AuthorizationServerConfigurerAdapter {
  40. @Autowired
  41. private AuthenticationManager authenticationManager;
  42. @Autowired
  43. private CustomAccessDeniedHandler customAccessDeniedHandler;
  44. @Autowired
  45. private CustomWebResponseExceptionTranslator customWebResponseExceptionTranslator;
  46. // @Autowired
  47. // private UsernameUserDetailService userDetailsService;
  48. @Autowired
  49. private UserDetailsService userDetailsService;//读取客户端的service app可以是一个客户端 web可以是一个客户端
  50. @Override
  51. public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
  52. clients.inMemory()
  53. .withClient("web-app")
  54. .secret( new BCryptPasswordEncoder().encode("rq9nuNkIwT"))
  55. .scopes("web-app")
  56. .authorizedGrantTypes("password","smscode", "refresh_token")
  57. .accessTokenValiditySeconds(86400)//超时
  58. .refreshTokenValiditySeconds(604800)
  59. .and()
  60. .withClient("android-app")
  61. .secret(new BCryptPasswordEncoder().encode("ijnuybdsvv"))
  62. .scopes("android-app")
  63. .authorizedGrantTypes("password","smscode", "refresh_token")
  64. .accessTokenValiditySeconds(86400*7)
  65. .refreshTokenValiditySeconds(604800*4);
  66. }
  67. @Bean
  68. public UserDetailsService userDetailsService(){
  69. return userDetailsService;
  70. }
  71. @Bean
  72. public JwtAccessTokenConverter jwtAccessTokenConverter() {
  73. JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
  74. jwtAccessTokenConverter.setSigningKey("cloudserver");
  75. return jwtAccessTokenConverter;
  76. }
  77. public static void main(String[] args){
  78. // Jwt jwt=JwtHelper.decode("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtc2ciOiLnmbvlvZXmiJDlip8iLCJjb2RlIjoyMDAsImRhdGEiOnsibGFiZWwiOiLlvKDlrablj4siLCJpZCI6Mn0sInVzZXJfbmFtZSI6IjE2NjY2NjY2NjIxIiwic2NvcGUiOlsid2ViLWFwcCJdLCJleHAiOjE1NTA3NDc1NTQsImF1dGhvcml0aWVzIjpbIlJPTEVfVVNFUiJdLCJqdGkiOiJhZDk1OGZhMC1mYWNiLTQyOGQtYWZlMi0xNGQ0OGJhMTBjMjAiLCJjbGllbnRfaWQiOiJ3ZWItYXBwIn0.yQbgx8rXCkwqdYWhGOBIRJZyIe9VOKrV3yNIcqVE294");
  79. // System.out.println(new String(jwt.getClaims().getBytes()));
  80. System.out.println(new BCryptPasswordEncoder().encode("123456"));
  81. System.out.println(new BCryptPasswordEncoder().matches("123456","$2a$10$xT8XiML30Yer0d3cYBmXfewMgZtQyiGc25zZs9ipkvKJuyOQDwcF2"));
  82. }
  83. @Bean
  84. public TokenStore jwtTokenStore() {
  85. return new JwtTokenStore(jwtAccessTokenConverter());
  86. }
  87. @Override
  88. public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
  89. TokenEnhancerChain enhancerChain = new TokenEnhancerChain();
  90. enhancerChain.setTokenEnhancers(Arrays.asList(customTokenEnhancer(), jwtAccessTokenConverter()));
  91. endpoints.tokenStore(jwtTokenStore())
  92. .accessTokenConverter(jwtAccessTokenConverter())
  93. .reuseRefreshTokens(false)//该字段设置设置refresh token是否重复使用,true:reuse;false:no reuse.
  94. .authenticationManager(authenticationManager)
  95. .userDetailsService(userDetailsService)
  96. .tokenEnhancer(enhancerChain);
  97. endpoints.exceptionTranslator(customWebResponseExceptionTranslator);
  98. endpoints.tokenGranter(new CompositeTokenGranter(getTokenGranters(endpoints)));
  99. }
  100. private List<TokenGranter> getTokenGranters(AuthorizationServerEndpointsConfigurer endpoints){
  101. ClientDetailsService clientDetails = endpoints.getClientDetailsService();
  102. AuthorizationServerTokenServices tokenServices = endpoints.getTokenServices();
  103. AuthorizationCodeServices authorizationCodeServices = endpoints.getAuthorizationCodeServices();
  104. OAuth2RequestFactory requestFactory = endpoints.getOAuth2RequestFactory();
  105. // ((DefaultTokenServices)tokenServices).setAuthenticationManager(new ProviderManager(getProvider(),null));
  106. List<TokenGranter> tokenGranters = new ArrayList<TokenGranter>();
  107. tokenGranters.add(new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientDetails,
  108. requestFactory));
  109. tokenGranters.add(new RefreshTokenGranter(tokenServices, clientDetails, requestFactory));
  110. ImplicitTokenGranter implicit = new ImplicitTokenGranter(tokenServices, clientDetails, requestFactory);
  111. tokenGranters.add(implicit);
  112. tokenGranters.add(new ClientCredentialsTokenGranter(tokenServices, clientDetails, requestFactory));
  113. if (authenticationManager != null) {
  114. // tokenGranters.add(new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices,
  115. // clientDetails, requestFactory));//有了自定义的用户名密码验证方式不需要初始化默认的了
  116. tokenGranters.add(new AppResourceOwnerPasswordTokenGranter(new ProviderManager(getProvider(),null),tokenServices,endpoints.getClientDetailsService(),endpoints.getOAuth2RequestFactory()));
  117. tokenGranters.add(new SMSCodeTokenGranter(new ProviderManager(getProvider(),null),tokenServices,endpoints.getClientDetailsService(),endpoints.getOAuth2RequestFactory()));
  118. }
  119. //添加自定义granter
  120. return tokenGranters;
  121. }
  122. private List<AuthenticationProvider> getProvider(){
  123. List<AuthenticationProvider> list=new ArrayList<>();
  124. AppAuthenticationProvider provider = new AppAuthenticationProvider();
  125. // 设置userDetailsService
  126. provider.setUserDetailsService(userDetailsService);
  127. provider.setPasswordEncoder(new BCryptPasswordEncoder());
  128. // 禁止隐藏用户未找到异常
  129. provider.setHideUserNotFoundExceptions(false);
  130. list.add(provider);
  131. return list;
  132. }
  133. @Override
  134. public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
  135. security.allowFormAuthenticationForClients()
  136. .authenticationEntryPoint(new AuthExceptionEntryPoint())//自定义异常信息
  137. .accessDeniedHandler(customAccessDeniedHandler)
  138. .tokenKeyAccess("permitAll()")
  139. .checkTokenAccess("isAuthenticated()");
  140. }
  141. @Bean
  142. public TokenEnhancer customTokenEnhancer() {
  143. return new CustomTokenEnhancer();// 写入自定义信息
  144. }
  145. //
  146. // @Override
  147. // public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
  148. // oauthServer.authenticationEntryPoint(new AuthExceptionEntryPoint());
  149. // }
  150. }
  1. package com.mlines.cloud.config;
  2. import com.mlines.cloud.filter.AppLoginAuthenticationFilter;
  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.authentication.AuthenticationManager;
  7. import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  8. import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  9. import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  10. import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  11. import org.springframework.security.core.userdetails.UserDetailsService;
  12. import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  13. @Configuration
  14. @EnableWebSecurity
  15. public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
  16. //
  17. @Autowired
  18. private UserDetailsService userDetailsService;
  19. @Bean
  20. public BCryptPasswordEncoder passwordEncoder() {
  21. return new BCryptPasswordEncoder();
  22. }
  23. // @Override
  24. // protected void configure(AuthenticationManagerBuilder auth) throws Exception {
  25. // auth
  26. // .userDetailsService(userDetailsService())
  27. // .passwordEncoder(passwordEncoder());
  28. // }
  29. @Override
  30. protected void configure(AuthenticationManagerBuilder auth) throws Exception {
  31. //TODO:use md5
  32. // auth.authenticationProvider(appAuthenticationProvider());
  33. auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
  34. }
  35. //不定义没有password grant_type
  36. @Override
  37. @Bean
  38. public AuthenticationManager authenticationManagerBean() throws Exception {
  39. return super.authenticationManagerBean();
  40. }
  41. //
  42. @Bean
  43. public AppLoginAuthenticationFilter getPhoneLoginAuthenticationFilter() {
  44. AppLoginAuthenticationFilter filter = new AppLoginAuthenticationFilter();
  45. try {
  46. filter.setAuthenticationManager(this.authenticationManagerBean());
  47. } catch (Exception e) {
  48. e.printStackTrace();
  49. }
  50. // filter.setAuthenticationSuccessHandler(new LoginAuthSuccessHandler());
  51. return filter;
  52. }
  53. // /**
  54. // * 手机验证码登陆过滤器
  55. // * @return
  56. // */
  57. // @Bean
  58. // public UserNamePwdAuthenticationFilter getUserNamePwdFilter() {
  59. // UserNamePwdAuthenticationFilter filter = new UserNamePwdAuthenticationFilter();
  60. // try {
  61. // filter.setAuthenticationManager(this.authenticationManagerBean());
  62. // } catch (Exception e) {
  63. // e.printStackTrace();
  64. // }
  65. // return filter;
  66. // }
  67. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/534117
推荐阅读
相关标签
  

闽ICP备14008679号