Files
gocryptotrader/gctrpc/auth/auth.go
Adrian Gallagher f5914e8c10 Engine changes
2019-05-22 17:06:38 +10:00

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
}