|
129 | 129 | </paper-listbox>
|
130 | 130 | <paper-item on-tap="_stop" style="border-top: 1px solid #DDD;">
|
131 | 131 | <paper-input label="New URL" id="newURL" value="{{newURL}}" always-float-label>
|
132 |
| -<div id="urlPrefix" prefix>https://</div> |
133 | 132 | <paper-icon-button suffix on-tap="_addURL" icon="add" alt="add" title="add"></paper-icon-button>
|
134 | 133 | </paper-input>
|
135 | 134 | <iron-a11y-keys target="[[targetNewURL]]" keys="enter" on-keys-pressed="_addURL"></iron-a11y-keys>
|
|
171 | 170 | </paper-toast>
|
172 | 171 | <paper-toast id="warningtoast" class="fit-bottom" duration="0">
|
173 | 172 | <iron-icon prefix icon="error-outline" style="padding-right: 7px;"></iron-icon>
|
174 |
| -An HTTPS based URL is required. |
| 173 | +Caution! Connecting to Vault over unencrypted HTTP may expose secrets! |
175 | 174 | </paper-toast>
|
176 | 175 | </template>
|
177 | 176 |
|
|
239 | 238 | },
|
240 | 239 | newURL: {
|
241 | 240 | type: String,
|
242 |
| -value: '', |
243 |
| -observer: '_watchNewURL' |
| 241 | +value: '' |
244 | 242 | },
|
245 | 243 | header: {
|
246 | 244 | type: Object,
|
|
290 | 288 | return this.url + 'v1/auth/ldap/login/' + u
|
291 | 289 | },
|
292 | 290 | _login: function() {
|
293 |
| -if (this.url.toLowerCase().startsWith('https') || this.url.toLowerCase().startsWith('http://127.0.0.1:')) { |
294 | 291 | // Switch for LDAP, Token, and UserPass auth backends
|
295 | 292 | if (this.page == 0) {
|
296 | 293 | if (!this.username && !this.password) { //Check fields have content
|
|
326 | 323 | }
|
327 | 324 | this.loading = true;
|
328 | 325 | this.push('authRequests', this.$.testReq.generateRequest());
|
329 |
| -} else { |
330 |
| -this.errorText = 'An HTTPS based URL is required.'; |
331 |
| -this.$.errortoast.show(); |
332 |
| -this.loading = false; |
333 |
| -} |
334 | 326 | },
|
335 | 327 | _success: function() {
|
336 | 328 | this.$.errortoast.close()
|
|
415 | 407 | }
|
416 | 408 | },
|
417 | 409 | _testError: function() {
|
418 |
| -this.errorText = 'No supported Vault instance found at the this URL'; |
| 410 | +this.errorText = 'An error occurred while connecting to the provided URL.'; |
419 | 411 | this.$.errortoast.show();
|
420 | 412 | this.approvedURL = false;
|
421 | 413 | this.loading = false;
|
|
426 | 418 | },
|
427 | 419 | _watchURL: function() {
|
428 | 420 | if (!(this.url.endsWith('/'))) this.url += '/';
|
429 |
| -if (this.url.toLowerCase().startsWith('http://localhost:')) this.url = this.url.replace('http://localhost:' ,'http://127.0.0.1:'); |
430 | 421 | this.debounce('checkURL', function () {
|
431 |
| -if (this.url.toLowerCase().startsWith('https://') || this.url.toLowerCase().startsWith('http://127.0.0.1:')) { |
| 422 | +if (this.url.toLowerCase().startsWith('https://') || |
| 423 | +this.url.toLowerCase().startsWith('http://127.0.0.1:') || |
| 424 | +this.url.toLowerCase().startsWith('http://localhost:')) { |
432 | 425 | this.$.warningtoast.close();
|
433 |
| -this.testURL = this.url + 'v1/sys/seal-status'; |
434 |
| -this.$.testReq.generateRequest(); |
435 | 426 | } else {
|
436 | 427 | this.$.warningtoast.show();
|
437 | 428 | }
|
| 429 | +this.testURL = this.url + 'v1/sys/seal-status'; |
| 430 | +this.$.testReq.generateRequest(); |
438 | 431 | }, 400);
|
439 | 432 | },
|
440 |
| -_watchNewURL: function() { |
441 |
| -if (this.newURL == '') return; |
442 |
| -if (this.newURL.toLowerCase().startsWith('localhost:')) this.newURL = this.newURL.replace('localhost:' ,'127.0.0.1:'); |
443 |
| -if (this.newURL.toLowerCase().startsWith('127.0.0.1:')) this.$.urlPrefix.innerText = 'http://'; |
444 |
| -else this.$.urlPrefix.innerText = 'https://'; |
445 |
| -}, |
446 | 433 | _addURL: function() {
|
447 | 434 | if (this.newURL == '') return;
|
448 |
| -var url = (this.newURL.toLowerCase().startsWith('127.0.0.1:')) ? 'http://' + this.newURL : 'https://' + this.newURL; |
449 |
| -if (!url.endsWith('/')) url += '/'; |
| 435 | +else if (!(this.newURL.toLowerCase().startsWith('http://') || this.newURL.toLowerCase().startsWith('https://'))) { |
| 436 | +this.errorText = 'URL must start with either "http://" or "https://".'; |
| 437 | +this.$.errortoast.show(); |
| 438 | +return |
| 439 | +} |
| 440 | +if (!this.newURL.endsWith('/')) this.newURL += '/'; |
450 | 441 | if (!this.urls) this.urls = [];
|
451 |
| -this.push('urls', url); |
| 442 | +this.push('urls', this.newURL); |
452 | 443 | this.newURL = '';
|
453 |
| -this.$.urlPrefix.innerText = 'https://'; |
454 | 444 | },
|
455 | 445 | _clearItem: function(e) {
|
456 | 446 | event.stopPropagation();
|
|
0 commit comments