Skip to content

Commit

Permalink
Merge pull request #73 from dinukadesilva/gh-72-enable-secret-management
Browse files Browse the repository at this point in the history
gh-72: Enable SSH secret management
  • Loading branch information
isururanawaka authored Jun 20, 2021
2 parents b1fa661 + 64c9926 commit d8cf439
Show file tree
Hide file tree
Showing 19 changed files with 303 additions and 59 deletions.
10 changes: 9 additions & 1 deletion custos-demo-gateway/src/components/Breadcrumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<b-breadcrumb style="background: none;padding: 0px 0px;">
<router-link v-for="(link, index) in links" :key="index" :to="link.to"
v-slot="{ href, route, navigate, isActive,isExactActive }" tag="">
<b-breadcrumb-item :href="href" :active="isExactActive" @click="navigate">{{ link.name }}</b-breadcrumb-item>
<b-breadcrumb-item :disabled="link.disabled === true" :href="href" :active="isExactActive" @click="navigate">
{{ link.name }}
</b-breadcrumb-item>
</router-link>
</b-breadcrumb>
</template>
Expand All @@ -23,4 +25,10 @@ export default {
ol {
margin: 0px;
}
a.disabled, a.disabled:hover {
text-decoration: line-through;
color: #6c757d;
cursor: initial;
}
</style>
13 changes: 9 additions & 4 deletions custos-demo-gateway/src/components/admin-portal/NewTenant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</p>
<br/>
<router-link :to="`/tenants/${clientId}/child-tenants`" v-slot="{ href, route, navigate}" tag="">
<b-button variant="secondary" @click="navigate">Back to Clients</b-button>
<b-button variant="secondary" @click="navigate">Back to Tenants</b-button>
</router-link>
</div>
<div v-else class="w-100 text-left" style="width: 600px;max-width: 600px;display: inline-block;">
Expand Down Expand Up @@ -250,7 +250,12 @@
import store from "../../new-service/store";
import {custosService} from "@/new-service/store/util/custos.util";
import TenantHome from "@/components/admin-portal/TenantHome";
import {VALIDATION_REGEX_DOMAIN, VALIDATION_REGEX_EMAIL, VALIDATION_REGEX_URI} from "@/components/validation-regex";
import {
VALIDATION_REGEX_DOMAIN,
VALIDATION_REGEX_EMAIL,
VALIDATION_REGEX_FIRST_NAME, VALIDATION_REGEX_LAST_NAME,
VALIDATION_REGEX_URI
} from "@/components/validation-regex";
export default {
components: {TenantHome},
Expand Down Expand Up @@ -328,8 +333,8 @@ export default {
isValid() {
return {
username: !!this.username && this.username.length >= 3,
firstName: !!this.firstName && this.firstName.length > 0,
lastName: !!this.lastName && this.lastName.length > 0,
firstName: !!this.firstName && VALIDATION_REGEX_FIRST_NAME.test(this.firstName),
lastName: !!this.lastName && VALIDATION_REGEX_LAST_NAME.test(this.lastName),
email: !!this.email && VALIDATION_REGEX_EMAIL.test(this.email),
password: !!this.password && /[a-z]/.test(this.password) && // checks for a-z
/[0-9]/.test(this.password) && // checks for 0-9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<b-overlay :show="processingAddNewUsers" rounded spinner-small spinner-variant="primary" class="d-inline-block">
<b-button variant="primary" v-b-modal="`modal-select-users-or-groups`">Share</b-button>
</b-overlay>
<modal-share-entity :client-id="clientId" :entity-id="entityId"
<modal-share-entity v-if="entity" :client-id="clientId" :entity-id="entityId"
:modal-id="`modal-select-users-or-groups`"
:title="`Share Entity '${entity.name}'`"
v-on:close="refreshData"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
<b-td>{{ entityType.description }}</b-td>
<b-td>
<button-overlay :show="processingDelete[entityType.id]">
<b-button variant="link" size="sm" v-on:click="onClickDelete(entityType)">
<b-button variant="link" size="sm" v-on:click="onClickDelete(entityType)"
:disabled="disabledEntityTypes[entityType.id]">
<b-icon icon="trash"></b-icon>
</b-button>
</button-overlay>
Expand All @@ -47,7 +48,11 @@ export default {
data() {
return {
processingDelete: {},
errors: []
errors: [],
disabledEntityTypes: {
"SECRET": true
}
}
},
computed: {
Expand Down
16 changes: 8 additions & 8 deletions custos-demo-gateway/src/components/admin-portal/TenantHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
</div>

<div class="w-100" v-if="tenant" style="display: flex; flex-direction: row;">
<div style="width: 200px;padding-top: 15px;" v-if="tenant.hasAdminPrivileges">
<div style="width: 200px;padding-top: 15px;">
<ul>
<li>
<li v-if="tenant.hasAdminPrivileges || appTenant.hasAdminPrivileges">
<router-link :to="`/tenants/${clientId}/profile`" v-slot="{ href, route, navigate}" tag="">
<b-link @click="navigate" :href="href">Profile</b-link>
</router-link>
<ul>
<ul v-if="tenant.hasAdminPrivileges && tenant.status === 'ACTIVE'">
<li>
<router-link :to="`/tenants/${clientId}/roles`" v-slot="{ href, route, navigate}"
tag="">
Expand All @@ -45,13 +45,13 @@
<!-- <b-link @click="navigate" :href="href">User Management</b-link>-->
<!-- </router-link>-->
<!-- <ul>&lt;!&ndash;&ndash;&gt;-->
<li>
<li v-if="tenant.hasAdminPrivileges && tenant.status === 'ACTIVE'">
<router-link :to="`/tenants/${clientId}/users`" v-slot="{ href, route, navigate}"
tag="">
<b-link @click="navigate" :href="href">Users</b-link>
</router-link>
</li>
<li>
<li v-if="tenant.hasAdminPrivileges && tenant.status === 'ACTIVE'">
<router-link :to="`/tenants/${clientId}/groups`" v-slot="{ href, route, navigate}"
tag="">
<b-link @click="navigate" :href="href">Groups</b-link>
Expand All @@ -72,12 +72,12 @@
<!-- </router-link>-->
<!-- </li>-->

<li>
<li v-if="tenant.hasAdminPrivileges && tenant.status === 'ACTIVE'">
<router-link :to="`/tenants/${clientId}/entities`" v-slot="{ href, route, navigate}" tag="">
<b-link @click="navigate" :href="href">Entities</b-link>
</router-link>
</li>
<li>
<li v-if="tenant.hasAdminPrivileges && tenant.status === 'ACTIVE'">
<router-link :to="`/tenants/${clientId}/audits`" v-slot="{ href, route, navigate}" tag="">
<b-link @click="navigate" :href="href">Secrets</b-link>
</router-link>
Expand All @@ -95,7 +95,7 @@
<!-- </li>-->
<!-- </ul>-->

<li v-if="tenant.type !== 'CHILD_TENANT'">
<li v-if="tenant.status === 'ACTIVE' && tenant.type !== 'CHILD_TENANT'">
<router-link :to="`/tenants/${tenant.clientId}/child-tenants`" v-slot="{ href, route, navigate}" tag="">
<b-link @click="navigate" :href="href" v-if="tenant.type === 'SUPER_TENANT'">Admin Clients</b-link>
<b-link @click="navigate" :href="href" v-if="tenant.type === 'ADMIN_TENANT'">Child Clients</b-link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
size="sm">
</b-form-input>
</div>

<div class="pt-3">
<label class="form-label" for="entityTypeId">Entity Type</label>
<button-overlay :show="!entityTypes" class="w-100">
Expand All @@ -50,6 +51,18 @@
</b-form-select>
</button-overlay>
</div>

<div class="pt-3" v-if="entityTypeId === 'SECRET'">
<label class="form-label" for="secretType">Secret Type</label>
<b-form-radio-group
v-model="secretType"
:options="availableSecretTypes"
id="secretType"
trim
size="sm">
</b-form-radio-group>
</div>

</div>
</div>
</b-overlay>
Expand All @@ -73,6 +86,9 @@ export default {
name: null,
description: null,
entityTypeId: null,
secretType: "SSH",
availableSecretTypes: ["SSH"],
inputFieldsList: ["name", "description", "entityTypeId"]
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
<b-td>{{ permissionType.description }}</b-td>
<b-td>
<button-overlay :show="processingDelete[permissionType.id]">
<b-button variant="link" size="sm" v-on:click="onClickDelete(permissionType)">
<b-button variant="link" size="sm" v-on:click="onClickDelete(permissionType)"
:disabled="disabledPermissionType[permissionType.id]">
<b-icon icon="trash"></b-icon>
</b-button>
</button-overlay>
Expand All @@ -47,7 +48,11 @@ export default {
data() {
return {
processingDelete: {},
errors: []
errors: [],
disabledPermissionType: {
"OWNER": true
}
}
},
computed: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@
import store from "../../new-service/store";
import TenantHome from "@/components/admin-portal/TenantHome";
import {custosService} from "@/new-service/store/util/custos.util";
import {VALIDATION_REGEX_DOMAIN, VALIDATION_REGEX_EMAIL, VALIDATION_REGEX_URI} from "@/components/validation-regex";
import {
VALIDATION_REGEX_DOMAIN,
VALIDATION_REGEX_EMAIL,
VALIDATION_REGEX_FIRST_NAME, VALIDATION_REGEX_LAST_NAME,
VALIDATION_REGEX_URI
} from "@/components/validation-regex";
export default {
name: "TenantProfile",
Expand Down Expand Up @@ -299,8 +304,8 @@ export default {
isValid() {
return {
username: !!this.username && this.username.length >= 3,
firstName: !!this.firstName && this.firstName.length > 0,
lastName: !!this.lastName && this.lastName.length > 0,
firstName: !!this.firstName && VALIDATION_REGEX_FIRST_NAME.test(this.firstName),
lastName: !!this.lastName && VALIDATION_REGEX_LAST_NAME.test(this.lastName),
email: !!this.email && VALIDATION_REGEX_EMAIL.test(this.email),
tenantName: !!this.tenantName && this.tenantName.length > 0,
Expand Down
57 changes: 40 additions & 17 deletions custos-demo-gateway/src/components/admin-portal/TenantUser.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<template>
<TenantHome :title="title" :breadcrumb-links="breadcrumbLinks">
<TenantHome :title="title" :breadcrumb-links="breadcrumbLinks" :errors="errors">
<template #header-right>
<div style="font-size: 14px; font-weight: 500;">
<b-icon icon="envelope"></b-icon>
{{ email }}
<br/>
<b-icon icon="person"></b-icon>
{{ username }}
<div style="display: flex; flex-direction: row;">
<div style="font-size: 14px; font-weight: 500;padding-right: 20px;">
<b-icon icon="envelope"></b-icon>
{{ email }}
<br/>
<b-icon icon="person"></b-icon>
{{ username }}
</div>
<div>
<b-button variant="primary" v-on:click="onClickSave">Save</b-button>
</div>
</div>
</template>

Expand Down Expand Up @@ -176,10 +181,6 @@
</div>

</div>
<div class="p-2 pt-4">
<b-button variant="primary" size="sm" v-on:click="onClickSave">Save</b-button>
<b-button variant="secondary" size="sm" class="ml-3">Cancel</b-button>
</div>
</b-overlay>
</TenantHome>
</template>
Expand All @@ -188,7 +189,11 @@
import TenantHome from "@/components/admin-portal/TenantHome";
import store from "@/new-service/store";
import TableOverlayInfo from "@/components/table-overlay-info";
import {VALIDATION_REGEX_EMAIL} from "@/components/validation-regex";
import {
VALIDATION_REGEX_EMAIL,
VALIDATION_REGEX_FIRST_NAME,
VALIDATION_REGEX_LAST_NAME
} from "@/components/validation-regex";
// import TableOverlayInfo from "@/components/table-overlay-info";
export default {
Expand All @@ -207,6 +212,8 @@ export default {
clientRoles: [],
attributes: null, // [{key: "a", values: ["1", "2", "3"]}, {key: "b", values: ["fhfhf"]}]
rolesToBeDisabled: ["uma_authorization", "offline_access"],
inputFieldsList: ["firstName", "lastName", "email", "realmRoles", "clientRoles", "attributes"]
}
},
Expand All @@ -225,8 +232,8 @@ export default {
isValid() {
return {
username: !!this.username && this.username.length > 0,
firstName: !!this.firstName && this.firstName.length > 0,
lastName: !!this.lastName && this.lastName.length > 0,
firstName: !!this.firstName && VALIDATION_REGEX_FIRST_NAME.test(this.firstName),
lastName: !!this.lastName && VALIDATION_REGEX_LAST_NAME.test(this.lastName),
email: !!this.email && VALIDATION_REGEX_EMAIL.test(this.email),
realmRoles: true,
clientRoles: true,
Expand All @@ -249,12 +256,26 @@ export default {
user() {
return this.$store.getters["user/getUser"]({clientId: this.clientId, username: this.username})
},
tenant() {
return this.$store.getters["tenant/getTenant"]({clientId: this.clientId});
},
breadcrumbLinks() {
const _breadcrumbLinks = [{to: `/tenants/${this.clientId}/users`, name: "Users"}];
const _breadcrumbLinks = [];
if (this.tenant) {
_breadcrumbLinks.push({
to: `/tenants/${this.clientId}/users`,
name: "Users",
disabled: !this.tenant.hasAdminPrivileges
});
}
if (this.user) {
// alert("this.tenant.hasAdminPrivileges " + this.tenant.hasAdminPrivileges)
_breadcrumbLinks.push({
to: `/tenants/${this.clientId}/users/${this.username}`,
name: this.title
name: this.title,
disabled: !this.tenant.hasAdminPrivileges
});
}
Expand All @@ -271,7 +292,9 @@ export default {
availableTenantRoles() {
const _roles = this.$store.getters["tenant/getTenantRoles"]({clientId: this.clientId, clientLevel: false});
if (_roles) {
return _roles.map(({name}) => name);
return _roles.map(({name}) => {
return {value: name, text: name, disabled: this.rolesToBeDisabled.indexOf(name) >= 0}
});
} else {
return [];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
<template>
<div>
<div>Secret Entity. TBA</div>
<entity-view-default :entity-id="entityId" :client-id="clientId"/>
<div style="flex: 1;" class="ml-2">
<label class="form-label" for="passphrase">Passphrase</label>
<b-form-textarea
v-model="entity.ext.passphrase"
id="passphrase"
trim
size="sm"
readonly>
</b-form-textarea>
<b-form-invalid-feedback>
</b-form-invalid-feedback>
</div>

<div style="flex: 1;" class="ml-2">
<label class="form-label" for="public_key">Public Key</label>
<b-form-textarea
v-model="entity.ext.public_key"
id="public_key"
trim
size="sm"
readonly
style="min-height: 100px;">
</b-form-textarea>
<b-form-invalid-feedback>
</b-form-invalid-feedback>
</div>

<div style="flex: 1;" class="ml-2">
<label class="form-label" for="private_key">Private Key</label>
<b-form-textarea
v-model="entity.ext.private_key"
id="private_key"
trim
size="sm"
readonly
style="min-height: 300px;">
</b-form-textarea>
<b-form-invalid-feedback>
</b-form-invalid-feedback>
</div>

</div>
</template>

<script>
import store from "@/new-service/store";
import EntityViewDefault from "@/components/admin-portal/block/entity-view/entity-view-default";
export default {
name: "entity-view-secret",
components: {EntityViewDefault},
store: store,
props: {
clientId: {},
Expand Down
Loading

0 comments on commit d8cf439

Please sign in to comment.