Skip to content

Add basic user auth support #109

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add basic user auth support #109

wants to merge 4 commits into from

Conversation

bob-bot
Copy link

@bob-bot bob-bot commented May 29, 2025

This PR builds on #107 and should be merged after it.
Closes #108

Add Basic Authentication support to net_http_request table

This PR adds a user_credentials column that accepts username:password format and automatically encodes it as a Basic Auth header, similar to curl's --user flag.

Changes

  • Added user_credentials column to table definition
  • Added UserCredentials field to request structs
  • Implemented automatic Basic Auth header generation with base64 encoding
  • Updated documentation with usage examples

Testing

Tested against httpbin.org's basic-auth endpoint:

select
 url,
 response_status_code,
 response_body
from
 net_http_request
where
 url = 'https://httpbin.org/basic-auth/testuser/testpass'
 and user_credentials = 'testuser:testpass';

Result:

url                                              | response_status_code | response_body
-------------------------------------------------|---------------------|----------------------------------
https://httpbin.org/basic-auth/testuser/testpass | 200                 | {"authenticated": true, "user": "testuser"}

Also tested with invalid credentials:

select
  url,
  response_status_code,
  response_body
from
  net_http_request
where
  url = 'https://httpbin.org/basic-auth/testuser/testpass'
  and user_credentials = 'wronguser:wrongpass';

Result:

url                                              | response_status_code | response_body
-------------------------------------------------|---------------------|----------------------------------
https://httpbin.org/basic-auth/testuser/testpass | 401                 |

Also tested with combining insecure = true on an internal API server.

@bob-bot bob-bot requested a review from misraved May 29, 2025 01:56
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

Successfully merging this pull request may close these issues.

Add Basic Authentication support to net_http_request table
1 participant