Added token based authentication type
User can choose Bearer Token authentication type to access apis protected with access/id token.
This commit is contained in:
@@ -153,6 +153,7 @@
|
|||||||
<select v-model="auth">
|
<select v-model="auth">
|
||||||
<option>None</option>
|
<option>None</option>
|
||||||
<option>Basic</option>
|
<option>Basic</option>
|
||||||
|
<option>Bearer Token</option>
|
||||||
</select>
|
</select>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -166,6 +167,12 @@
|
|||||||
<input v-model="httpPassword" type="password">
|
<input v-model="httpPassword" type="password">
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<ul v-if="auth === 'Bearer Token'">
|
||||||
|
<li>
|
||||||
|
<label for="bearer_token">Token</label>
|
||||||
|
<input v-model="bearerToken">
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="parameters hidden">
|
<fieldset class="parameters hidden">
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const app = new Vue({
|
|||||||
path: '/api',
|
path: '/api',
|
||||||
httpUser: '',
|
httpUser: '',
|
||||||
httpPassword: '',
|
httpPassword: '',
|
||||||
|
bearerToken: '',
|
||||||
params: [],
|
params: [],
|
||||||
bodyParams: [],
|
bodyParams: [],
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
@@ -133,6 +134,9 @@ const app = new Vue({
|
|||||||
const user = this.auth === 'Basic' ? this.httpUser : null
|
const user = this.auth === 'Basic' ? this.httpUser : null
|
||||||
const pswd = this.auth === 'Basic' ? this.httpPassword : null
|
const pswd = this.auth === 'Basic' ? this.httpPassword : null
|
||||||
xhr.open(this.method, this.url + this.path + this.queryString, true, user, pswd)
|
xhr.open(this.method, this.url + this.path + this.queryString, true, user, pswd)
|
||||||
|
if (this.auth === 'Bearer Token') {
|
||||||
|
xhr.setRequestHeader('Authorization', 'Bearer ' + this.bearerToken);
|
||||||
|
}
|
||||||
if (this.method === 'POST' || this.method === 'PUT') {
|
if (this.method === 'POST' || this.method === 'PUT') {
|
||||||
const requestBody = this.rawRequestBody
|
const requestBody = this.rawRequestBody
|
||||||
xhr.setRequestHeader('Content-Length', requestBody.length)
|
xhr.setRequestHeader('Content-Length', requestBody.length)
|
||||||
|
|||||||
Reference in New Issue
Block a user