提交 9f7879f2 编写于 作者: Cano1997's avatar Cano1997

fix: 文件下载越权漏洞修复

上级 c65dc5f0
...@@ -47,19 +47,20 @@ ...@@ -47,19 +47,20 @@
</ul> </ul>
</modal> </modal>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Vue, Prop, Watch } from 'vue-property-decorator'; import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import { Environment } from '@/environments/environment'; import { Environment } from '@/environments/environment';
import { CreateElement } from 'vue'; import { CreateElement } from 'vue';
import { Subject, Unsubscribable } from 'rxjs'; import { Subject, Unsubscribable } from 'rxjs';
import Axios from 'axios'; import Axios from 'axios';
import { Message } from 'element-ui'; import { Message } from 'element-ui';
import EntityService from '@/service/entity-service';
@Component({ @Component({
}) })
export default class AppFileUpload extends Vue { export default class AppFileUpload extends Vue {
/** /**
* 表单状态 * 表单状态
...@@ -175,6 +176,22 @@ ...@@ -175,6 +176,22 @@
*/ */
@Prop() public exportparams?: any; @Prop() public exportparams?: any;
/**
* 实体服务
*
* @type {EntityService}
* @memberof AppFileUpload
*/
@Prop() public appEntityService!: EntityService;
/**
* 默认为当前实体主键id,有指定则按表单参数
*
* @type {string}
* @memberof AppFileUpload
*/
@Prop() public ownerid!: string;
/** /**
* 文件列表 * 文件列表
* *
...@@ -470,7 +487,10 @@ ...@@ -470,7 +487,10 @@
let _this: any = this; let _this: any = this;
const id = typeof file.id == "string" ? file.id : JSON.stringify(file.id); const id = typeof file.id == "string" ? file.id : JSON.stringify(file.id);
const name = typeof file.name == "string" ? file.name : JSON.stringify(file.filename); const name = typeof file.name == "string" ? file.name : JSON.stringify(file.filename);
const downloadUrl = `${(window as any).Environment.ExportFile}`+ '/' + id + '/' + name; // const downloadUrl = '/ibizutilrpm/download/' + this.getFolder() + '/' + id + '/' + encodeURIComponent(name);
const entityName = this.appEntityService.APPDENAME;
const base64 = `${id}|${entityName}|${this.ownerid}|${this.context.srfpersonid || this.context.srfuserid}`;
const downloadUrl =`http://downloadpath?key=${window.btoa(base64)}`
// 发送get请求 // 发送get请求
Axios.get(downloadUrl, { Axios.get(downloadUrl, {
responseType: 'arraybuffer', responseType: 'arraybuffer',
...@@ -546,9 +566,9 @@ ...@@ -546,9 +566,9 @@
public showActions: boolean = false; public showActions: boolean = false;
} }
</script> </script>
<style lang='less'> <style lang='less'>
@import './app-file-upload.less'; @import './app-file-upload.less';
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -9,6 +9,7 @@ import { Component, Vue, Prop, Watch } from 'vue-property-decorator'; ...@@ -9,6 +9,7 @@ import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import { Environment } from '@/environments/environment'; import { Environment } from '@/environments/environment';
import { CreateElement } from 'vue'; import { CreateElement } from 'vue';
import { Subject, Unsubscribable } from 'rxjs'; import { Subject, Unsubscribable } from 'rxjs';
import EntityService from '@/service/entity-service';
@Component({ @Component({
}) })
...@@ -42,6 +43,30 @@ export default class AppUploadFileInfo extends Vue { ...@@ -42,6 +43,30 @@ export default class AppUploadFileInfo extends Vue {
*/ */
@Prop() public name!: string; @Prop() public name!: string;
/**
* 应用上下文
*
* @type {*}
* @memberof AppUploadFileInfo
*/
@Prop() public context!: any;
/**
* 实体服务
*
* @type {EntityService}
* @memberof AppUploadFileInfo
*/
@Prop() public appEntityService!: EntityService;
/**
* 默认为当前实体主键id,有指定则按表单参数
*
* @type {string}
* @memberof AppUploadFileInfo
*/
@Prop() public ownerid!: string;
/** /**
* 上传文件路径 * 上传文件路径
* *
...@@ -74,8 +99,11 @@ export default class AppUploadFileInfo extends Vue { ...@@ -74,8 +99,11 @@ export default class AppUploadFileInfo extends Vue {
let files = JSON.parse(this.value); let files = JSON.parse(this.value);
if(files.length){ if(files.length){
files.forEach((file: any) => { files.forEach((file: any) => {
let url = `${this.downloadUrl}/${file.id}`; // let url = `${this.downloadUrl}/${file.id}`;
file.url = url; const entityName = this.appEntityService.APPDENAME;
const base64 = `${file.id}|${entityName}|${this.ownerid}|${this.context.srfpersonid || this.context.srfuserid}`;
const downloadUrl =`http://downloadpath?key=${window.btoa(base64)}`
file.url = downloadUrl;
}); });
}else{ }else{
files = [] files = []
......
...@@ -71,6 +71,7 @@ import Axios from 'axios'; ...@@ -71,6 +71,7 @@ import Axios from 'axios';
import { Unsubscribable } from 'rxjs'; import { Unsubscribable } from 'rxjs';
import { Environment } from '@/environments/environment'; import { Environment } from '@/environments/environment';
import { encode } from "js-base64"; import { encode } from "js-base64";
import EntityService from '@/service/entity-service';
@Component({}) @Component({})
export default class DiskFileUpload extends Vue { export default class DiskFileUpload extends Vue {
...@@ -195,6 +196,22 @@ export default class DiskFileUpload extends Vue { ...@@ -195,6 +196,22 @@ export default class DiskFileUpload extends Vue {
*/ */
@Prop({ default: false }) public showOcrview?: boolean; @Prop({ default: false }) public showOcrview?: boolean;
/**
* 实体服务
*
* @type {EntityService}
* @memberof DiskFileUpload
*/
@Prop() public appEntityService!: EntityService;
/**
* 应用上下文
*
* @type {*}
* @memberof DiskFileUpload
*/
@Prop() public context!: any;
/** /**
* 表单是否处于编辑状态(有真实主键,srfuf='1';srfuf='0'时处于新建未保存) * 表单是否处于编辑状态(有真实主键,srfuf='1';srfuf='0'时处于新建未保存)
* *
...@@ -519,7 +536,10 @@ export default class DiskFileUpload extends Vue { ...@@ -519,7 +536,10 @@ export default class DiskFileUpload extends Vue {
let _this: any = this; let _this: any = this;
const id = typeof item.id == "string" ? item.id : JSON.stringify(item.id); const id = typeof item.id == "string" ? item.id : JSON.stringify(item.id);
const name = typeof item.name == "string" ? item.name : JSON.stringify(item.filename); const name = typeof item.name == "string" ? item.name : JSON.stringify(item.filename);
const downloadUrl = '/ibizutilrpm/download/' + this.getFolder() + '/' + id + '/' + encodeURIComponent(name); // const downloadUrl = '/ibizutilrpm/download/' + this.getFolder() + '/' + id + '/' + encodeURIComponent(name);
const entityName = this.appEntityService.APPDENAME;
const base64 = `${id}|${entityName}|${this.getOwnerid()}|${this.context.srfpersonid || this.context.srfuserid}`;
const downloadUrl =`http://downloadpath?key=${window.btoa(base64)}`
// 发送get请求 // 发送get请求
Axios.get(downloadUrl, { Axios.get(downloadUrl, {
headers: { headers: {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册