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

Commit 8273451

Browse files
authored
Caution against HTTP, but do not prevent its use (#48)
* Caution against HTTP, but do not prevent its use * Language
1 parent f0933f8 commit 8273451

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

app/elements/login-form.html

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
</paper-listbox>
130130
<paper-item on-tap="_stop" style="border-top: 1px solid #DDD;">
131131
<paper-input label="New URL" id="newURL" value="{{newURL}}" always-float-label>
132-
<div id="urlPrefix" prefix>https://</div>
133132
<paper-icon-button suffix on-tap="_addURL" icon="add" alt="add" title="add"></paper-icon-button>
134133
</paper-input>
135134
<iron-a11y-keys target="[[targetNewURL]]" keys="enter" on-keys-pressed="_addURL"></iron-a11y-keys>
@@ -171,7 +170,7 @@
171170
</paper-toast>
172171
<paper-toast id="warningtoast" class="fit-bottom" duration="0">
173172
<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!
175174
</paper-toast>
176175
</template>
177176

@@ -239,8 +238,7 @@
239238
},
240239
newURL: {
241240
type: String,
242-
value: '',
243-
observer: '_watchNewURL'
241+
value: ''
244242
},
245243
header: {
246244
type: Object,
@@ -290,7 +288,6 @@
290288
return this.url + 'v1/auth/ldap/login/' + u
291289
},
292290
_login: function() {
293-
if (this.url.toLowerCase().startsWith('https') || this.url.toLowerCase().startsWith('http://127.0.0.1:')) {
294291
// Switch for LDAP, Token, and UserPass auth backends
295292
if (this.page == 0) {
296293
if (!this.username && !this.password) { //Check fields have content
@@ -326,11 +323,6 @@
326323
}
327324
this.loading = true;
328325
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-
}
334326
},
335327
_success: function() {
336328
this.$.errortoast.close()
@@ -415,7 +407,7 @@
415407
}
416408
},
417409
_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.';
419411
this.$.errortoast.show();
420412
this.approvedURL = false;
421413
this.loading = false;
@@ -426,31 +418,29 @@
426418
},
427419
_watchURL: function() {
428420
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:');
430421
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:')) {
432425
this.$.warningtoast.close();
433-
this.testURL = this.url + 'v1/sys/seal-status';
434-
this.$.testReq.generateRequest();
435426
} else {
436427
this.$.warningtoast.show();
437428
}
429+
this.testURL = this.url + 'v1/sys/seal-status';
430+
this.$.testReq.generateRequest();
438431
}, 400);
439432
},
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-
},
446433
_addURL: function() {
447434
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 += '/';
450441
if (!this.urls) this.urls = [];
451-
this.push('urls', url);
442+
this.push('urls', this.newURL);
452443
this.newURL = '';
453-
this.$.urlPrefix.innerText = 'https://';
454444
},
455445
_clearItem: function(e) {
456446
event.stopPropagation();

0 commit comments

Comments
 (0)