mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-24 23:22:38 +08:00
feat: Add validate identity helper to resolver (#23068)
This commit is contained in:
@@ -81,6 +81,14 @@ export interface ICredentialResolver {
|
||||
*/
|
||||
validateOptions(options: CredentialResolverConfiguration): Promise<void>;
|
||||
|
||||
/**
|
||||
* Validates if the userIdentity provided has access to the resolver capable credential
|
||||
*
|
||||
* @param identity - The identity of the entity to validate access for
|
||||
* @throws {CredentialResolverAccessValidationError} When access is invalid
|
||||
*/
|
||||
validateIdentity?(identity: string, handle: CredentialResolverHandle): Promise<void>;
|
||||
|
||||
/**
|
||||
* Runs initialization logic for the resolver. This might be called multiple times!
|
||||
* Optional - not all resolvers require initialization.
|
||||
|
||||
+9
@@ -78,4 +78,13 @@ describe('StubCredentialResolver', () => {
|
||||
await expect(resolver2.getSecret(credentialId, context, handle)).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateIdentity', () => {
|
||||
it('should validate identity', async () => {
|
||||
const resolver = new StubCredentialResolver(mockLogger);
|
||||
const identity = 'test-identity';
|
||||
const handle = testHelpers.createHandle({});
|
||||
await expect(resolver.validateIdentity(identity, handle)).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+4
@@ -108,4 +108,8 @@ export class StubCredentialResolver implements ICredentialResolver {
|
||||
async validateOptions(options: CredentialResolverConfiguration): Promise<void> {
|
||||
await this.parseOptions(options);
|
||||
}
|
||||
|
||||
async validateIdentity(_identity: string, _handle: CredentialResolverHandle): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user