Get OAuth-Callback URLs from backend

This commit is contained in:
Jan Oberhauser 2020-09-30 15:50:43 +02:00
parent 6f576b3da9
commit f1680386ca
6 changed files with 26 additions and 3 deletions

View file

@ -288,6 +288,10 @@ export interface IN8nUISettings {
saveManualExecutions: boolean; saveManualExecutions: boolean;
executionTimeout: number; executionTimeout: number;
maxExecutionTimeout: number; maxExecutionTimeout: number;
oauthCallbackUrls: {
oauth1: string;
oauth2: string;
};
timezone: string; timezone: string;
urlBaseWebhook: string; urlBaseWebhook: string;
versionCli: string; versionCli: string;

View file

@ -1617,7 +1617,9 @@ class App {
// Returns the settings which are needed in the UI // Returns the settings which are needed in the UI
this.app.get(`/${this.restEndpoint}/settings`, ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<IN8nUISettings> => { this.app.get(`/${this.restEndpoint}/settings`, ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<IN8nUISettings> => {
return { const urlBaseWebhook = WebhookHelpers.getWebhookBaseUrl();
const settings: IN8nUISettings = {
endpointWebhook: this.endpointWebhook, endpointWebhook: this.endpointWebhook,
endpointWebhookTest: this.endpointWebhookTest, endpointWebhookTest: this.endpointWebhookTest,
saveDataErrorExecution: this.saveDataErrorExecution, saveDataErrorExecution: this.saveDataErrorExecution,
@ -1626,8 +1628,12 @@ class App {
executionTimeout: this.executionTimeout, executionTimeout: this.executionTimeout,
maxExecutionTimeout: this.maxExecutionTimeout, maxExecutionTimeout: this.maxExecutionTimeout,
timezone: this.timezone, timezone: this.timezone,
urlBaseWebhook: WebhookHelpers.getWebhookBaseUrl(), urlBaseWebhook,
versionCli: this.versions!.cli, versionCli: this.versions!.cli,
oauthCallbackUrls: {
'oauth1': urlBaseWebhook + `${this.restEndpoint}/oauth1-credential/callback`,
'oauth2': urlBaseWebhook + `${this.restEndpoint}/oauth2-credential/callback`,
}
}; };
})); }));

View file

@ -399,6 +399,10 @@ export interface IN8nUISettings {
timezone: string; timezone: string;
executionTimeout: number; executionTimeout: number;
maxExecutionTimeout: number; maxExecutionTimeout: number;
oauthCallbackUrls: {
oauth1: string;
oauth2: string;
};
urlBaseWebhook: string; urlBaseWebhook: string;
versionCli: string; versionCli: string;
} }

View file

@ -235,7 +235,7 @@ export default mixins(
oAuthCallbackUrl (): string { oAuthCallbackUrl (): string {
const types = this.parentTypes(this.credentialTypeData.name); const types = this.parentTypes(this.credentialTypeData.name);
const oauthType = (this.credentialTypeData.name === 'oAuth2Api' || types.includes('oAuth2Api')) ? 'oauth2' : 'oauth1'; const oauthType = (this.credentialTypeData.name === 'oAuth2Api' || types.includes('oAuth2Api')) ? 'oauth2' : 'oauth1';
return this.$store.getters.getWebhookBaseUrl + `rest/${oauthType}-credential/callback`; return this.$store.getters.oauthCallbackUrls[oauthType];
}, },
requiredPropertiesFilled (): boolean { requiredPropertiesFilled (): boolean {
for (const property of this.credentialProperties) { for (const property of this.credentialProperties) {

View file

@ -8,6 +8,7 @@ import {
IConnection, IConnection,
IConnections, IConnections,
ICredentialType, ICredentialType,
IDataObject,
INodeConnections, INodeConnections,
INodeIssueData, INodeIssueData,
INodeTypeDescription, INodeTypeDescription,
@ -55,6 +56,7 @@ export const store = new Vuex.Store({
executionTimeout: -1, executionTimeout: -1,
maxExecutionTimeout: Number.MAX_SAFE_INTEGER, maxExecutionTimeout: Number.MAX_SAFE_INTEGER,
versionCli: '0.0.0', versionCli: '0.0.0',
oauthCallbackUrls: {},
workflowExecutionData: null as IExecutionResponse | null, workflowExecutionData: null as IExecutionResponse | null,
lastSelectedNode: null as string | null, lastSelectedNode: null as string | null,
lastSelectedNodeOutputIndex: null as number | null, lastSelectedNodeOutputIndex: null as number | null,
@ -490,6 +492,9 @@ export const store = new Vuex.Store({
setVersionCli (state, version: string) { setVersionCli (state, version: string) {
Vue.set(state, 'versionCli', version); Vue.set(state, 'versionCli', version);
}, },
setOauthCallbackUrls(state, urls: IDataObject) {
Vue.set(state, 'oauthCallbackUrls', urls);
},
addNodeType (state, typeData: INodeTypeDescription) { addNodeType (state, typeData: INodeTypeDescription) {
if (!typeData.hasOwnProperty('name')) { if (!typeData.hasOwnProperty('name')) {
@ -609,6 +614,9 @@ export const store = new Vuex.Store({
versionCli: (state): string => { versionCli: (state): string => {
return state.versionCli; return state.versionCli;
}, },
oauthCallbackUrls: (state): object => {
return state.oauthCallbackUrls;
},
// Push Connection // Push Connection
pushConnectionActive: (state): boolean => { pushConnectionActive: (state): boolean => {

View file

@ -1873,6 +1873,7 @@ export default mixins(
this.$store.commit('setExecutionTimeout', settings.executionTimeout); this.$store.commit('setExecutionTimeout', settings.executionTimeout);
this.$store.commit('setMaxExecutionTimeout', settings.maxExecutionTimeout); this.$store.commit('setMaxExecutionTimeout', settings.maxExecutionTimeout);
this.$store.commit('setVersionCli', settings.versionCli); this.$store.commit('setVersionCli', settings.versionCli);
this.$store.commit('setOauthCallbackUrls', settings.oauthCallbackUrls);
}, },
async loadNodeTypes (): Promise<void> { async loadNodeTypes (): Promise<void> {
const nodeTypes = await this.restApi().getNodeTypes(); const nodeTypes = await this.restApi().getNodeTypes();