Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit cb6d349

Browse files
committed
- Add namespace support
- Fix issue with Identifies - Remove dashboard coming soon language
1 parent c16c769 commit cb6d349

File tree

10 files changed

+109
-35
lines changed

10 files changed

+109
-35
lines changed

app/elements/dash-board.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@
4747
<div class="center">
4848
<div class="vertical center">
4949
<iron-icon id="dashboard" icon="dashboard"></iron-icon>
50-
<div>
51-
<div class="shaded">Dashboard</div>
52-
</div>
53-
<div>
54-
<div class="shaded">Coming Soon!</div>
55-
</div>
5650
</div>
5751
</div>
5852
</div>

app/elements/elements.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
-->
1414

1515
<!-- Iron Elements -->
16+
<link rel="import" href="../bower_components/iron-collapse/iron-collapse.html">
1617
<link rel="import" href="../bower_components/iron-flex-layout/iron-flex-layout.html">
1718
<link rel="import" href="../bower_components/iron-icons/iron-icons.html">
1819
<link rel="import" href="../bower_components/iron-icons/communication-icons.html">

app/elements/login-form.html

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@
7373
paper-progress.bottombar {
7474
--paper-progress-container-color: rgba(#ffffff, 0);
7575
}
76+
#collapse {
77+
padding: 0em;
78+
background-color: #d3d3d36e;
79+
margin: 1em;
80+
border-radius: 5px;
81+
}
82+
#optionalCollapsible {
83+
margin: 0 2em;
84+
padding-bottom: 1em;
85+
}
7686
</style>
7787

7888
<iron-ajax id="authenticateReq"
@@ -94,6 +104,7 @@
94104
handle-as="json"
95105
method="POST"
96106
body="{{oidcBody}}"
107+
headers="{{header}}"
97108
content-type="application/json"
98109
last-response="{{oidcResponse}}"
99110
last-error={{loginError}}
@@ -167,11 +178,22 @@
167178
<paper-input id="userfield" value="{{username}}" label="Username" disabled="{{loading}}"></paper-input>
168179
<paper-input id="passfield" value="{{password}}" label="Password" type="password" disabled="{{loading}}"></paper-input>
169180
</div>
170-
<div>
171-
<iron-a11y-keys target="[[targetrole]]" keys="enter" on-keys-pressed="_login"></iron-a11y-keys>
172-
<paper-input id="rolefield" value="{{role}}" label="Role (optional)" disabled="{{loading}}"></paper-input>
173-
</div>
174181
</iron-pages>
182+
<div id="trigger" on-tap="_toggleOptional" style="padding: 0 15px;">
183+
<iron-icon icon="{{optionalIcon}}" hidden$="[[noIcons]]"></iron-icon>
184+
More Options
185+
</div>
186+
<iron-collapse id="collapse" opened="{{optionalOpen}}">
187+
<div id="optionalCollapsible">
188+
<div>
189+
<paper-input id="namespacefield" value="{{namespace}}" label="Namespace" disabled="{{loading}}"></paper-input>
190+
</div>
191+
<template is="dom-if" if="{{roleVisible}}">
192+
<iron-a11y-keys target="[[targetrole]]" keys="enter" on-keys-pressed="_login"></iron-a11y-keys>
193+
<paper-input id="rolefield" value="{{role}}" label="Role" disabled="{{loading}}"></paper-input>
194+
</template>
195+
</div>
196+
</iron-collapse>
175197
<div class="buttons">
176198
<paper-button on-tap="_login" autofocus disabled="{{loading}}">Login</paper-button>
177199
</div>
@@ -181,6 +203,8 @@
181203
<app-localstorage-document key="page" data="{{page}}"></app-localstorage-document>
182204
<app-localstorage-document key="urls" data="{{urls}}"></app-localstorage-document>
183205
<app-localstorage-document key="username" data="{{username}}"></app-localstorage-document>
206+
<app-localstorage-document key="namespace" data="{{namespace}}"></app-localstorage-document>
207+
<app-localstorage-document key="optionalOpen" data="{{optionalOpen}}"></app-localstorage-document>
184208

