Skip to content

Commit

Permalink
fixes #758 Basic Auth should accept utf8 charset
Browse files Browse the repository at this point in the history
  • Loading branch information
mrin9 committed Sep 21, 2022
1 parent b97164c commit 26f1db7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/templates/security-scheme-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export function applyApiKey(securitySchemeId, username = '', password = '', prov
let finalApiKeyValue = '';
if (securityObj.scheme?.toLowerCase() === 'basic') {
if (username) {
finalApiKeyValue = `Basic ${btoa(`${username}:${password}`)}`;
finalApiKeyValue = Buffer.from(`${username}:${password}`, 'utf8').toString('base64');
// finalApiKeyValue = `Basic ${btoa(`${username}:${password}`)}`;
}
} else if (providedApikeyVal) {
securityObj.value = providedApikeyVal;
Expand Down Expand Up @@ -104,7 +105,8 @@ async function fetchAccessToken(tokenUrl, clientId, clientSecret, redirectUrl, g
urlFormParams.append('code_verifier', codeVerifier); // for PKCE
}
if (sendClientSecretIn === 'header') {
headers.set('Authorization', `Basic ${btoa(`${clientId}:${clientSecret}`)}`);
// headers.set('Authorization', `Basic ${btoa(`${clientId}:${clientSecret}`)}`);
headers.set('Authorization', `Basic ${Buffer.from(`${username}:${password}`, 'utf8').toString('base64')}`);
} else {
urlFormParams.append('client_id', clientId);
urlFormParams.append('client_secret', clientSecret);
Expand Down

0 comments on commit 26f1db7

Please sign in to comment.