added token request management
This commit is contained in:
@@ -94,7 +94,11 @@ export default {
|
|||||||
save_token: "Save Access Token",
|
save_token: "Save Access Token",
|
||||||
use_token: "Use Saved Token",
|
use_token: "Use Saved Token",
|
||||||
request_token: "Request Token",
|
request_token: "Request Token",
|
||||||
save_token_request: "Save Token Request",
|
save_token_req: "Save Token Request",
|
||||||
|
manage_token_req: "Manage Token Request",
|
||||||
|
use_token_req: "Use Token Request",
|
||||||
|
token_req_name: "Request Name",
|
||||||
|
token_req_details: "Request Details",
|
||||||
token_name: "Token Name",
|
token_name: "Token Name",
|
||||||
oidc_discovery_url: "OIDC Discovery URL",
|
oidc_discovery_url: "OIDC Discovery URL",
|
||||||
auth_url: "Auth URL",
|
auth_url: "Auth URL",
|
||||||
@@ -102,4 +106,5 @@ export default {
|
|||||||
client_id: "Client ID",
|
client_id: "Client ID",
|
||||||
scope: "Scope",
|
scope: "Scope",
|
||||||
state: "State",
|
state: "State",
|
||||||
|
token_req_list: "Token Request List"
|
||||||
};
|
};
|
||||||
|
|||||||
209
pages/index.vue
209
pages/index.vue
@@ -436,7 +436,7 @@
|
|||||||
<button
|
<button
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="showTokenRequestList = true"
|
@click="showTokenRequestList = true"
|
||||||
v-tooltip.bottom="$t('save_token_request')"
|
v-tooltip.bottom="$t('manage_token_req')"
|
||||||
>
|
>
|
||||||
<i class="material-icons">library_add</i>
|
<i class="material-icons">library_add</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -939,46 +939,6 @@
|
|||||||
<div slot="footer"></div>
|
<div slot="footer"></div>
|
||||||
</pw-modal>
|
</pw-modal>
|
||||||
|
|
||||||
<pw-modal v-if="showTokenRequestList" @close="showTokenRequestList = false">
|
|
||||||
<div slot="header">
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<div class="flex-wrap">
|
|
||||||
<h3 class="title">{{ $t("save_token_request") }}</h3>
|
|
||||||
<div>
|
|
||||||
<button class="icon" @click="showTokenRequestList = false">
|
|
||||||
<i class="material-icons">close</i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div slot="body">
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<textarea
|
|
||||||
rows="8"
|
|
||||||
placeholder="Enter request list"
|
|
||||||
></textarea>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div slot="footer">
|
|
||||||
<div class="flex-wrap">
|
|
||||||
<span></span>
|
|
||||||
<span>
|
|
||||||
<button class="icon" @click="showTokenRequestList = false">
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
<button class="icon primary" @click="saveTokenRequest">
|
|
||||||
{{ $t("save_token_request") }}
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</pw-modal>
|
|
||||||
|
|
||||||
<pw-modal v-if="showTokenList" @close="showTokenList = false">
|
<pw-modal v-if="showTokenList" @close="showTokenList = false">
|
||||||
<div slot="header">
|
<div slot="header">
|
||||||
<ul>
|
<ul>
|
||||||
@@ -994,7 +954,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div slot="body" ref="tokens">
|
<div slot="body">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<div class="flex-wrap">
|
<div class="flex-wrap">
|
||||||
@@ -1051,6 +1011,91 @@
|
|||||||
</div>
|
</div>
|
||||||
<div slot="footer"></div>
|
<div slot="footer"></div>
|
||||||
</pw-modal>
|
</pw-modal>
|
||||||
|
|
||||||
|
<pw-modal v-if="showTokenRequestList" @close="showTokenRequestList = false">
|
||||||
|
<div slot="header">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<div class="flex-wrap">
|
||||||
|
<h3 class="title">{{ $t("manage_token_req") }}</h3>
|
||||||
|
<div>
|
||||||
|
<button class="icon" @click="showTokenRequestList = false">
|
||||||
|
<i class="material-icons">close</i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div slot="body">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<div class="flex-wrap">
|
||||||
|
<label for="token-req-list">{{ $t("token_req_list") }}</label>
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
:disabled="this.tokenReqs.length === 0"
|
||||||
|
class="icon"
|
||||||
|
@click="showTokenRequestList = false"
|
||||||
|
v-tooltip.bottom="$t('use_token_req')"
|
||||||
|
>
|
||||||
|
<i class="material-icons">input</i>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:disabled="this.tokenReqs.length === 0"
|
||||||
|
class="icon"
|
||||||
|
@click="removeOAuthTokenReq"
|
||||||
|
>
|
||||||
|
<i class="material-icons">delete</i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="select-wrapper">
|
||||||
|
<select
|
||||||
|
id="token-req-list"
|
||||||
|
v-model="tokenReqSelect"
|
||||||
|
:disabled="this.tokenReqs.length === 0"
|
||||||
|
@change="tokenReqChange($event)">
|
||||||
|
<option
|
||||||
|
v-for="(req, index) in tokenReqs"
|
||||||
|
:key="index"
|
||||||
|
:value="req.name">
|
||||||
|
{{ req.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<label for="token-req-name">{{ $t("token_req_name") }}</label>
|
||||||
|
<input v-model="tokenReqName">
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<label for="token-req-details">{{ $t("token_req_details") }}</label>
|
||||||
|
<textarea
|
||||||
|
id="token-req-details"
|
||||||
|
readonly
|
||||||
|
rows="7"
|
||||||
|
v-model="tokenReqDetails"
|
||||||
|
></textarea>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div slot="footer">
|
||||||
|
<div class="flex-wrap">
|
||||||
|
<span></span>
|
||||||
|
<span>
|
||||||
|
<button class="icon primary" @click="addOAuthTokenReq">
|
||||||
|
{{ $t("save_token_req") }}
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</pw-modal>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -1466,6 +1511,30 @@ export default {
|
|||||||
this.$store.commit("setOAuth2", { value, attribute: "tokens" });
|
this.$store.commit("setOAuth2", { value, attribute: "tokens" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
tokenReqs: {
|
||||||
|
get() {
|
||||||
|
return this.$store.state.oauth2.tokenReqs;
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
this.$store.commit("setOAuth2", { value, attribute: "tokenReqs" });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tokenReqSelect: {
|
||||||
|
get() {
|
||||||
|
return this.$store.state.oauth2.tokenReqSelect;
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
this.$store.commit("setOAuth2", { value, attribute: "tokenReqSelect" });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tokenReqName: {
|
||||||
|
get() {
|
||||||
|
return this.$store.state.oauth2.tokenReqName;
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
this.$store.commit("setOAuth2", { value, attribute: "tokenReqName" });
|
||||||
|
}
|
||||||
|
},
|
||||||
accessTokenName: {
|
accessTokenName: {
|
||||||
get() {
|
get() {
|
||||||
return this.$store.state.oauth2.accessTokenName;
|
return this.$store.state.oauth2.accessTokenName;
|
||||||
@@ -1812,6 +1881,16 @@ export default {
|
|||||||
}
|
}
|
||||||
return requestString.join("").slice(0, -3);
|
return requestString.join("").slice(0, -3);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
tokenReqDetails() {
|
||||||
|
const details = {
|
||||||
|
oidcDiscoveryUrl: this.oidcDiscoveryUrl,
|
||||||
|
authUrl: this.authUrl,
|
||||||
|
accessTokenUrl: this.accessTokenUrl,
|
||||||
|
clientId: this.clientId,
|
||||||
|
scope: this.scope
|
||||||
|
};
|
||||||
|
return JSON.stringify(details, null, 2);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -2361,6 +2440,7 @@ export default {
|
|||||||
this.bearerToken = "";
|
this.bearerToken = "";
|
||||||
this.showTokenRequest = false;
|
this.showTokenRequest = false;
|
||||||
this.tokens = [];
|
this.tokens = [];
|
||||||
|
this.tokenReqs = [];
|
||||||
break;
|
break;
|
||||||
case "headers":
|
case "headers":
|
||||||
this.headers = [];
|
this.headers = [];
|
||||||
@@ -2379,6 +2459,8 @@ export default {
|
|||||||
case "tokens":
|
case "tokens":
|
||||||
this.tokens = [];
|
this.tokens = [];
|
||||||
break;
|
break;
|
||||||
|
case "tokenReqs":
|
||||||
|
this.tokenReqs = [];
|
||||||
default:
|
default:
|
||||||
(this.label = ""),
|
(this.label = ""),
|
||||||
(this.method = "GET"),
|
(this.method = "GET"),
|
||||||
@@ -2395,6 +2477,7 @@ export default {
|
|||||||
this.rawParams = "";
|
this.rawParams = "";
|
||||||
this.showTokenRequest = false;
|
this.showTokenRequest = false;
|
||||||
this.tokens = [];
|
this.tokens = [];
|
||||||
|
this.tokenReqs = [];
|
||||||
this.accessTokenName = "";
|
this.accessTokenName = "";
|
||||||
this.oidcDiscoveryUrl = "";
|
this.oidcDiscoveryUrl = "";
|
||||||
this.authUrl = "";
|
this.authUrl = "";
|
||||||
@@ -2527,9 +2610,7 @@ export default {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
removeOAuthToken(index) {
|
removeOAuthToken(index) {
|
||||||
// .slice() gives us an entirely new array rather than giving us just the reference
|
|
||||||
const oldTokens = this.tokens.slice();
|
const oldTokens = this.tokens.slice();
|
||||||
|
|
||||||
this.$store.commit("removeOAuthToken", index);
|
this.$store.commit("removeOAuthToken", index);
|
||||||
this.$toast.error("Deleted", {
|
this.$toast.error("Deleted", {
|
||||||
icon: "delete",
|
icon: "delete",
|
||||||
@@ -2546,8 +2627,14 @@ export default {
|
|||||||
this.bearerToken = value;
|
this.bearerToken = value;
|
||||||
this.showTokenList = false;
|
this.showTokenList = false;
|
||||||
},
|
},
|
||||||
saveTokenRequest() {
|
addOAuthTokenReq() {
|
||||||
try {
|
try {
|
||||||
|
const name = this.tokenReqName;
|
||||||
|
const details = JSON.parse(this.tokenReqDetails);
|
||||||
|
this.$store.commit("addOAuthTokenReq", {
|
||||||
|
name,
|
||||||
|
details
|
||||||
|
});
|
||||||
this.$toast.info("Token request saved");
|
this.$toast.info("Token request saved");
|
||||||
this.showTokenRequestList = false;
|
this.showTokenRequestList = false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -2555,6 +2642,38 @@ export default {
|
|||||||
icon: "code"
|
icon: "code"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
removeOAuthTokenReq(index) {
|
||||||
|
const oldTokenReqs = this.tokenReqs.slice();
|
||||||
|
let targetReqIndex = this.tokenReqs.findIndex(tokenReq => tokenReq.name === this.tokenReqName);
|
||||||
|
if (targetReqIndex < 0) return;
|
||||||
|
this.$store.commit("removeOAuthTokenReq", targetReqIndex);
|
||||||
|
this.$toast.error("Deleted", {
|
||||||
|
icon: "delete",
|
||||||
|
action: {
|
||||||
|
text: "Undo",
|
||||||
|
onClick: (e, toastObject) => {
|
||||||
|
this.tokenReqs = oldTokenReqs;
|
||||||
|
toastObject.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
tokenReqChange(event) {
|
||||||
|
let targetReq = this.tokenReqs.find(tokenReq => tokenReq.name === event.target.value);
|
||||||
|
let {
|
||||||
|
oidcDiscoveryUrl,
|
||||||
|
authUrl,
|
||||||
|
accessTokenUrl,
|
||||||
|
clientId,
|
||||||
|
scope
|
||||||
|
} = targetReq.details;
|
||||||
|
this.tokenReqName = targetReq.name;
|
||||||
|
this.oidcDiscoveryUrl = oidcDiscoveryUrl;
|
||||||
|
this.authUrl = authUrl;
|
||||||
|
this.accessTokenUrl = accessTokenUrl;
|
||||||
|
this.clientId = clientId;
|
||||||
|
this.scope = scope;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
|
|||||||
@@ -101,6 +101,13 @@ export default {
|
|||||||
|
|
||||||
setOAuthTokenName({ oauth2 }, { index, value }) {
|
setOAuthTokenName({ oauth2 }, { index, value }) {
|
||||||
oauth2.tokens[index].name = value;
|
oauth2.tokens[index].name = value;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
addOAuthTokenReq({ oauth2 }, value) {
|
||||||
|
oauth2.tokenReqs.push(value);
|
||||||
|
},
|
||||||
|
|
||||||
|
removeOAuthTokenReq({ oauth2 }, index) {
|
||||||
|
oauth2.tokenReqs.splice(index, 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ export default () => ({
|
|||||||
},
|
},
|
||||||
oauth2: {
|
oauth2: {
|
||||||
tokens: [],
|
tokens: [],
|
||||||
|
tokenReqs: [],
|
||||||
|
tokenReqSelect: "",
|
||||||
|
tokenReqName: "",
|
||||||
accessTokenName: "",
|
accessTokenName: "",
|
||||||
oidcDiscoveryUrl: "",
|
oidcDiscoveryUrl: "",
|
||||||
authUrl: "",
|
authUrl: "",
|
||||||
|
|||||||
Reference in New Issue
Block a user