main
黄海 11 months ago
parent ff6051896f
commit 81d0f7598f

@ -1,62 +0,0 @@
package com.dsideal.base.Handler;
import com.dsideal.base.Util.SsoUtil;
import com.jfinal.handler.Handler;
import com.jfinal.kit.PropKit;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import static com.jfinal.kit.HandlerKit.redirect;
/**
* sso使,cookie
*
* @author
*/
@SuppressWarnings("unchecked")
public class SsoHandler extends Handler {
@Override
public void handle(String target, HttpServletRequest req,
HttpServletResponse res, boolean[] isHandled) {
String servletPath = req.getServletPath();
//根据IP获取是走内网还是走外网
String ssoServerUrl = PropKit.get("SSO_SERVER_NW");
String serverIp = req.getServerName();
String IntranetIP = PropKit.get("IntranetIP");
String firstPart = serverIp.split("\\.")[0];
if (IntranetIP.indexOf(firstPart) == -1) {
ssoServerUrl = PropKit.get("SSO_SERVER_WW");
}
String link = req.getRequestURL().toString();
String cookieSessionId = SsoUtil.getSessionIdByCookie(req, PropKit.get("SSO_SESSIONID"));
if (cookieSessionId == null) {
String paramSessionId = req.getParameter(PropKit.get("SSO_SESSIONID"));
if (paramSessionId != null) {
Map loginMap = SsoUtil.loginCheck(paramSessionId, ssoServerUrl);
loginMap.put("person_id", loginMap.get("person_id").toString());
loginMap.put("identity_id", loginMap.get("identity_id").toString());
loginMap.put(PropKit.get("SSO_SESSIONID"), paramSessionId);
SsoUtil.setCookieMap(res, loginMap);
} else {
String loginPageUrl = ssoServerUrl.concat("/login?redirect_url=" + link);
redirect(loginPageUrl, req, res, isHandled);
}
} else {
Map loginMap = SsoUtil.loginCheck(cookieSessionId, ssoServerUrl);
loginMap.put("person_id", loginMap.get("person_id").toString());
loginMap.put("identity_id", loginMap.get("identity_id").toString());
loginMap.put(PropKit.get("SSO_SESSIONID"), cookieSessionId);
SsoUtil.setCookieMap(res, loginMap);
}
next.handle(target, req, res, isHandled);
}
}

@ -0,0 +1,79 @@
package com.dsideal.base.Util;
import cn.hutool.core.io.FileUtil;
import com.jfinal.kit.PathKit;
import com.jfinal.kit.PropKit;
import io.minio.MinioClient;
import io.minio.SetBucketPolicyArgs;
import io.minio.UploadObjectArgs;
import io.minio.errors.*;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class MinioUtils {
/**
* Minio
*
* @return
*/
public static MinioClient getMinioClient() {
// //配置文件
// String configFile = "application_dev.properties";
// String myEnvVar = System.getenv("WORKING_ENV");
// if (myEnvVar != null) {
// configFile = configFile.replace("_dev", "_pro");
// System.out.println("环境变量 WORKING_ENV 的值是: " + myEnvVar);
// } else {
// System.out.println("环境变量 WORKING_ENV 未设置。");
// }
// PropKit.use(configFile);
String minio_endpoint = PropKit.get("minio_endpoint");
String minio_accesskey = PropKit.get("minio_accesskey");
String minio_secretkey = PropKit.get("minio_secretkey");
return MinioClient.builder()
.endpoint(minio_endpoint)
.credentials(minio_accesskey, minio_secretkey)
.build();
}
/**
*
*
* @param minioClient
* @param key
* @param source
* @throws IOException
* @throws ServerException
* @throws InsufficientDataException
* @throws ErrorResponseException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws InvalidResponseException
* @throws XmlParserException
* @throws InternalException
*/
public static void uploadFile(MinioClient minioClient, String key, String source) throws IOException, ServerException, InsufficientDataException, ErrorResponseException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
minioClient.uploadObject(
UploadObjectArgs.builder()
.bucket(PropKit.get("minio_bucketName"))
.object(key)
.filename(source)
.build());
}
public static void main(String[] args) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
String policy = FileUtil.readUtf8String(PathKit.getRootClassPath() + "/SetMinioDownload.json");
MinioClient client = getMinioClient();
SetBucketPolicyArgs setBucketPolicyArgs = SetBucketPolicyArgs.builder()
.bucket(PropKit.get("minio_bucketName"))
.config(policy)
.build();
client.setBucketPolicy(setBucketPolicyArgs);
System.out.println("完成全局权限设置!");
//测试样例
//http://10.10.14.212:9000/dsideal/%E5%AE%89%E5%90%89%E4%B8%BD%E5%A8%9C%E6%9C%B1%E8%8E%89.jpg
}
}

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -1,9 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PyListCreationInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PyPep8NamingInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PyProtectedMemberInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
</profile>
</component>

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ExcelImportTemplate.iml" filepath="$PROJECT_DIR$/.idea/ExcelImportTemplate.iml" />
</modules>
</component>
</project>

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" />
</component>
</project>

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c9117f15-5ada-42d4-a094-bacc4da713a5" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../../../.." />
</component>
<component name="ProjectId" id="29h7HfV4pVPLtlgAYRGTuSeM70z" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"last_opened_file_path": "D:/dsWork/baseServiceJava/src/main/resource/Py"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="c9117f15-5ada-42d4-a094-bacc4da713a5" name="Changes" comment="" />
<created>1653553376213</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1653553376213</updated>
<workItem from="1653553377383" duration="14000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>

@ -14,8 +14,6 @@ CookieMd5SingPwd=DsideaL4r5t6y7u
excelExportTemplatePathSuffix=/ExcelExportTemplate/
# 导入excel 的模板配置路径
ExcelImportTemplatePathSuffix=/ExcelImportTemplate/
# sso的cookie名称
SSO_SESSIONID=ds_sso_sessionid
#mongodb
mongodbUri=mongodb://yltcharge:yltcharge@10.10.14.210:27017/yltcharge

@ -0,0 +1,35 @@
#### 摘取镜像
```shell
docker pull minio/minio
```
#### 启动实例
```shell
mkdir -p /opt/minio/{data,.minio}
docker run --name minio -d -p 9000:9000 -p 9090:9090 -v /opt/minio/data:/data -v /opt/minio/.minio:/root/.minio minio/minio server /data --console-address ":9090" --address ":9000"
```
#### 访问办法
通过浏览器访问`http://10.10.14.212:9090/login`即可访问MinIO的Web管理界面
默认凭证
```
minioadmin
minioadmin
```
#### 匿名访问
进入桶管理配置匿名访问规则。Prefix输入 /Access选择 readonly。保存后再次访问`http://10.10.14.212:9090/dsideal/安吉丽娜朱莉.jpg`可以看到图片了。
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202409050828779.png)
Loading…
Cancel
Save