mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-24 23:22:38 +08:00
feat: Fix types, add resolver id to csrf state (#23087)
This commit is contained in:
@@ -4,7 +4,8 @@ import { Request, Response } from 'express';
|
||||
import { EnterpriseCredentialsService } from '@/credentials/credentials.service.ee';
|
||||
import { NotFoundError } from '@/errors/response-errors/not-found.error';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
import { OauthService } from '@/oauth/oauth.service';
|
||||
import { CreateCsrfStateData, OauthService } from '@/oauth/oauth.service';
|
||||
import { CredentialsEntity } from '@n8n/db';
|
||||
|
||||
@RestController('/credentials')
|
||||
export class DynamicCredentialsController {
|
||||
@@ -25,20 +26,22 @@ export class DynamicCredentialsController {
|
||||
throw new BadRequestError('Credential type not supported');
|
||||
}
|
||||
|
||||
if (credential.type.includes('OAuth2')) {
|
||||
return await this.oauthService.generateAOauth2AuthUri(credential, {
|
||||
const callerData: [CredentialsEntity, CreateCsrfStateData] = [
|
||||
credential,
|
||||
{
|
||||
cid: credential.id,
|
||||
origin: 'dynamic-credential',
|
||||
authorizationHeader: req.headers.authorization ?? '',
|
||||
});
|
||||
credentialResolverId: req.query.resolverId,
|
||||
},
|
||||
];
|
||||
|
||||
if (credential.type.includes('OAuth2')) {
|
||||
return await this.oauthService.generateAOauth2AuthUri(...callerData);
|
||||
}
|
||||
|
||||
if (credential.type.includes('OAuth1')) {
|
||||
return await this.oauthService.generateAOauth1AuthUri(credential, {
|
||||
cid: credential.id,
|
||||
origin: 'dynamic-credential',
|
||||
authorizationHeader: req.headers.authorization ?? '',
|
||||
});
|
||||
return await this.oauthService.generateAOauth1AuthUri(...callerData);
|
||||
}
|
||||
|
||||
throw new BadRequestError('Credential type not supported');
|
||||
|
||||
+5
-5
@@ -8,12 +8,12 @@ import {
|
||||
type IWorkflowSettings,
|
||||
jsonParse,
|
||||
} from 'n8n-workflow';
|
||||
import type { DynamicCredentialResolverRegistry } from './credential-resolver-registry.service';
|
||||
import type { DynamicCredentialResolverRepository } from '../database/repositories/credential-resolver.repository';
|
||||
import type { Cipher } from 'n8n-core';
|
||||
import { DynamicCredentialResolverRegistry } from './credential-resolver-registry.service';
|
||||
import { DynamicCredentialResolverRepository } from '../database/repositories/credential-resolver.repository';
|
||||
import { Cipher } from 'n8n-core';
|
||||
import { CredentialStorageError } from '../errors/credential-storage.error';
|
||||
import type { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
|
||||
import type { Logger } from '@n8n/backend-common';
|
||||
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
|
||||
import { Logger } from '@n8n/backend-common';
|
||||
import { Service } from '@n8n/di';
|
||||
import { extractSharedFields } from './shared-fields';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user