Skip to content

Commit

Permalink
Merge branch 'feature/1.0.0' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
fuhouyu committed Oct 22, 2024
2 parents 7b7e397 + 4cb1fe8 commit b7c25c5
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.fuhouyu.framework.security.model.dto;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
package com.fuhouyu.framework.function;

/**
* <p>
* 应用dto传输对象
* 回调函数
* </p>
*
* @author fuhouyu
* @since 2024/8/15 17:16
* @since 2024/10/22 21:01
*/
@ToString
@Getter
@Setter
public class ApplicationDTO {

private String clientId;

private String clientSecret;

private Integer accessTokenExpireTime;
@FunctionalInterface
public interface Callback<T> {

private Integer refreshTokenExpireTime;
/**
* 回调函数
*
* @param t t
*/
void call(T t);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class CipherFieldQueryInterceptor implements Interceptor {

@Override
public Object intercept(Invocation invocation) throws Throwable {
// TODO 待实现
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public TokenStore tokenStore(CacheService<String, Object> cacheService) {
* 认证管理器配置这里可以进行除其他登录模式的扩展,需要实现{@link AuthenticationProvider}
*
* @param authenticationProviders 认证提供者集合
* @param userDetailsService 用户接口详情
* @param passwordEncoder 密码认证管理器
* @param userDetailsService 用户接口详情
* @param passwordEncoder 密码认证管理器
* @return 认证管理器
*/
@Bean("authenticationManager")
Expand All @@ -94,7 +94,7 @@ public PasswordEncoder passwordEncoder() {
/**
* dao层实现
*
* @param passwordEncoder 密码管理器
* @param passwordEncoder 密码管理器
* @param userDetailsService 用户详情接口
* @return dao默认实现
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2024-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fuhouyu.framework.security.core;

import com.fuhouyu.framework.security.core.authentication.wechat.WechatAppletsPlatformProvider;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.security.authentication.AbstractAuthenticationToken;

/**
* <p>
* 默认的映射枚举类
* </p>
*
* @author fuhouyu
* @since 2024/10/22 21:25
*/
@RequiredArgsConstructor
@Getter
@SuppressWarnings("unchecked")
public enum GrantTypeAuthenticationTokenEnum implements GrantTypeAuthenticationTokenMapping {

WECHAT_APPLETS("WECHAT_APPLETS") {
@Override
public <T extends AbstractAuthenticationToken> Class<T> getAuthenticationTokenClass() {
return (Class<T>) WechatAppletsPlatformProvider.WechatAppletsAuthenticationToken.class;
}
},
;

private final String grantType;

/**
* 安全获取枚举类
*
* @param grantType 授权类型
* @return 枚举类
*/
public static GrantTypeAuthenticationTokenEnum safeEnumValueOf(String grantType) {
try {
return GrantTypeAuthenticationTokenEnum.valueOf(grantType);
} catch (IllegalArgumentException | NullPointerException e) {
throw new IllegalArgumentException("Invalid value for enum: " + grantType);
}
}

@Override
public abstract <T extends AbstractAuthenticationToken> Class<T> getAuthenticationTokenClass();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2024-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fuhouyu.framework.security.core;

import com.fuhouyu.framework.utils.JacksonUtil;
import org.springframework.security.authentication.AbstractAuthenticationToken;

/**
* <p>
* 授权类型和AuthenticationToken映射
* </p>
*
* @author fuhouyu
* @since 2024/10/22 21:18
*/
public interface GrantTypeAuthenticationTokenMapping {

/**
* 获取授权类型
*
* @return 授权类型
*/
String getGrantType();

/**
* 获取授权token类型
*
* @param <T> 具体的子类
* @return 授权token类型
*/
<T extends AbstractAuthenticationToken> Class<T> getAuthenticationTokenClass();

/**
* 加载该类
*
* @param param 参数映射
* @return AbstractAuthenticationToken 子类
*/
default AbstractAuthenticationToken loadAuthenticationToken(Object param) {
Class<AbstractAuthenticationToken> authenticationTokenClass = this.getAuthenticationTokenClass();
return JacksonUtil.tryParse(() ->
JacksonUtil.getObjectMapper().convertValue(param, authenticationTokenClass));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.fuhouyu.framework.security.core.authentication.wechat;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fuhouyu.framework.security.core.AbstractAuthenticationProvider;
import com.fuhouyu.framework.security.properties.OpenPlatformAuthProperties;
import com.fuhouyu.framework.utils.JacksonUtil;
Expand Down Expand Up @@ -141,12 +143,15 @@ public static class WechatAppletsAuthenticationToken extends AbstractAuthenticat
*/
private final String jsCode;


/**
* 构造函数
*
* @param jsCode 登录时获取的 code,可通过wx.login获取
*/
public WechatAppletsAuthenticationToken(String jsCode) {
@JsonCreator
public WechatAppletsAuthenticationToken(
@JsonProperty("jsCode") String jsCode) {
super(List.of());
this.jsCode = jsCode;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.fuhouyu.framework.security.properties;

import com.fuhouyu.framework.constants.ConfigPropertiesConstant;
import com.fuhouyu.framework.security.core.GrantTypeAuthenticationTokenEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
Expand Down Expand Up @@ -46,19 +47,7 @@ public class OpenPlatformAuthProperties {
/**
* 客户端相关配置
*/
private Map<OpenPlatformAuthTypeEnum, AuthDetail> auth;

/**
* 平台类型
*/
public enum OpenPlatformAuthTypeEnum {
/**
* 微信小程序
*/
WECHAT_APPLET,


}
private Map<GrantTypeAuthenticationTokenEnum, AuthDetail> auth;

/**
* 授权的详情
Expand Down
Loading

0 comments on commit b7c25c5

Please sign in to comment.