Skip to content

Commit

Permalink
fix one can submit request to any project (#166)
Browse files Browse the repository at this point in the history
* update depends for jupyter docker

* fix one can submit request to any project
  • Loading branch information
cyjseagull authored Dec 3, 2024
1 parent 5cb9035 commit f2b54c5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docker-files/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM ubuntu:18.04
RUN apt-get update && apt-get install -y tzdata language-pack-zh* \
&& ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone \
&& locale-gen zh_CN.UTF-8 \
&& apt-get install -y git wget tar unzip lzip vim nasm python3.8 python3-pip python3.8-dev perl graphviz openjdk-8-jdk gcc g++ build-essential m4 tcpdump net-tools gdb \
&& apt-get install -y git wget tar unzip lzip vim nasm python3.8 python3-pip python3.8-dev perl graphviz openjdk-8-jdk gcc g++ build-essential m4 tcpdump net-tools gdb libkrb5-dev krb5-user pkg-config default-libmysqlclient-dev\
&& rm -f /usr/bin/python && ln -s /usr/bin/python3.8 /usr/bin/python \
&& rm -f /usr/bin/python3 && ln -s /usr/bin/python3.8 /usr/bin/python3 \
&& ln -s /usr/bin/pip3 /usr/bin/pip
Expand Down
1 change: 1 addition & 0 deletions docker-files/jupyter/depends/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ traitlets>=4.3.2
jupyter_server>=2.2
pyjwt>=2
tornado>=6.4.2
requests_kerberos>=0.15.0
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@

package com.webank.wedpr.components.project.model;

import com.webank.wedpr.common.utils.Common;
import com.webank.wedpr.common.utils.PageRequest;
import com.webank.wedpr.common.utils.WeDPRException;
import com.webank.wedpr.components.meta.resource.follower.dao.FollowerDO;
import com.webank.wedpr.components.project.dao.JobDO;
import com.webank.wedpr.components.project.dao.ProjectDO;
import com.webank.wedpr.components.project.dao.ProjectMapper;
import java.util.List;
import lombok.SneakyThrows;

Expand All @@ -33,6 +36,23 @@ public JobDO getJob() {
return job;
}

public void check(ProjectMapper projectMapper, String owner, String ownerAgency)
throws Exception {
if (job == null) {
throw new WeDPRException("Must set the job information!");
}
Common.requireNonEmpty("projectId", job.getProjectId());
ProjectDO condition = new ProjectDO(true);
condition.setId(job.getProjectId());
condition.setOwnerAgency(ownerAgency);
condition.setOwner(owner);
List<ProjectDO> result = projectMapper.queryProject(true, condition);
if (result == null || result.isEmpty()) {
throw new WeDPRException(
"Invalid job request, " + owner + " not own project " + job.getProjectId());
}
}

public void setJob(JobDO job) {
if (job == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,11 @@ public void validateUserPermissionToDatasets(
public WeDPRResponse submitJob(String user, JobRequest request) {
WeDPRResponse response =
new WeDPRResponse(Constant.WEDPR_SUCCESS, Constant.WEDPR_SUCCESS_MSG);

// String userName = user;
String agency = WeDPRCommonConfig.getAgency();

List<String> datasetList = request.getDatasetList();
try {
request.check(
projectMapperWrapper.getProjectMapper(), user, WeDPRCommonConfig.getAgency());
List<String> datasetList = request.getDatasetList();
request.getJob().setOwner(user);
request.getJob().setOwnerAgency(agency);
request.getJob().setTaskParties(request.getTaskParties());
Expand Down

0 comments on commit f2b54c5

Please sign in to comment.