fix(bitwarden): support European Cloud-Hosted instances (#13315)

This commit is contained in:
Damien Dudognon 2025-02-18 08:28:31 +01:00
parent 8790a0df3d
commit 51b55a4cd1
No known key found for this signature in database
GPG key ID: 45D954AB469923B0
2 changed files with 25 additions and 4 deletions

View file

@ -51,5 +51,26 @@ export class BitwardenApi implements ICredentialType {
}, },
}, },
}, },
{
displayName: 'Server Geographies',
name: 'serverLocation',
type: 'options',
default: 'bitwarden.com',
options: [
{
name: 'United States',
value: 'bitwarden.com',
},
{
name: 'European Union',
value: 'bitwarden.eu',
},
],
displayOptions: {
show: {
environment: ['cloudHosted'],
},
},
},
]; ];
} }

View file

@ -13,10 +13,10 @@ import { NodeApiError } from 'n8n-workflow';
* Return the access token URL based on the user's environment. * Return the access token URL based on the user's environment.
*/ */
async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
const { environment, domain } = await this.getCredentials('bitwardenApi'); const { environment, domain, serverLocation } = await this.getCredentials('bitwardenApi');
return environment === 'cloudHosted' return environment === 'cloudHosted'
? 'https://identity.bitwarden.com/connect/token' ? `https://identity.${serverLocation}/connect/token`
: `${domain}/identity/connect/token`; : `${domain}/identity/connect/token`;
} }
@ -24,9 +24,9 @@ async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
* Return the base API URL based on the user's environment. * Return the base API URL based on the user's environment.
*/ */
async function getBaseUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { async function getBaseUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
const { environment, domain } = await this.getCredentials('bitwardenApi'); const { environment, domain, serverLocation } = await this.getCredentials('bitwardenApi');
return environment === 'cloudHosted' ? 'https://api.bitwarden.com' : `${domain}/api`; return environment === 'cloudHosted' ? `https://api.${serverLocation}` : `${domain}/api`;
} }
/** /**