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

Commit 058572e

Browse files
committed
Support custom mount paths
1 parent cb6d349 commit 058572e

File tree

1 file changed

+49
-5
lines changed

1 file changed

+49
-5
lines changed

app/elements/login-form.html

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,26 @@
188188
<div>
189189
<paper-input id="namespacefield" value="{{namespace}}" label="Namespace" disabled="{{loading}}"></paper-input>
190190
</div>
191+
<template is="dom-if" if="{{_setMountPath(page, 0)}}">
192+
<div>
193+
<paper-input value="{{ldapMountPath}}" label="Mount Path" disabled="{{loading}}"></paper-input>
194+
</div>
195+
</template>
196+
<template is="dom-if" if="{{_setMountPath(page, 1)}}">
197+
<div>
198+
<paper-input value="{{tokenMountPath}}" label="Mount Path" disabled="{{loading}}"></paper-input>
199+
</div>
200+
</template>
201+
<template is="dom-if" if="{{_setMountPath(page, 2)}}">
202+
<div>
203+
<paper-input value="{{userpassMountPath}}" label="Mount Path" disabled="{{loading}}"></paper-input>
204+
</div>
205+
</template>
206+
<template is="dom-if" if="{{_setMountPath(page, 3)}}">
207+
<div>
208+
<paper-input value="{{oidcMountPath}}" label="Mount Path" disabled="{{loading}}"></paper-input>
209+
</div>
210+
</template>
191211
<template is="dom-if" if="{{roleVisible}}">
192212
<iron-a11y-keys target="[[targetrole]]" keys="enter" on-keys-pressed="_login"></iron-a11y-keys>
193213
<paper-input id="rolefield" value="{{role}}" label="Role" disabled="{{loading}}"></paper-input>
@@ -205,6 +225,10 @@
205225
<app-localstorage-document key="username" data="{{username}}"></app-localstorage-document>
206226
<app-localstorage-document key="namespace" data="{{namespace}}"></app-localstorage-document>
207227
<app-localstorage-document key="optionalOpen" data="{{optionalOpen}}"></app-localstorage-document>
228+
<app-localstorage-document key="ldapMountPath" data="{{ldapMountPath}}"></app-localstorage-document>
229+
<app-localstorage-document key="oidcMountPath" data="{{oidcMountPath}}"></app-localstorage-document>
230+
<app-localstorage-document key="tokenMountPath" data="{{tokenMountPath}}"></app-localstorage-document>
231+
<app-localstorage-document key="userpassMountPath" data="{{userpassMountPath}}"></app-localstorage-document>
208232

209233
<paper-toast id="errortoast" class="fit-bottom error" duration="5000">
210234
<iron-icon prefix icon="error-outline" style="padding-right: 7px;"></iron-icon>
@@ -349,6 +373,22 @@
349373
oidcStarted: {
350374
type: Boolean,
351375
value: false
376+
},
377+
ldapMountPath: {
378+
type: String,
379+
value: 'ldap'
380+
},
381+
oidcMountPath: {
382+
type: String,
383+
value: 'oidc'
384+
},
385+
tokenMountPath: {
386+
type: String,
387+
value: 'token'
388+
},
389+
userpassMountPath: {
390+
type: String,
391+
value: 'userpass'
352392
}
353393
},
354394
attached: function() {
@@ -403,7 +443,7 @@
403443
}
404444
this.authMethod = 'POST';
405445
this.header = {"X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace};
406-
this.authURL = this.url + 'v1/auth/ldap/login/' + this.username;
446+
this.authURL = this.url + 'v1/auth/' + this.ldapMountPath + '/login/' + this.username;
407447
this.body = {"password": this.password };
408448
} else if (this.page == 1) {
409449
if (!this.token) { //Check field has content
@@ -413,7 +453,7 @@
413453
return;
414454
}
415455
this.authMethod = 'GET';
416-
this.authURL = this.url + 'v1/auth/token/lookup-self';
456+
this.authURL = this.url + 'v1/auth/' + this.tokenMountPath + '/lookup-self';
417457
this.header = {"X-Vault-Token": this.token, "X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace };
418458
this.body = '';
419459
} else if (this.page == 2) {
@@ -424,12 +464,12 @@
424464
return;
425465
}
426466
this.authMethod = 'POST';
427-
this.authURL = this.url + 'v1/auth/userpass/login/' + this.username;
467+
this.authURL = this.url + 'v1/auth/' + this.userpassMountPath + '/login/' + this.username;
428468
this.header = {"X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace};
429469
this.body = {"password": this.password };
430470
} else if (this.page == 3) {
431471
if (this.oidcStarted) {
432-
this.oidcURL = this.url + 'v1/auth/oidc/oidc/auth_url';
472+
this.oidcURL = this.url + 'v1/auth/' + this.oidcMountPath + '/oidc/auth_url';
433473
this.oidcBody = {"redirect_uri": "http://localhost:8250/oidc/callback", "role": this.role}
434474
this.header = {"X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace};
435475
this.loading = true;
@@ -585,7 +625,7 @@
585625
},
586626
_oidcAuth: function(data) {
587627
this.authMethod = 'GET';
588-
this.authURL = this.url + 'v1/auth/oidc/oidc/callback?code=' + data.code + '&state=' + data.state;
628+
this.authURL = this.url + 'v1/auth/' + this.oidcMountPath + '/oidc/callback?code=' + data.code + '&state=' + data.state;
589629
this.body = '';
590630
this.header = {"X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace};
591631
this.push('authRequests', this.$.testReq.generateRequest());
@@ -622,6 +662,10 @@
622662
},
623663
_watchNamespace: function() {
624664
this.namespaceLabel = (this.namespace) ? this.namespace : 'None'
665+
},
666+
_setMountPath: function(unused, id) {
667+
// 'unused' variable is passed here to trigger updating this function on page changes
668+
return id == this.page;
625669
}
626670
});
627671
})();

0 commit comments

Comments
 (0)