feat: add support for logging in to a basic auth protected app#203
Conversation
WalkthroughThe changes introduce support for basic authentication credentials within the application's configuration and request handling. A new struct for basic auth labels is added, the labels parsing logic is updated to handle these credentials, and the HTTP handler now sets an Authorization header using a new utility function to generate the Basic auth token. Header sanitization is removed, and logging is simplified. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant AuthHandler
participant Utils
Client->>AuthHandler: Send request
AuthHandler->>Utils: Parse labels (including Basic)
alt Basic auth credentials present
AuthHandler->>Utils: GetBasicAuth(user, password)
Utils-->>AuthHandler: base64(user:password)
AuthHandler->>Client: Set Authorization header (Basic)
end
AuthHandler->>Client: Set other headers and respond
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
internal/types/config.go (1)
102-106: Consider security implications of plaintext credential storage.The
BasicLabelsstruct stores username and password as plain strings. While this is likely intended for configuration purposes, ensure that:
- These credentials are not logged or exposed in debug output
- The values are properly validated when parsed from labels
- Consider if any additional security measures are needed for credential handling
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
internal/handlers/handlers.go(2 hunks)internal/types/config.go(1 hunks)internal/utils/utils.go(3 hunks)
🔇 Additional comments (3)
internal/types/config.go (1)
114-114: LGTM! Clean integration with existing Labels structure.The addition of the
Basicfield to theLabelsstruct follows the existing pattern with theOAuthfield and maintains consistency.internal/utils/utils.go (2)
363-370: LGTM! Correct implementation of Basic auth header generation.The
GetBasicAuthfunction correctly implements RFC 7617 Basic authentication by:
- Concatenating username and password with a colon separator
- Base64 encoding the combined string
- Returning the encoded value for use in Authorization headers
205-205: ```shell
#!/bin/bashRetrieve the BasicLabels struct definition to verify its field tags
echo "Looking for BasicLabels struct definition across the repo..."
rg -n -C3 "type BasicLabels" --type goLocate the labelsParsed declaration around the parser.Decode call
echo "Locating labelsParsed declaration in internal/utils/utils.go..."
rg -n -C3 "labelsParsed" --type go internal/utils/utils.go</details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Solves #185
Summary by CodeRabbit
New Features
Bug Fixes