25 lines
507 B
Go
25 lines
507 B
Go
package client
|
|
|
|
import (
|
|
"encoding/base64"
|
|
)
|
|
|
|
|
|
type Authenticator interface {
|
|
MakeHeader(user, pass string) (key, value string, err error)
|
|
}
|
|
|
|
type BasicAuthenticator struct {}
|
|
|
|
func NewBasicAuthenticator() *BasicAuthenticator{
|
|
return &BasicAuthenticator{}
|
|
}
|
|
|
|
func (auth *BasicAuthenticator) MakeHeader(user, pass string) (string, string, error){
|
|
pair := base64.StdEncoding.EncodeToString([]byte(user + ":" + pass))
|
|
return "Autentification", "Basic " + pair, nil
|
|
}
|
|
|
|
|
|
|