185209
<paper-toast id="errortoast" class="fit-bottom error" duration="5000">
186210
<iron-icon prefix icon="error-outline" style="padding-right: 7px;"></iron-icon>
@@ -242,6 +266,10 @@
242266
type: String,
243267
value: ''
244268
},
269+
roleVisible: {
270+
type: Boolean,
271+
value: false
272+
},
245273
backends: {
246274
type: Array,
247275
value: [],
@@ -281,6 +309,25 @@
281309
type: Object,
282310
notify: true
283311
},
312+
namespace: {
313+
type: String,
314+
value: '',
315+
observer: '_watchNamespace'
316+
},
317+
namespaceLabel: {
318+
type: String,
319+
value: 'None',
320+
notify: true,
321+
},
322+
optionalOpen: {
323+
type: Boolean,
324+
value: false,
325+
observer: '_watchOptionalIcon'
326+
},
327+
optionalIcon: {
328+
type: String,
329+
value: 'expand-more'
330+
},
284331
page: {
285332
type: Number,
286333
value: 0,
@@ -327,14 +374,15 @@
327374
_autofocus: function() {
328375
// Close OIDC alert on all pages. Open selectively as needed.
329376
this.$.oidctoast.close();
377+
this.roleVisible = false;
330378

331379
// Set cursor autofocus for login/password fields
332380
// TODO: autofocus on username field first if unset
333381
if (this.page === 1) this.$.tokenfield.autofocus = true;
334382
else if (this.page === 0) this.$.passfieldldap.autofocus = true;
335383
else if (this.page === 2) this.$.passfield.autofocus = true;
336384
else if (this.page === 3) {
337-
this.$.rolefield.autofocus = true;
385+
this.roleVisible = true;
338386
if (!(this.oidcStarted)) this.$.oidctoast.open();
339387
}
340388
},
@@ -354,6 +402,7 @@
354402
return;
355403
}
356404
this.authMethod = 'POST';
405+
this.header = {"X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace};
357406
this.authURL = this.url + 'v1/auth/ldap/login/' + this.username;
358407
this.body = {"password": this.password };
359408
} else if (this.page == 1) {
@@ -365,7 +414,7 @@
365414
}
366415
this.authMethod = 'GET';
367416
this.authURL = this.url + 'v1/auth/token/lookup-self';
368-
this.header = {"X-Vault-Token": this.token, "X-Cryptr-Version": app.cryptrVersion };
417+
this.header = {"X-Vault-Token": this.token, "X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace };
369418
this.body = '';
370419
} else if (this.page == 2) {
371420
if (!this.username && !this.password) { //Check fields have content
@@ -376,11 +425,13 @@
376425
}
377426
this.authMethod = 'POST';
378427
this.authURL = this.url + 'v1/auth/userpass/login/' + this.username;
428+
this.header = {"X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace};
379429
this.body = {"password": this.password };
380430
} else if (this.page == 3) {
381431
if (this.oidcStarted) {
382-
this.oidcURL = this.url + 'v1/auth/oidc/oidc/auth_url'
432+
this.oidcURL = this.url + 'v1/auth/oidc/oidc/auth_url';
383433
this.oidcBody = {"redirect_uri": "http://localhost:8250/oidc/callback", "role": this.role}
434+
this.header = {"X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace};
384435
this.loading = true;
385436
this.$.oidcReq.generateRequest();
386437
} else {
@@ -399,7 +450,7 @@
399450
// UserPass / LDAP
400451
if (this.loginResponse.auth && this.loginResponse.auth.client_token) {
401452
this.loginResponse = this.loginResponse.auth;
402-
this.header = {"X-Vault-Token": this.loginResponse.client_token, "X-Cryptr-Version": app.cryptrVersion };
453+
this.header = {"X-Vault-Token": this.loginResponse.client_token, "X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace };
403454
// Token Auth
404455
} else if (this.loginResponse.data) {
405456
this.loginResponse = this.loginResponse.data;
@@ -536,7 +587,7 @@
536587
this.authMethod = 'GET';
537588
this.authURL = this.url + 'v1/auth/oidc/oidc/callback?code=' + data.code + '&state=' + data.state;
538589
this.body = '';
539-
this.header = '';
590+
this.header = {"X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace};
540591
this.push('authRequests', this.$.testReq.generateRequest());
541592
},
542593
_oidcAuthError: function(data) {
@@ -558,6 +609,19 @@
558609
this.$.authenticateReq.generateRequest();
559610
this.authRequests = [];
560611
}
612+
},
613+
_appendNamespace: function() {
614+
if (this.namespace != "") return '?namespace=' + this.namespace
615+
else return ""
616+
},
617+
_toggleOptional: function() {
618+
this.optionalOpen = !this.optionalOpen;
619+
},
620+
_watchOptionalIcon: function() {
621+
this.optionalIcon = (this.optionalOpen) ? 'expand-more' : 'chevron-right';
622+
},
623+
_watchNamespace: function() {
624+
this.namespaceLabel = (this.namespace) ? this.namespace : 'None'
561625
}
562626
});
563627
})();

app/elements/secrets-init.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
_listSecrets: function(key) {
9999
// Todo: Check for list permissions on folder before executing
100100
// Execute list on a folder
101-
if (!key.startsWith('sys') && !key.startsWith('cubbyhole')) {
101+
if (!key.startsWith('sys') && !key.startsWith('cubbyhole') && !key.startsWith('identity')) {
102102
// Track completed requests
103103
this.push('completedRequests', key);
104104

@@ -160,7 +160,7 @@
160160
},
161161
_addSecret: function(location) {
162162
var parts = location.split('/');
163-
if (!['sys', 'auth', 'cubbyhole'].includes(parts[0])) {
163+
if (!['sys', 'auth', 'cubbyhole', 'identity'].includes(parts[0])) {
164164
var type = location.endsWith('/') ? 'folder' : 'secret';
165165
var permissions = [];
166166
var keys = Object.keys(this.secretAccess).sort(function(a, b){ return b.length > a.length;}); //Sort by longest key to prioritize individual secret policies rather than wildcards
@@ -231,8 +231,8 @@
231231
var folderFound = false;
232232
for (var key in this.access) {
233233
var parts = key.split('/');
234-
if (!['sys', 'auth', 'cubbyhole'].includes(parts[0])) this.secretAccess[key] = this.access[key];
235-
if (this.access[key].capabilities.indexOf('deny') < 0) {
234+
if (!['sys', 'auth', 'cubbyhole', 'identity'].includes(parts[0])) this.secretAccess[key] = this.access[key];
235+
if ('capabilities' in this.access[key] && this.access[key].capabilities.indexOf('deny') < 0) {
236236
if (key.endsWith('/*') || key.endsWith('/')) {
237237
if (!['data', 'delete', 'destroy', 'undelete'].includes(parts[1])) {
238238
folderFound = true;
@@ -248,8 +248,13 @@
248248
}
249249
this._listSecrets(key);
250250
}
251-
}
252-
else this._addSecret(key);
251+
} else if (key == '*') { //Support root access, including root Namespace users
252+
folderFound = true;
253+
for (var i in this.backends) {
254+
if (this.backends[i].type === '2') this._listSecrets(this.backends[i].name + '/metadata/');
255+
else this._listSecrets(this.backends[i].name);
256+
}
257+
} else this._addSecret(key);
253258
}
254259
}
255260
if (!folderFound) this.loading = false;

app/elements/user-info.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@
2020
}
2121
</style>
2222
<template>
23-
24-
<paper-item>
23+
<paper-item>
2524
<paper-icon-button icon="refresh" on-click="_refreshKeys" style="margin-right: 20px"></paper-icon-button>
26-
<iron-icon icon="account-circle" style="color: #888"></iron-icon>
27-
<span class="noselect name">{{upperUser}}</span>
28-
<paper-button raised on-click="logout">Logout</paper-button>
29-
</paper-item>
25+
<iron-icon icon="account-circle" style="color: #888"></iron-icon>
26+
<span class="noselect name">{{upperUser}}</span>
27+
<paper-button raised on-click="logout">Logout</paper-button>
28+
</paper-item>
3029
</template>
3130

3231
<script>

app/index.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<body unresolved>
3232
<template is="dom-bind" id="app">
3333
<div id="blocker"></div> <!-- blocker: an element to obscure background-loading content at load time. -->
34-
<login-form status="{{status}}" username="{{u}}" url="{{url}}" header="{{header}}" login-response="{{loginResponse}}" loading="{{loading}}" backends="{{backends}}"></login-form>
34+
<login-form status="{{status}}" username="{{u}}" url="{{url}}" header="{{header}}" login-response="{{loginResponse}}" loading="{{loading}}" backends="{{backends}}" namespace-label="{{namespaceLabel}}"></login-form>
3535
<login-status id="login-status" status="{{status}}" url="{{url}}" header="{{header}}"></login-status>
3636
<secrets-init status="{{status}}" header="{{header}}" deferred-requests="{{deferredRequests}}" completed-requests="{{completedRequests}}" folder-route="{{folderRoute}}" login-response="{{loginResponse}}" secrets="{{secrets}}" access="{{access}}" loading="{{loading}}" backends="{{backends}}" index-all-secrets="{{indexAllSecrets}}"></secrets-init>
3737

@@ -46,7 +46,7 @@
4646
<span class="menu-name noselect">Cryptr</span>
4747
</paper-toolbar>
4848

49-
<div style="height: calc(100vh - 100px); overflow: scroll; padding-left: 10px;">
49+
<div style="height: calc(100vh - 128px); overflow: scroll; padding-left: 10px;">
5050
<span id="drawerMenuText" class="noselect">HOME</span>
5151
<paper-menu attr-for-selected="data-route" selected="{{route}}">
5252
<a data-route="home" href="{{baseUrl}}" class="noselect">
@@ -85,9 +85,12 @@
8585

8686
</div>
8787

88-
<!-- <div class="bottom-corner" style="color: #737373;">
89-
<paper-icon-button icon="settings"></paper-icon-button>
90-
</div> -->
88+
<div id="namespaceBar" class="noselect" style="width: {{drawerWidth}}">
89+
<paper-item>
90+
<iron-icon prefix icon="tab-unselected" style="min-width: 24px; padding-right: 7px;"></iron-icon>
91+
<b style="padding-right: 5px;">Namespace:</b> {{namespaceLabel}}
92+
</paper-item>
93+
</div>
9194
</paper-scroll-header-panel>
9295

9396
<!-- Main Area -->

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cryptr",
33
"author": "Jacob Crowther <crowther@adobe.com>",
4-
"version": "0.5.0",
4+
"version": "0.6.0",
55
"description": "A GUI for Vault",
66
"repository": {
77
"url": "https://github.com/jcrowthe/cryptr.git"

app/scripts/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ app.baseUrl = '/';
1818
app.url = 'start';
1919
app.secretRoute = '';
2020
app.folderRoute = '';
21-
app.cryptrVersion = "0.2.0";
21+
app.cryptrVersion = "0.6.0";
2222

2323
// Index filtering and sorting
2424
app.filterFolders = function(item) {

app/styles/app-theme.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@
117117

118118

119119
/* General styles */
120+
121+
#namespaceBar {
122+
height: 48px;
123+
background-color: #353d4a;
124+
color: #c0c1c3;
125+
}
126+
120127
.bottombar {
121128
position: fixed;
122129
left: 0;
@@ -142,6 +149,7 @@
142149
color: var(--secondary-text-color);
143150
background-color: var(--drawer-menu-color);
144151
border-bottom: none;
152+
height: 80px;
145153
}
146154

147155
.menu-name {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cryptr",
33
"author": "Jacob Crowther <crowther@adobe.com>",
4-
"version": "0.5.0",
4+
"version": "0.6.0",
55
"description": "A GUI for Vault",
66
"main": "app/index.js",
77
"repository": {

0 commit comments

Comments
 (0)