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

Commit ecc4fb7

Browse files
authored
Support for Versioned Secrets (KV V2 secret engine support) (#37)
* Versioned Secrets √ destroy operation √ "move" operation √ numbers and arrays get cast as strings and objects!! √ show icon or error when secret data is null √ default new secret path seems to be broken now with multiple folder-structures √ clear TOKEN as username √ swap raw and hide values for icons √ make Hide Values persistent √ improve error output for move requests * - Add support for wildcard policies on v2 secret backends - Update to Electron 4.0 - Update copyright
1 parent 1096be0 commit ecc4fb7

12 files changed

Lines changed: 4458 additions & 82 deletions

app/bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"paper-elements": "^1.0.7",
2121
"neon-elements": "^1.0.0",
2222
"page": "^1.7.1",
23-
"juicy-jsoneditor": "^1.1.1",
23+
"juicy-jsoneditor": "^1.3.0",
2424
"paper-toggle-button": "^2.0.0",
2525
"font-roboto-local": "PolymerElements/font-roboto-local#^1.0.1",
2626
"fuse.js": "^3.2.0",

app/elements/login-form.html

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@
9898
on-error="_testError"
9999
timeout="5000">
100100
</iron-ajax>
101+
102+
<iron-ajax id="listMounts"
103+
url="{{listMountsURL}}"
104+
handle-as="json"
105+
headers="{{header}}"
106+
last-response="{{listMountResponse}}"
107+
on-error="_listMountError"
108+
on-response="_listMountSuccess">
109+
</iron-ajax>
101110

102111
<paper-dialog id="modal" class="noselect" entry-animation="scale-up-animation" modal no-cancel-on-esc-key no-cancel-on-outside-click auto-fit-on-attach>
103112
<iron-image id="logo" sizing="contain" src="../images/cryptr-internal.png"></iron-image>
@@ -204,6 +213,12 @@
204213
body: Object,
205214
password: String,
206215
authURL: String,
216+
listMountsURL: String,
217+
backends: {
218+
type: Array,
219+
value: [],
220+
notify: true
221+
},
207222
token: {
208223
type: String,
209224
value: ''
@@ -326,9 +341,9 @@
326341
// Token Auth
327342
} else if (this.loginResponse.data) {
328343
this.loginResponse = this.loginResponse.data;
329-
this.username = 'TOKEN';
330344
}
331-
this.status = 'watch';
345+
this._listMounts();
346+
332347
this.password = '';
333348
this.token = '';
334349
document.getElementById('blocker').style.display = 'none';
@@ -347,14 +362,42 @@
347362
else this.errorText = 'Unknown Error: Please try again later.';
348363
this.$.errortoast.show();
349364
},
365+
_listMounts: function() {
366+
this.backends = [];
367+
// Request the accessible mounts to determine what mounts should be printed
368+
this.listMountsURL = this.url + 'v1/sys/internal/ui/mounts'
369+
this.$.listMounts.generateRequest();
370+
371+
},
372+
_listMountError: function(e) {
373+
// Vault version is older than 0.10.0. Show all available mounts.
374+
this.push('backends', {name: '', type: '1', base: ''});
375+
},
376+
_listMountSuccess: function(e) {
377+
this.status = 'watch';
378+
var secretBackends = this.listMountResponse.data.secret;
379+
for (var i in secretBackends) {
380+
if (secretBackends[i].type && ['kv', 'generic'].includes(secretBackends[i].type)) {
381+
var backend = {
382+
name: i.slice(0, -1),
383+
base: i.slice(0, -1),
384+
type: '1'
385+
}
386+
if (secretBackends[i].options != null && secretBackends[i].options.version) {
387+
backend['type'] = secretBackends[i].options.version;
388+
if (backend.type === '2') backend['base'] = backend.name + '/data'
389+
}
390+
this.push('backends', backend);
391+
}
392+
}
393+
},
350394
_testSuccess: function() {
351395
if (this.testResponse == null ||
352396
!this.testResponse.hasOwnProperty('t') ||
353397
!this.testResponse.hasOwnProperty('n') ||
354398
!this.testResponse.hasOwnProperty('progress') ||
355399
!this.testResponse.hasOwnProperty('version') ||
356-
!this.testResponse.hasOwnProperty('cluster_id') ||
357-
!this.testResponse.hasOwnProperty('cluster_name')) {
400+
!this.testResponse.hasOwnProperty('sealed')) {
358401
this.errorText = 'No supported Vault instance found at the this URL';
359402
this.$.errortoast.show();
360403
this.approvedURL = false;

app/elements/login-status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ <h2>Logging Out</h2>
127127
app.secretRoute = '';
128128
app.folderRoute = '';
129129
app.route = 'home';
130-
130+
app.backends = [];
131131
}
132132
});
133133
})();

app/elements/secret-display.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,29 @@
127127
</template>
128128
</div>
129129
</section>
130+
<section>
131+
<div class="vertical">
132+
<div class="horizontal justified">
133+
<iron-icon id="file" icon="cancel"></iron-icon>
134+
</div>
135+
<div class="horizontal justified">
136+
Version has been deleted
137+
</div>
138+
<div class="horizontal justified">
139+
<paper-button on-tap="_undelete">Restore Version</paper-button>
140+
</div>
141+
</div>
142+
</section>
143+
<section>
144+
<div class="vertical">
145+
<div class="horizontal justified">
146+
<iron-icon id="file" icon="cancel"></iron-icon>
147+
</div>
148+
<div class="horizontal justified">
149+
Version has been destroyed
150+
</div>
151+
</div>
152+
</section>
130153
</iron-pages>
131154
</div>
132155
</template>
@@ -149,6 +172,11 @@
149172
type: Boolean,
150173
value: false
151174
},
175+
metadata: {
176+
type: Object,
177+
value: {},
178+
notify: true
179+
},
152180
selected: {
153181
type: Number,
154182
value: 0,
@@ -175,6 +203,9 @@
175203
},
176204
_convertFile: function(e, file){
177205
this.data = {data: file.data, filename: file.name, lastModified: file.lastModified, type: 'file'};
206+
},
207+
_undelete: function() {
208+
this.fire('undelete');
178209
}
179210
});
180211
</script>

0 commit comments

Comments
 (0)