Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code snippet does not base64 encode the basic authentication header #741

Closed
worawatt opened this issue Dec 29, 2020 · 3 comments
Closed

Comments

@worawatt
Copy link

When creating code snippet from a request with basic authentication using user:password format, the Authorization in the snippet is not encoded with base64.

For example

GET https://httpbin.org/basic-auth/user/passwd HTTP/1.1
Authorization: Basic user:passwd

Result:

GET /basic-auth/user/passwd HTTP/1.1
User-Agent: vscode-restclient
Authorization: Basic user:passwd
Host: httpbin.org

But using user password format works correctly.

GET https://httpbin.org/basic-auth/user/passwd HTTP/1.1
Authorization: Basic user passwd

Result:

GET /basic-auth/user/passwd HTTP/1.1
User-Agent: vscode-restclient
Authorization: Basic dXNlcjpwYXNzd2Q=
Host: httpbin.org

Maybe because of this line where it splits the user and password using a space only:

const params = authHeader.substr(start).trim().split(' ');

@Huachao
Copy link
Owner

Huachao commented Dec 29, 2020

@worawatt nice catch, I will publish this fix in the next release.

@Huachao Huachao closed this as completed Dec 29, 2020
@Huachao
Copy link
Owner

Huachao commented Apr 6, 2021

@worawatt this has been fixed in the latest version 0.24.5 and you can have a try

@worawatt
Copy link
Author

worawatt commented Apr 7, 2021

It works.
Thank you so much @Huachao.
This plugin is awesome, and I've always suggested it to my colleagues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants