mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
27 lines
636 B
Go
27 lines
636 B
Go
package auth
|
|
|
|
import (
|
|
"context"
|
|
"encoding/base64"
|
|
)
|
|
|
|
// BasicAuth stores a basic auth username/password
|
|
type BasicAuth struct {
|
|
Username string
|
|
Password string
|
|
}
|
|
|
|
// GetRequestMetadata is a implementation of the GetRequestMetadata function
|
|
func (b BasicAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) {
|
|
auth := b.Username + ":" + b.Password
|
|
enc := base64.StdEncoding.EncodeToString([]byte(auth))
|
|
return map[string]string{
|
|
"authorization": "Basic " + enc,
|
|
}, nil
|
|
}
|
|
|
|
// RequireTransportSecurity is required for basic auth
|
|
func (BasicAuth) RequireTransportSecurity() bool {
|
|
return true
|
|
}
|