修改H5登录授权
This commit is contained in:
@@ -5,7 +5,7 @@ import com.accompany.core.service.user.PhoneBlackService;
|
||||
import com.accompany.oauth2.service.MyUserDetailsService;
|
||||
import com.accompany.oauth2.service.MyUserDetailsServiceImpl;
|
||||
import com.accompany.oauth2.service.account.AccountH5LoginService;
|
||||
import com.accompany.oauth2.support.h5.AbstractH5TokenGranter;
|
||||
import com.accompany.oauth2.support.h5.H5TokenGranter;
|
||||
import com.accompany.oauth2.support.h5.PasswordH5TokenGranter;
|
||||
import com.accompany.oauth2.support.h5.VerifyCodeH5TokenGranter;
|
||||
import com.accompany.oauth2.support.password.PasswordAuthenticationProvider;
|
||||
@@ -84,12 +84,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AbstractH5TokenGranter passwordH5TokenGranter() {
|
||||
public H5TokenGranter passwordH5TokenGranter() {
|
||||
return new PasswordH5TokenGranter(myUserDetailsService(), accountH5LoginService);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AbstractH5TokenGranter verifyCodeH5TokenGranter() {
|
||||
public H5TokenGranter verifyCodeH5TokenGranter() {
|
||||
return new VerifyCodeH5TokenGranter(myUserDetailsService(), phoneBlackService, accountH5LoginService);
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ import com.accompany.core.mybatismapper.AccountH5LoginRecordMapper;
|
||||
import com.accompany.core.service.account.AccountService;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.util.JwtUtils;
|
||||
import com.accompany.oauth2.support.h5.AbstractH5TokenGranter;
|
||||
import com.accompany.oauth2.support.h5.H5TokenGranter;
|
||||
import com.accompany.oauth2.token.H5AccessToken;
|
||||
import com.accompany.sms.service.SmsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -65,7 +65,7 @@ public class AccountH5LoginService {
|
||||
private AccountManageService accountManageService;
|
||||
|
||||
@Autowired
|
||||
private List<AbstractH5TokenGranter> h5tokenGranters;
|
||||
private List<H5TokenGranter> h5tokenGranters;
|
||||
|
||||
public AccountH5LoginRecord buildRecord(Long uid, Byte loginType, String ip, String os, String appVersion, String deviceId) {
|
||||
AccountH5LoginRecord accountH5LoginRecord = new AccountH5LoginRecord();
|
||||
@@ -215,7 +215,7 @@ public class AccountH5LoginService {
|
||||
*/
|
||||
public H5AccessToken token(ServletWebRequest request) {
|
||||
String grantType = request.getParameter("grantType");
|
||||
for (AbstractH5TokenGranter tokenGranter : h5tokenGranters) {
|
||||
for (H5TokenGranter tokenGranter : h5tokenGranters) {
|
||||
if (tokenGranter.getGrantType().equals(grantType)) {
|
||||
return tokenGranter.getAuthentication(request);
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import java.util.Map;
|
||||
* @date: 2023/7/17 10:25
|
||||
* @description:
|
||||
*/
|
||||
public abstract class AbstractH5TokenGranter {
|
||||
public abstract class AbstractH5TokenGranter implements H5TokenGranter {
|
||||
|
||||
protected static final String PHONE_AREA_CODE = "phoneAreaCode";
|
||||
|
||||
|
@@ -0,0 +1,27 @@
|
||||
package com.accompany.oauth2.support.h5;
|
||||
|
||||
import com.accompany.oauth2.token.H5AccessToken;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
|
||||
/**
|
||||
* @author: liaozetao
|
||||
* @date: 2023/7/17 12:16
|
||||
* @description:
|
||||
*/
|
||||
public interface H5TokenGranter {
|
||||
|
||||
/**
|
||||
* 获取令牌
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
H5AccessToken getAuthentication(ServletWebRequest request);
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getGrantType();
|
||||
}
|
Reference in New Issue
Block a user