Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ public class FrameMajorListener {
@EventListener
public void onStart(ApplicationPreparedEvent event) {

TFrame.tframe.setFrameStatus(FrameStatus.PREPARING);
TFrame tframe = TFrame.tframe;
tframe.setFrameStatus(FrameStatus.PREPARING);

TFrame.tframe.callEvent(new FramePreInstallEvent(System.nanoTime() - TalexFrameApplication.startedTimeStamp));
tframe.callEvent(new FramePreInstallEvent(System.nanoTime() - TalexFrameApplication.startedTimeStamp));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ public boolean unRegisterController(WebPlugin plugin, TApp controller) {

}

RequestAnalyser.removeRequests(controller);

this.controllers.remove(controller.getClass(), controller);
this.controllerPluginMap.remove(controller, plugin.getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import com.talexframe.frame.core.modules.network.connection.app.addon.param.valid.min.value.ReceiverMinValueValidateAddon;
import com.talexframe.frame.core.modules.network.connection.app.addon.param.valid.nonull.ReceiverNoNullValidateAddon;
import com.talexframe.frame.core.modules.network.connection.app.addon.param.valid.pattern.ReceiverPatternValidateAddon;
import com.talexframe.frame.core.modules.network.connection.app.addon.permission.ReceiverPermissionAddon;
import com.talexframe.frame.core.modules.plugins.adapt.PluginCompAdapter;
import com.talexframe.frame.core.modules.plugins.addon.PluginScanner;
import com.talexframe.frame.core.modules.plugins.core.WebPlugin;
import com.talexframe.frame.core.talex.FrameCreator;
import lombok.SneakyThrows;
import org.springframework.stereotype.Component;

import java.util.Comparator;
import java.util.HashMap;
Expand All @@ -31,7 +31,6 @@
*
* @author TalexDreamSoul 22/04/02 下午 08:44 Project: TalexFrame
*/
@Component
public class ReceiverAddonAdapter extends PluginCompAdapter<ReceiverAddon> {

private static final Map<Class<?>, ReceiverAddon> receiverAddonMap = new HashMap<>();
Expand All @@ -49,6 +48,7 @@ public ReceiverAddonAdapter() {
// 初始化内部的插件

register(new ReceiverLoginAddon());
register(new ReceiverPermissionAddon());
register(new ReceiverLimitAddon());
register(new ReceiverMethodAddon());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ReceiverLoginAddon() {

super("ReceiverLogin", new ReceiverAddonType[] { ReceiverAddonType.CLASS_APP, ReceiverAddonType.METHOD_APP });

super.priority = ReceiverAddonPriority.HIGH;
super.priority = ReceiverAddonPriority.HIGHEST;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ public boolean onPreInvokeMethod(MethodAppReceiver methodAppReceiver, WrappedRes

JSONObject json = JSONUtil.parseObj(str);

for ( Class<?> type : methodAppReceiver.getMethod().getParameterTypes() ) {



}

for ( Parameter parameter : methodAppReceiver.getMethod().getParameters() ) {

if( parameter.getType() == WrappedResponse.class ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.talexframe.frame.core.modules.network.connection.app.addon.permission;

import cn.dev33.satoken.stp.StpUtil;
import com.talexframe.frame.core.modules.network.connection.app.ClassAppReceiver;
import com.talexframe.frame.core.modules.network.connection.app.addon.ReceiverAddon;
import com.talexframe.frame.core.modules.network.connection.app.subapp.MethodAppReceiver;
import com.talexframe.frame.core.pojo.wrapper.ResultData;
import com.talexframe.frame.core.pojo.wrapper.WrappedResponse;

/**
* {@link com.talexframe.frame.core.modules.network.connection.app.addon.login Package }
*
* @author TalexDreamSoul 22/06/06 下午 04:47 Project: TalexFrame
*/
public class ReceiverPermissionAddon extends ReceiverAddon {

public ReceiverPermissionAddon() {

super("ReceiverPermission", new ReceiverAddonType[] { ReceiverAddonType.CLASS_APP, ReceiverAddonType.METHOD_APP });

super.priority = ReceiverAddonPriority.HIGH;

}

@Override
public boolean onPreCheckAppReceiver(ClassAppReceiver classAppReceiver, WrappedResponse wr) {

return got(classAppReceiver.getOwnClass().getAnnotation(TReqPermissionChecker.class), wr);

}

@Override
public boolean onPreInvokeMethod(MethodAppReceiver methodAppReceiver, WrappedResponse wr) {

return got(methodAppReceiver.getMethod().getAnnotation(TReqPermissionChecker.class), wr);

}

private boolean got(TReqPermissionChecker reqLoginChecker, WrappedResponse wr) {

// 不存在直接跳过
if( reqLoginChecker == null ) {

return true;

}

// 存在则检查

if( StpUtil.hasPermissionAnd( reqLoginChecker.value() ) ) {

return true;

}

wr.returnDataByFailed( ResultData.ResultEnum.ACCESS_DENIED, "权限不足! ");

return false;

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.talexframe.frame.core.modules.network.connection.app.addon.permission;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* 加了此注解代表需要登录才可以使用相关功能 <br /> {@link com.talexframe.frame.core.modules.network.connection.app.addon.login Package }
*
* @author TalexDreamSoul
* @date 2022/6/6 05:00 <br /> Project: TalexFrame <br />
*/
@Retention( RetentionPolicy.RUNTIME )
@Target( { ElementType.METHOD } )
public @interface TReqPermissionChecker {

/**
* 需要的权限表
*/
String[] value();

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public class PluginInfo {
public enum PluginSupportVersion {

// 7.0.0
SEVEN("7.0.0-core");
SEVEN("7.0.0-core"),
SEVEN_OFFICIAL("7.0.0-core-official");

@Getter
private final String version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ public void onUninstall() {

}

/**
* &#064;Description Please use saveDataToMysql instead
*/
@SneakyThrows
@Deprecated
public void saveDataToMysqlSilence(T data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ public enum ResultEnum {
**/
HOT_PARAM_LIMITED(10002, "hot param limited"),
/**
* 系统规则不满足
* 非法访问
**/
ILLEGAL_ACCESS(10003, "illegal access"),
/**
* 授权规则不通过
**/
ACCESS_DENIED(10004, "access denied"),
/**
* access_denied
* 缺失权限
**/
INSUFFICIENT_PERMISSION(10005, "insufficient permissions"),
/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/talexframe/frame/core/talex/TFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class TFrame {
public static final TFrame tframe = new TFrame();
@Getter
private static final File mainFile = new File(System.getProperty("user.dir"));
private final PluginInfo.PluginSupportVersion versionE = PluginInfo.PluginSupportVersion.SEVEN;
private final PluginInfo.PluginSupportVersion versionE = PluginInfo.PluginSupportVersion.SEVEN_OFFICIAL;
private final String version = "7.0.0";
private final FrameSender frameSender;
@Getter( AccessLevel.PACKAGE )
Expand Down Expand Up @@ -146,7 +146,7 @@ public void started() {
this.pluginManager.loadAllPluginsInFolder();
// ThreadUtil.execAsync(() -> this.pluginManager.loadAllPluginsInFolder());

log.info("框架启动成功!");
log.info("框架启动成功! (" + (System.nanoTime() - TalexFrameApplication.startedTimeStamp) + " ns)");
log.debug("** DEBUG 模式已启动!");

}
Expand Down
113 changes: 0 additions & 113 deletions src/main/java/com/talexframe/frame/utils/ReqMethodUtil.java

This file was deleted.

Loading