...
 
Commits (7)
    https://gitcode.net/u011197448/oneblog/-/commit/e165c0195b9b3813dc97300c24552b1569550527 修改 nginx 的配置文件 2021-06-21T18:54:16+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/f354ab37eef18f3e215142d0ea27907c1ae9e1f8 Signed-off-by: 国产大熊猫 <9199771@qq.com> 2021-07-20T13:13:24+08:00 国产大熊猫 9199771@qq.com https://gitcode.net/u011197448/oneblog/-/commit/10a88d6cbfbca352fb2c46b115650a9be9101ec6 !28 shiro反序列化安全过滤 2021-07-20T05:27:29+00:00 yadong.zhang yadong.zhang0415@gmail.com Merge pull request !28 from 国产大熊猫/master https://gitcode.net/u011197448/oneblog/-/commit/8cf948c40abc99b8558d6f16330db7a3306d0e52 Signed-off-by: 国产大熊猫 <9199771@qq.com> 2021-07-20T14:02:35+08:00 国产大熊猫 9199771@qq.com https://gitcode.net/u011197448/oneblog/-/commit/818e983a40edda5c0976a53f9bb59a801350eb2c !29 增加一句注释 2021-07-20T06:06:58+00:00 yadong.zhang yadong.zhang0415@gmail.com Merge pull request !29 from 国产大熊猫/master https://gitcode.net/u011197448/oneblog/-/commit/91d74d9283426b2d8f24c7948c0f5ee88251e01e 解决 treetable 中操作按钮被隐藏的问题 2021-08-01T16:48:10+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/u011197448/oneblog/-/commit/1b2bd1a271656e59d370289d6597baf2c8919087 Merge branch 'master' of gitee.com:yadong.zhang/DBlog 2021-08-01T16:48:38+08:00 yadong.zhang yadong.zhang0415@gmail.com
package com.zyd.blog.core.config;
import org.apache.shiro.util.ClassUtils;
import org.apache.shiro.util.UnknownClassException;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
public class MyClassResolvingObjectInputStream extends ObjectInputStream {
public MyClassResolvingObjectInputStream(InputStream inputStream) throws IOException {
super(inputStream);
}
protected Class<?> resolveClass(ObjectStreamClass osc) throws IOException, ClassNotFoundException {
try {
String s = osc.getName();
// 干掉常见的gadget,为了避免 [ ; 符号,必须使用contains方法
// 简单的使用 s.equals 可能导致fastjson 以前出现的黑名单逃逸问题
if (s.contains("java.util.PriorityQueue") || s.contains("xsltc.trax.TemplatesImpl")) {
throw new ClassNotFoundException("Unable to load Dangerous ObjectStreamClass [" + osc + "]");
}
if (s.contains("org.apache.")) {
// 直接干掉了 org.apache ,但是要保留shiro自己
if (s.startsWith("org.apache.shiro.subject.")) {
return ClassUtils.forName(s);
}
throw new ClassNotFoundException("Unable to load Dangerous ObjectStreamClass [" + osc + "]");
}
// 使用白名单保证业务的正常开展
if (s.startsWith("java.lang") || s.startsWith("java.util")) {
return ClassUtils.forName(s);
} else {
throw new ClassNotFoundException("Unable to load Dangerous ObjectStreamClass [" + osc + "]");
}
} catch (UnknownClassException var3) {
throw new ClassNotFoundException("Unable to load ObjectStreamClass [" + osc + "]: ", var3);
}
}
}
\ No newline at end of file
package com.zyd.blog.core.config;
import org.apache.shiro.io.SerializationException;
import org.apache.shiro.io.Serializer;
import java.io.*;
public class MySecSerializer<T> implements Serializer<T> {
public MySecSerializer() {
}
public byte[] serialize(T o) throws SerializationException {
if (o == null) {
String msg = "argument cannot be null.";
throw new IllegalArgumentException(msg);
} else {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(baos);
try {
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(o);
oos.close();
return baos.toByteArray();
} catch (IOException var6) {
String msg = "Unable to serialize object [" + o + "]. In order for the DefaultSerializer to serialize this object, the [" + o.getClass().getName() + "] class must implement java.io.Serializable.";
throw new SerializationException(msg, var6);
}
}
}
public T deserialize(byte[] serialized) throws SerializationException {
if (serialized == null) {
String msg = "argument cannot be null.";
throw new IllegalArgumentException(msg);
} else {
ByteArrayInputStream bais = new ByteArrayInputStream(serialized);
BufferedInputStream bis = new BufferedInputStream(bais);
try {
ObjectInputStream ois = new MyClassResolvingObjectInputStream(bis);
T deserialized = (T) ois.readObject();
ois.close();
return deserialized;
} catch (Exception var6) {
String msg = "Unable to deserialize argument byte array.";
throw new SerializationException(msg, var6);
}
}
}
}
......@@ -225,8 +225,10 @@ public class ShiroConfig {
*/
public CookieRememberMeManager rememberMeManager() {
CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
// 使用自定义的序列化类
cookieRememberMeManager.setSerializer(new MySecSerializer<>());
cookieRememberMeManager.setCookie(rememberMeCookie());
//rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位)
//rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 192 256 位)
cookieRememberMeManager.setCipherKey(GenerateCipherKey.generateNewKey());
return cookieRememberMeManager;
}
......@@ -251,8 +253,8 @@ public class ShiroConfig {
String msg = "Unable to acquire AES algorithm. This is required to function.";
throw new IllegalStateException(msg, var5);
}
kg.init(128);
// 满足合规应使用256位
kg.init(256);
SecretKey key = kg.generateKey();
return key.getEncoded();
}
......
......@@ -18,7 +18,7 @@ $.extend({
toobarTemplate: '<div id="tree-table-toolbar" class="btn-group" role="group" aria-label="..."><button id="add-btn" type="button" class="btn btn-info" title="新增"><i class="fa fa-plus fa-fw"> </i> </button><button id="batch-delete-btn" type="button" class="btn btn-danger" title="批量删除"><i class="fa fa-trash-o fa-fw"> </i> </button></div>',
oprater: {
title: '操作',
width: '100px',
width: '130px',
align: "center",
formatter: function (value, row, index) {
var curId = row.id;
......@@ -168,4 +168,4 @@ $.extend({
}
}
});
\ No newline at end of file
});
......@@ -114,7 +114,7 @@
}, {
field: '-',
title: '层级',
width: "60px",
width: "90px",
align: "center"
}, {
field: 'name',
......@@ -132,6 +132,7 @@
}, {
field: 'type',
title: '资源类型',
width: '100px',
formatter: function (code) {
return code == 'menu' ? '菜单' : '按钮';
}
......@@ -196,4 +197,4 @@
})
});
</script>
</@footer>
\ No newline at end of file
</@footer>
server {
listen 80;
server_name 改成自己的域名;
root 改成自己的文件目录;;
root 改成自己的文件目录;
location ^~ / {
try_files $uri $uri/ /index.html;
proxy_set_header Cookie $http_cookie;
proxy_set_header Cookie $http_cookie;
proxy_set_header Host $host:$server_port;
}
}