Added token management
This commit is contained in:
@@ -88,6 +88,7 @@ export default {
|
|||||||
start: "Start",
|
start: "Start",
|
||||||
stop: "Stop",
|
stop: "Stop",
|
||||||
access_token: "Access Token",
|
access_token: "Access Token",
|
||||||
|
token_list: "Token List",
|
||||||
get_token: "Get New Token",
|
get_token: "Get New Token",
|
||||||
manage_token: "Manage Access Token",
|
manage_token: "Manage Access Token",
|
||||||
save_token: "Save Access Token",
|
save_token: "Save Access Token",
|
||||||
|
|||||||
104
pages/index.vue
104
pages/index.vue
@@ -400,7 +400,7 @@
|
|||||||
@click="showTokenList = !showTokenList"
|
@click="showTokenList = !showTokenList"
|
||||||
v-tooltip.bottom="$t('use_token')"
|
v-tooltip.bottom="$t('use_token')"
|
||||||
>
|
>
|
||||||
<i class="material-icons">input</i>
|
<i class="material-icons">open_in_new</i>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
v-if="auth === 'OAuth 2.0'"
|
v-if="auth === 'OAuth 2.0'"
|
||||||
@@ -995,7 +995,23 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div slot="body" ref="tokens">
|
<div slot="body" ref="tokens">
|
||||||
<ul v-for="(token, index) in tokens" :key="index">
|
<ul>
|
||||||
|
<li>
|
||||||
|
<div class="flex-wrap">
|
||||||
|
<label for="token-list">{{ $t("token_list") }}</label>
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
class="icon"
|
||||||
|
@click="clearContent('tokens', $event)"
|
||||||
|
v-tooltip.bottom="'Clear'"
|
||||||
|
>
|
||||||
|
<i class="material-icons">clear_all</i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul id="token-list" v-for="(token, index) in tokens" :key="index">
|
||||||
<li>
|
<li>
|
||||||
<input
|
<input
|
||||||
:placeholder="'name ' + (index + 1)"
|
:placeholder="'name ' + (index + 1)"
|
||||||
@@ -1009,51 +1025,31 @@
|
|||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input
|
<input :value="token.value" readonly>
|
||||||
:placeholder="'value ' + (index + 1)"
|
|
||||||
:name="'value' + index"
|
|
||||||
:value="token.value"
|
|
||||||
@change="
|
|
||||||
$store.commit('setOAuthTokenValue', {
|
|
||||||
index,
|
|
||||||
value: $event.target.value
|
|
||||||
})
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</li>
|
</li>
|
||||||
<div>
|
<div class="flex-wrap">
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
class="icon"
|
||||||
|
@click="useOAuthToken(token.value)"
|
||||||
|
v-tooltip.bottom="$t('use_token')"
|
||||||
|
>
|
||||||
|
<i class="material-icons">input</i>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="removeOAuthToken(index)"
|
@click="removeOAuthToken(index)"
|
||||||
|
v-tooltip.bottom="'Delete'"
|
||||||
>
|
>
|
||||||
<i class="material-icons">delete</i>
|
<i class="material-icons">delete</i>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<button class="icon" @click="addOAuthToken">
|
|
||||||
<i class="material-icons">add</i>
|
|
||||||
<span>{{ $t("add_new") }}</span>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div slot="footer">
|
|
||||||
<div class="flex-wrap">
|
|
||||||
<span></span>
|
|
||||||
<span>
|
|
||||||
<button class="icon" @click="showTokenList = false">
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
<button class="icon primary" @click="saveToken">
|
|
||||||
{{ $t("save_token") }}
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div slot="footer"></div>
|
||||||
</pw-modal>
|
</pw-modal>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -2364,6 +2360,7 @@ export default {
|
|||||||
this.httpPassword = "";
|
this.httpPassword = "";
|
||||||
this.bearerToken = "";
|
this.bearerToken = "";
|
||||||
this.showTokenRequest = false;
|
this.showTokenRequest = false;
|
||||||
|
this.tokens = [];
|
||||||
break;
|
break;
|
||||||
case "headers":
|
case "headers":
|
||||||
this.headers = [];
|
this.headers = [];
|
||||||
@@ -2379,6 +2376,9 @@ export default {
|
|||||||
this.clientId = "";
|
this.clientId = "";
|
||||||
this.scope = "";
|
this.scope = "";
|
||||||
break;
|
break;
|
||||||
|
case "tokens":
|
||||||
|
this.tokens = [];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
(this.label = ""),
|
(this.label = ""),
|
||||||
(this.method = "GET"),
|
(this.method = "GET"),
|
||||||
@@ -2393,6 +2393,14 @@ export default {
|
|||||||
this.params = [];
|
this.params = [];
|
||||||
this.bodyParams = [];
|
this.bodyParams = [];
|
||||||
this.rawParams = "";
|
this.rawParams = "";
|
||||||
|
this.showTokenRequest = false;
|
||||||
|
this.tokens = [];
|
||||||
|
this.accessTokenName = "";
|
||||||
|
this.oidcDiscoveryUrl = "";
|
||||||
|
this.authUrl = "";
|
||||||
|
this.accessTokenUrl = "";
|
||||||
|
this.clientId = "";
|
||||||
|
this.scope = "";
|
||||||
}
|
}
|
||||||
e.target.innerHTML = this.doneButton;
|
e.target.innerHTML = this.doneButton;
|
||||||
this.$toast.info("Cleared", {
|
this.$toast.info("Cleared", {
|
||||||
@@ -2478,7 +2486,7 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async handleAccessTokenRequest(){
|
async handleAccessTokenRequest() {
|
||||||
if (this.oidcDiscoveryUrl === "" && (this.authUrl === "" || this.accessTokenUrl === "")) {
|
if (this.oidcDiscoveryUrl === "" && (this.authUrl === "" || this.accessTokenUrl === "")) {
|
||||||
this.$toast.error("Please complete configuration urls.", {
|
this.$toast.error("Please complete configuration urls.", {
|
||||||
icon: "error"
|
icon: "error"
|
||||||
@@ -2505,12 +2513,16 @@ export default {
|
|||||||
let tokenInfo = await oauthRedirect();
|
let tokenInfo = await oauthRedirect();
|
||||||
if(tokenInfo.hasOwnProperty('access_token')) {
|
if(tokenInfo.hasOwnProperty('access_token')) {
|
||||||
this.bearerToken = tokenInfo.access_token;
|
this.bearerToken = tokenInfo.access_token;
|
||||||
|
this.addOAuthToken({
|
||||||
|
name: this.accessTokenName,
|
||||||
|
value: tokenInfo.access_token
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addOAuthToken() {
|
addOAuthToken({name, value}) {
|
||||||
this.$store.commit("addOAuthToken", {
|
this.$store.commit("addOAuthToken", {
|
||||||
name: "",
|
name,
|
||||||
value: ""
|
value
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@@ -2530,17 +2542,11 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveToken(){
|
useOAuthToken(value) {
|
||||||
try {
|
this.bearerToken = value;
|
||||||
this.$toast.info("Access token saved");
|
this.showTokenList = false;
|
||||||
this.showTokenList = false;
|
|
||||||
} catch (e) {
|
|
||||||
this.$toast.error(e, {
|
|
||||||
icon: "code"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
saveTokenRequest(){
|
saveTokenRequest() {
|
||||||
try {
|
try {
|
||||||
this.$toast.info("Token request saved");
|
this.$toast.info("Token request saved");
|
||||||
this.showTokenRequestList = false;
|
this.showTokenRequestList = false;
|
||||||
|
|||||||
@@ -101,10 +101,6 @@ export default {
|
|||||||
|
|
||||||
setOAuthTokenName({ oauth2 }, { index, value }) {
|
setOAuthTokenName({ oauth2 }, { index, value }) {
|
||||||
oauth2.tokens[index].name = value;
|
oauth2.tokens[index].name = value;
|
||||||
},
|
}
|
||||||
|
|
||||||
setOAuthTokenValue({ oauth2 }, { index, value }) {
|
|
||||||
oauth2.tokens[index].value = value;
|
|
||||||
},
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user