Documentation
¶
Overview ¶
Copyright 2019 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Imported from https://golang.org/src/cmd/go/internal/auth/netrc.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( EmptyBasicAuthClientConfig = BasicAuthClientConfig{} EmptyBasicAuthServerConfig = BasicAuthServerConfig{} )
Functions ¶
func AddCredentials ¶
AddCredentials fills in the user's credentials for req, if any. The return value reports whether any matching credentials were found.
func BasicAuthHandlerFunc ¶
func BasicAuthHandlerFunc(cfg BasicAuthServerConfig, next http.Handler) http.HandlerFunc
Types ¶
type BasicAuthClientConfig ¶
type BasicAuthClientConfig struct {
// https://everything.curl.dev/usingcurl/netrc
//
// machine connect.lab.dioad.net
// login blah
// password blah
NetRCFile string `mapstructure:"netrc-file"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
}
func (BasicAuthClientConfig) IsEmpty ¶
func (c BasicAuthClientConfig) IsEmpty() bool
type BasicAuthHandler ¶
type BasicAuthHandler struct {
// contains filtered or unexported fields
}
func NewBasicAuthHandler ¶
func NewBasicAuthHandler(handler http.Handler, cfg BasicAuthServerConfig) BasicAuthHandler
func NewBasicAuthHandlerWithMap ¶
func NewBasicAuthHandlerWithMap(handler http.Handler, authMap BasicAuthMap) BasicAuthHandler
func (BasicAuthHandler) ServeHTTP ¶
func (h BasicAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type BasicAuthMap ¶
type BasicAuthMap map[string]BasicAuthPair
func LoadBasicAuthFromFile ¶
func LoadBasicAuthFromFile(filePath string) (BasicAuthMap, error)
func LoadBasicAuthFromReader ¶
func LoadBasicAuthFromReader(reader io.Reader) BasicAuthMap
func LoadBasicAuthFromScanner ¶
func LoadBasicAuthFromScanner(scanner *bufio.Scanner) BasicAuthMap
func (BasicAuthMap) AddUserWithHashedPassword ¶
func (m BasicAuthMap) AddUserWithHashedPassword(user, hashedPassword string)
if user already exists it will over ride it
func (BasicAuthMap) AddUserWithPlainPassword ¶
func (m BasicAuthMap) AddUserWithPlainPassword(user, password string)
if user already exists it will over ride it
func (BasicAuthMap) Authenticate ¶
func (m BasicAuthMap) Authenticate(user, password string) (bool, error)
func (BasicAuthMap) UserExists ¶
func (m BasicAuthMap) UserExists(user string) bool
type BasicAuthPair ¶
func NewBasicAuthPairWithPlainPassword ¶
func NewBasicAuthPairWithPlainPassword(user, password string) (BasicAuthPair, error)
func (BasicAuthPair) VerifyPassword ¶
func (p BasicAuthPair) VerifyPassword(password string) (bool, error)
type BasicAuthServerConfig ¶
type BasicAuthServerConfig struct {
AllowInsecureHTTP bool `mapstructure:"allow-insecure-http"`
HTPasswdFile string `mapstructure:"htpasswd-file"`
Users []string `mapstructure:"users"`
}
func (BasicAuthServerConfig) IsEmpty ¶
func (c BasicAuthServerConfig) IsEmpty() bool
type BasicClientAuth ¶
type BasicClientAuth struct {
Config BasicAuthClientConfig
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.