Files
mstore/pkg/filecli/authbas.go
T
2026-03-11 19:47:40 +02:00

30 lines
776 B
Go

/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*
* This work is published and licensed under a Creative Commons
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
*
* Distribution of this work is permitted, but commercial use and
* modifications are strictly prohibited.
*/
package filecli
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 "Authorization", "Basic " + pair, nil
}