Skip to content
Snippets Groups Projects
Verified Commit 43e39f98 authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Disable features for unauthorized user

#33
parent e1423291
No related branches found
No related tags found
2 merge requests!84Remove development branch,!28Resolve "Disable feature for foreign users"
Pipeline #26724 passed
...@@ -19,6 +19,7 @@ const props = defineProps<{ ...@@ -19,6 +19,7 @@ const props = defineProps<{
active: boolean; active: boolean;
bucket: BucketOut; bucket: BucketOut;
loading: boolean; loading: boolean;
deletable: boolean;
}>(); }>();
const randomIDSuffix = Math.random().toString(16).substr(2, 8); const randomIDSuffix = Math.random().toString(16).substr(2, 8);
...@@ -88,7 +89,7 @@ onMounted(() => { ...@@ -88,7 +89,7 @@ onMounted(() => {
<span class="text-truncate" style="width: 80%">{{ bucket.name }}</span> <span class="text-truncate" style="width: 80%">{{ bucket.name }}</span>
<div> <div>
<bootstrap-icon <bootstrap-icon
v-if="props.active && permission == null" v-if="props.active && permission == null && props.deletable"
icon="trash-fill" icon="trash-fill"
class="delete-icon me-2" class="delete-icon me-2"
:width="16" :width="16"
......
...@@ -636,6 +636,7 @@ watch( ...@@ -636,6 +636,7 @@ watch(
/> />
<!-- Add bucket permission button --> <!-- Add bucket permission button -->
<button <button
v-if="!authStore.foreignUser"
:hidden="bucketRepository.getBucketPermission(props.bucketName) != null" :hidden="bucketRepository.getBucketPermission(props.bucketName) != null"
type="button" type="button"
class="btn btn-secondary m-2 tooltip-container" class="btn btn-secondary m-2 tooltip-container"
...@@ -653,6 +654,7 @@ watch( ...@@ -653,6 +654,7 @@ watch(
<span class="visually-hidden">Add Bucket Permission</span> <span class="visually-hidden">Add Bucket Permission</span>
</button> </button>
<permission-modal <permission-modal
v-if="!authStore.foreignUser"
modalID="create-permission-modal" modalID="create-permission-modal"
:bucket-name="props.bucketName" :bucket-name="props.bucketName"
:sub-folders="folderStructure" :sub-folders="folderStructure"
...@@ -666,6 +668,7 @@ watch( ...@@ -666,6 +668,7 @@ watch(
" "
/> />
<button <button
v-if="!authStore.foreignUser"
:hidden="bucketRepository.getBucketPermission(props.bucketName) != null" :hidden="bucketRepository.getBucketPermission(props.bucketName) != null"
type="button" type="button"
class="btn btn-secondary m-2 tooltip-container" class="btn btn-secondary m-2 tooltip-container"
...@@ -683,7 +686,10 @@ watch( ...@@ -683,7 +686,10 @@ watch(
<span class="visually-hidden">View Bucket Permissions</span> <span class="visually-hidden">View Bucket Permissions</span>
</button> </button>
<permission-list-modal <permission-list-modal
v-if="bucketRepository.getBucketPermission(props.bucketName) == null" v-if="
bucketRepository.getBucketPermission(props.bucketName) == null &&
!authStore.foreignUser
"
:bucket-name="props.bucketName" :bucket-name="props.bucketName"
:sub-folders="folderStructure" :sub-folders="folderStructure"
modalID="permission-list-modal" modalID="permission-list-modal"
......
...@@ -69,7 +69,7 @@ onBeforeUnmount(() => { ...@@ -69,7 +69,7 @@ onBeforeUnmount(() => {
height="24" height="24"
class="d-inline-block align-text-top me-2" class="d-inline-block align-text-top me-2"
/> />
S3 Proxy CloWM
</router-link> </router-link>
<button <button
class="navbar-toggler" class="navbar-toggler"
......
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import type { User } from "@/client/auth"; import type { User } from "@/client/auth";
import { UserService } from "@/client/auth"; import { UserService, RoleEnum } from "@/client/auth";
import { S3KeyService } from "@/client/s3proxy"; import { S3KeyService } from "@/client/s3proxy";
import type { S3Key } from "@/client/s3proxy"; import type { S3Key } from "@/client/s3proxy";
import { OpenAPI as S3ProxyOpenAPI } from "@/client/s3proxy"; import { OpenAPI as S3ProxyOpenAPI } from "@/client/s3proxy";
...@@ -23,6 +23,15 @@ export const useAuthStore = defineStore({ ...@@ -23,6 +23,15 @@ export const useAuthStore = defineStore({
} as RootState), } as RootState),
getters: { getters: {
authenticated: (state) => state.token != null, authenticated: (state) => state.token != null,
foreignUser: (state) =>
state.user?.roles?.includes(RoleEnum.FOREIGN_USER) ?? true,
normalUser: (state) => state.user?.roles?.includes(RoleEnum.USER) ?? false,
workflowReviewer: (state) =>
state.user?.roles?.includes(RoleEnum.REVIEWER) ?? false,
workflowDev: (state) =>
state.user?.roles?.includes(RoleEnum.DEVELOPER) ?? false,
workflowAdmin: (state) =>
state.user?.roles?.includes(RoleEnum.ADMINISTRATOR) ?? false,
}, },
actions: { actions: {
setToken(token: string | null) { setToken(token: string | null) {
......
...@@ -52,7 +52,7 @@ export const useBucketStore = defineStore({ ...@@ -52,7 +52,7 @@ export const useBucketStore = defineStore({
onFinally: (() => void) | null | undefined = null onFinally: (() => void) | null | undefined = null
) { ) {
const authStore = useAuthStore(); const authStore = useAuthStore();
if (authStore.user != null) { if (authStore.user != null && !authStore.foreignUser) {
BucketPermissionService.bucketPermissionListPermissionsPerUser( BucketPermissionService.bucketPermissionListPermissionsPerUser(
authStore.user.uid authStore.user.uid
) )
...@@ -80,7 +80,8 @@ export const useBucketStore = defineStore({ ...@@ -80,7 +80,8 @@ export const useBucketStore = defineStore({
onRejected: ((reason: any) => void) | null | undefined = null, onRejected: ((reason: any) => void) | null | undefined = null,
onFinally: (() => void) | null | undefined = null onFinally: (() => void) | null | undefined = null
) { ) {
BucketService.bucketListBuckets() const authStore = useAuthStore();
BucketService.bucketListBuckets(authStore.user?.uid)
.then((buckets) => { .then((buckets) => {
this.buckets = buckets; this.buckets = buckets;
onFulfilled?.(buckets); onFulfilled?.(buckets);
......
...@@ -60,7 +60,7 @@ onMounted(() => { ...@@ -60,7 +60,7 @@ onMounted(() => {
<div <div
class="card text-center bg-dark ms-md-auto position-fixed top-50 start-50 translate-middle" class="card text-center bg-dark ms-md-auto position-fixed top-50 start-50 translate-middle"
> >
<div class="card-header text-dark bg-light">S3Proxy</div> <div class="card-header text-dark bg-light">CloWM</div>
<div class="card-body p-5"> <div class="card-body p-5">
<h5 class="card-title text-light">Login</h5> <h5 class="card-title text-light">Login</h5>
<p class="card-text text-secondary"> <p class="card-text text-secondary">
......
...@@ -9,10 +9,12 @@ import DeleteModal from "@/components/Modals/DeleteModal.vue"; ...@@ -9,10 +9,12 @@ import DeleteModal from "@/components/Modals/DeleteModal.vue";
import BucketListItem from "@/components/BucketListItem.vue"; import BucketListItem from "@/components/BucketListItem.vue";
import { useBucketStore } from "@/stores/buckets"; import { useBucketStore } from "@/stores/buckets";
import { Modal } from "bootstrap"; import { Modal } from "bootstrap";
import { useAuthStore } from "@/stores/auth";
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const bucketRepository = useBucketStore(); const bucketRepository = useBucketStore();
const authStore = useAuthStore();
const bucketsState = reactive({ const bucketsState = reactive({
filterString: "", filterString: "",
...@@ -58,6 +60,7 @@ onMounted(() => { ...@@ -58,6 +60,7 @@ onMounted(() => {
<template> <template>
<DeleteModal <DeleteModal
v-if="!authStore.foreignUser"
modalID="delete-bucket-modal" modalID="delete-bucket-modal"
:object-name-delete="bucketsState.potentialDeleteBucketName" :object-name-delete="bucketsState.potentialDeleteBucketName"
:back-modal-id="undefined" :back-modal-id="undefined"
...@@ -65,7 +68,10 @@ onMounted(() => { ...@@ -65,7 +68,10 @@ onMounted(() => {
confirmedDeleteBucket(bucketsState.potentialDeleteBucketName) confirmedDeleteBucket(bucketsState.potentialDeleteBucketName)
" "
/> />
<CreateBucketModal modalID="create-bucket-modal" /> <CreateBucketModal
modalID="create-bucket-modal"
v-if="!authStore.foreignUser"
/>
<div class="row m-2 border-bottom border-light mt-4"> <div class="row m-2 border-bottom border-light mt-4">
<div class="col-12"></div> <div class="col-12"></div>
<h1 class="mb-2 text-light">Buckets</h1> <h1 class="mb-2 text-light">Buckets</h1>
...@@ -82,6 +88,7 @@ onMounted(() => { ...@@ -82,6 +88,7 @@ onMounted(() => {
<span class="visually-hidden">Refresh Buckets</span> <span class="visually-hidden">Refresh Buckets</span>
</button> </button>
<button <button
v-if="!authStore.foreignUser"
type="button" type="button"
class="btn btn-light" class="btn btn-light"
data-bs-toggle="modal" data-bs-toggle="modal"
...@@ -115,6 +122,7 @@ onMounted(() => { ...@@ -115,6 +122,7 @@ onMounted(() => {
route.params.bucketName != null && route.params.bucketName != null &&
route.params.bucketName === bucket.name route.params.bucketName === bucket.name
" "
:deletable="!authStore.foreignUser"
:bucket="bucket" :bucket="bucket"
:loading="false" :loading="false"
@delete-bucket="deleteBucket" @delete-bucket="deleteBucket"
...@@ -140,6 +148,7 @@ onMounted(() => { ...@@ -140,6 +148,7 @@ onMounted(() => {
:active="false" :active="false"
:loading="true" :loading="true"
:permission="undefined" :permission="undefined"
:deletable="!authStore.foreignUser"
:bucket="{ :bucket="{
name: '', name: '',
description: '', description: '',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment