This is an automated email from the ASF dual-hosted git repository. ofuks pushed a commit to branch bucket-browser-gcp in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit 894465b7f9f87fd435fbb70d39340470f444afc5 Author: Oleh Fuks <olegfuk...@gmail.com> AuthorDate: Tue Apr 28 15:51:49 2020 +0300 Added permission for bucket browser --- .../backendapi/resources/dto/HealthStatusPageDTO.java | 11 +++++++++++ .../service/impl/InfrastructureInfoServiceImpl.java | 18 ++++++++++++++++-- .../src/main/resources/mongo/aws/mongo_roles.json | 1 + .../src/main/resources/mongo/azure/mongo_roles.json | 1 + 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/HealthStatusPageDTO.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/HealthStatusPageDTO.java index 17e7b91..4eb0b3b 100644 --- a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/HealthStatusPageDTO.java +++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/HealthStatusPageDTO.java @@ -47,4 +47,15 @@ public class HealthStatusPageDTO { private int billingUserQuoteUsed; @JsonProperty private boolean projectAssigned; + @JsonProperty + private BucketBrowser bucketBrowser; + + @Builder + @Data + public static class BucketBrowser { + private final boolean view; + private final boolean upload; + private final boolean download; + private final boolean delete; + } } \ No newline at end of file diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceImpl.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceImpl.java index b1eac51..4063ca1 100644 --- a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceImpl.java +++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/InfrastructureInfoServiceImpl.java @@ -29,6 +29,7 @@ import com.epam.dlab.backendapi.domain.ProjectEndpointDTO; import com.epam.dlab.backendapi.resources.dto.HealthStatusEnum; import com.epam.dlab.backendapi.resources.dto.HealthStatusPageDTO; import com.epam.dlab.backendapi.resources.dto.ProjectInfrastructureInfo; +import com.epam.dlab.backendapi.roles.RoleType; import com.epam.dlab.backendapi.roles.UserRoles; import com.epam.dlab.backendapi.service.BillingService; import com.epam.dlab.backendapi.service.EndpointService; @@ -55,9 +56,12 @@ import java.util.stream.StreamSupport; @Slf4j public class InfrastructureInfoServiceImpl implements InfrastructureInfoService { + private static final String RELEASE_NOTES_FORMAT = "https://github.com/apache/incubator-dlab/blob/%s/RELEASE_NOTES.md"; + private static final String PERMISSION_VIEW = "/api/bucket/view"; + private static final String PERMISSION_UPLOAD = "/api/bucket/upload"; + private static final String PERMISSION_DOWNLOAD = "/api/bucket/download"; + private static final String PERMISSION_DELETE = "/api/bucket/delete"; - private static final String RELEASE_NOTES_FORMAT = "https://github.com/apache/incubator-dlab/blob/%s" + - "/RELEASE_NOTES.md"; private final ExploratoryDAO expDAO; private final SelfServiceApplicationConfiguration configuration; private final BillingDAO billingDAO; @@ -134,6 +138,12 @@ public class InfrastructureInfoServiceImpl implements InfrastructureInfoService .projectAssigned(projectService.isAnyProjectAssigned(userInfo)) .billingQuoteUsed(billingDAO.getBillingQuoteUsed()) .billingUserQuoteUsed(billingDAO.getBillingUserQuoteUsed(user)) + .bucketBrowser(HealthStatusPageDTO.BucketBrowser.builder() + .view(checkAccess(userInfo, PERMISSION_VIEW)) + .upload(checkAccess(userInfo, PERMISSION_UPLOAD)) + .download(checkAccess(userInfo, PERMISSION_DOWNLOAD)) + .delete(checkAccess(userInfo, PERMISSION_DELETE)) + .build()) .build(); } catch (Exception e) { log.warn("Could not return status of resources for user {}: {}", user, e.getLocalizedMessage(), e); @@ -183,4 +193,8 @@ public class InfrastructureInfoServiceImpl implements InfrastructureInfoService return shared; } + + private boolean checkAccess(UserInfo userInfo, String permission) { + return UserRoles.checkAccess(userInfo, RoleType.PAGE, permission, userInfo.getRoles()); + } } diff --git a/services/self-service/src/main/resources/mongo/aws/mongo_roles.json b/services/self-service/src/main/resources/mongo/aws/mongo_roles.json index 942f281..ee7d97e 100644 --- a/services/self-service/src/main/resources/mongo/aws/mongo_roles.json +++ b/services/self-service/src/main/resources/mongo/aws/mongo_roles.json @@ -402,6 +402,7 @@ "/api/settings", "/user/settings", "/api/project", + "/api/project/create", "/api/endpoint" ], "groups": [ diff --git a/services/self-service/src/main/resources/mongo/azure/mongo_roles.json b/services/self-service/src/main/resources/mongo/azure/mongo_roles.json index f05f3d1..1cd44b1 100644 --- a/services/self-service/src/main/resources/mongo/azure/mongo_roles.json +++ b/services/self-service/src/main/resources/mongo/azure/mongo_roles.json @@ -342,6 +342,7 @@ "/api/settings", "/user/settings", "/api/project", + "/api/project/create", "/api/endpoint" ], "groups": [ --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org For additional commands, e-mail: commits-h...@dlab.apache.org