basic

package
v0.43.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

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

This section is empty.

Functions

func AddCredentials

func AddCredentials(req *http.Request) (added bool)

AddCredentials fills in the user's credentials for req, if any. The return value reports whether any matching credentials were found.

Types

type AuthMap added in v0.37.0

type AuthMap map[string]BasicAuthPair

AuthMap is a user and password pair

func LoadBasicAuthFromFile

func LoadBasicAuthFromFile(filePath string) (AuthMap, error)

func LoadBasicAuthFromReader

func LoadBasicAuthFromReader(reader io.Reader) AuthMap

func LoadBasicAuthFromScanner

func LoadBasicAuthFromScanner(scanner *bufio.Scanner) AuthMap

func (AuthMap) AddUserWithHashedPassword added in v0.37.0

func (m AuthMap) AddUserWithHashedPassword(user, hashedPassword string)

AddUserWithHashedPassword if user already exists it will over ride it

func (AuthMap) AddUserWithPlainPassword added in v0.37.0

func (m AuthMap) AddUserWithPlainPassword(user, password string)

AddUserWithPlainPassword if user already exists it will over ride it

func (AuthMap) Authenticate added in v0.37.0

func (m AuthMap) Authenticate(user, password string) (bool, error)

Authenticate returns true if the user exists and the password is correct

func (AuthMap) UserExists added in v0.37.0

func (m AuthMap) UserExists(user string) bool

UserExists returns true if the user exists

type BasicAuthPair

type BasicAuthPair struct {
	User           string
	HashedPassword string
}

func NewBasicAuthPairWithPlainPassword

func NewBasicAuthPairWithPlainPassword(user, password string) (BasicAuthPair, error)

func (BasicAuthPair) VerifyPassword

func (p BasicAuthPair) VerifyPassword(password string) (bool, error)

type ClientAuth added in v0.40.0

type ClientAuth struct {
	Config ClientConfig
	// contains filtered or unexported fields
}

func (ClientAuth) AddAuth added in v0.40.0

func (a ClientAuth) AddAuth(req *http.Request) error

func (ClientAuth) HTTPClient added in v0.40.0

func (a ClientAuth) HTTPClient() (*http.Client, error)

type ClientConfig added in v0.37.0

type ClientConfig 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"`
}

type Handler added in v0.37.0

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler added in v0.37.0

func NewHandler(cfg ServerConfig) *Handler

func NewHandlerWithMap added in v0.37.0

func NewHandlerWithMap(authMap AuthMap) *Handler

func (*Handler) AuthRequest added in v0.37.0

func (h *Handler) AuthRequest(r *http.Request) (stdctx.Context, error)

func (*Handler) Wrap added in v0.37.0

func (h *Handler) Wrap(handler http.Handler) http.Handler

type RoundTripper added in v0.40.0

type RoundTripper struct {
	Username string
	Password string
	Base     http.RoundTripper
}

func (*RoundTripper) RoundTrip added in v0.40.0

func (t *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type ServerConfig added in v0.37.0

type ServerConfig struct {
	AllowInsecureHTTP bool     `mapstructure:"allow-insecure-http"`
	HTPasswdFile      string   `mapstructure:"htpasswd-file"`
	Users             []string `mapstructure:"users"`
	Realm             string   `mapstructure:"realm"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL