|
73 | 73 | paper-progress.bottombar {
|
74 | 74 | --paper-progress-container-color: rgba(#ffffff, 0);
|
75 | 75 | }
|
| 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 | +} |
76 | 86 | </style>
|
77 | 87 |
|
78 | 88 | <iron-ajax id="authenticateReq"
|
|
94 | 104 | handle-as="json"
|
95 | 105 | method="POST"
|
96 | 106 | body="{{oidcBody}}"
|
| 107 | +headers="{{header}}" |
97 | 108 | content-type="application/json"
|
98 | 109 | last-response="{{oidcResponse}}"
|
99 | 110 | last-error={{loginError}}
|
|
167 | 178 | <paper-input id="userfield" value="{{username}}" label="Username" disabled="{{loading}}"></paper-input>
|
168 | 179 | <paper-input id="passfield" value="{{password}}" label="Password" type="password" disabled="{{loading}}"></paper-input>
|
169 | 180 | </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> |
174 | 181 | </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> |
175 | 197 | <div class="buttons">
|
176 | 198 | <paper-button on-tap="_login" autofocus disabled="{{loading}}">Login</paper-button>
|
177 | 199 | </div>
|
|
181 | 203 | <app-localstorage-document key="page" data="{{page}}"></app-localstorage-document>
|
182 | 204 | <app-localstorage-document key="urls" data="{{urls}}"></app-localstorage-document>
|
183 | 205 | <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> |
184 | 208 |
|
185 | 209 | <paper-toast id="errortoast" class="fit-bottom error" duration="5000">
|
186 | 210 | <iron-icon prefix icon="error-outline" style="padding-right: 7px;"></iron-icon>
|
|
242 | 266 | type: String,
|
243 | 267 | value: ''
|
244 | 268 | },
|
| 269 | +roleVisible: { |
| 270 | +type: Boolean, |
| 271 | +value: false |
| 272 | +}, |
245 | 273 | backends: {
|
246 | 274 | type: Array,
|
247 | 275 | value: [],
|
|
281 | 309 | type: Object,
|
282 | 310 | notify: true
|
283 | 311 | },
|
| 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 | +}, |
284 | 331 | page: {
|
285 | 332 | type: Number,
|
286 | 333 | value: 0,
|
|
327 | 374 | _autofocus: function() {
|
328 | 375 | // Close OIDC alert on all pages. Open selectively as needed.
|
329 | 376 | this.$.oidctoast.close();
|
| 377 | +this.roleVisible = false; |
330 | 378 |
|
331 | 379 | // Set cursor autofocus for login/password fields
|
332 | 380 | // TODO: autofocus on username field first if unset
|
333 | 381 | if (this.page === 1) this.$.tokenfield.autofocus = true;
|
334 | 382 | else if (this.page === 0) this.$.passfieldldap.autofocus = true;
|
335 | 383 | else if (this.page === 2) this.$.passfield.autofocus = true;
|
336 | 384 | else if (this.page === 3) {
|
337 |
| -this.$.rolefield.autofocus = true; |
| 385 | +this.roleVisible = true; |
338 | 386 | if (!(this.oidcStarted)) this.$.oidctoast.open();
|
339 | 387 | }
|
340 | 388 | },
|
|
354 | 402 | return;
|
355 | 403 | }
|
356 | 404 | this.authMethod = 'POST';
|
| 405 | +this.header = {"X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace}; |
357 | 406 | this.authURL = this.url + 'v1/auth/ldap/login/' + this.username;
|
358 | 407 | this.body = {"password": this.password };
|
359 | 408 | } else if (this.page == 1) {
|
|
365 | 414 | }
|
366 | 415 | this.authMethod = 'GET';
|
367 | 416 | 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 }; |
369 | 418 | this.body = '';
|
370 | 419 | } else if (this.page == 2) {
|
371 | 420 | if (!this.username && !this.password) { //Check fields have content
|
|
376 | 425 | }
|
377 | 426 | this.authMethod = 'POST';
|
378 | 427 | this.authURL = this.url + 'v1/auth/userpass/login/' + this.username;
|
| 428 | +this.header = {"X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace}; |
379 | 429 | this.body = {"password": this.password };
|
380 | 430 | } else if (this.page == 3) {
|
381 | 431 | 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'; |
383 | 433 | 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}; |
384 | 435 | this.loading = true;
|
385 | 436 | this.$.oidcReq.generateRequest();
|
386 | 437 | } else {
|
|
399 | 450 | // UserPass / LDAP
|
400 | 451 | if (this.loginResponse.auth && this.loginResponse.auth.client_token) {
|
401 | 452 | 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 }; |
403 | 454 | // Token Auth
|
404 | 455 | } else if (this.loginResponse.data) {
|
405 | 456 | this.loginResponse = this.loginResponse.data;
|
|
536 | 587 | this.authMethod = 'GET';
|
537 | 588 | this.authURL = this.url + 'v1/auth/oidc/oidc/callback?code=' + data.code + '&state=' + data.state;
|
538 | 589 | this.body = '';
|
539 |
| -this.header = ''; |
| 590 | +this.header = {"X-Cryptr-Version": app.cryptrVersion, "X-Vault-Namespace": this.namespace}; |
540 | 591 | this.push('authRequests', this.$.testReq.generateRequest());
|
541 | 592 | },
|
542 | 593 | _oidcAuthError: function(data) {
|
|
558 | 609 | this.$.authenticateReq.generateRequest();
|
559 | 610 | this.authRequests = [];
|
560 | 611 | }
|
| 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' |
561 | 625 | }
|
562 | 626 | });
|
563 | 627 | })();
|
|
0 commit comments