auth

package
v1.58.1-0...-47970fe Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextAuthKey = &contextAuthType{}

ContextAuthKey is a simple context key for storing info returned by CustomAuthFn

View Source
var ContextUserKey = &contextUserType{}

ContextUserKey is a simple context key for storing the username of the request

View Source
var Help = `
#### Authentication

By default this will serve files without needing a login.

You can either use an htpasswd file which can take lots of users, or
set a single username and password with the ` + "`--user` and `--pass`" + ` flags.

Use ` + "`--htpasswd /path/to/htpasswd`" + ` to provide an htpasswd file.  This is
in standard apache format and supports MD5, SHA1 and BCrypt for basic
authentication.  Bcrypt is recommended.

To create an htpasswd file:

    touch htpasswd
    htpasswd -B htpasswd user
    htpasswd -B htpasswd anotherUser

The password file can be updated while rclone is running.

Use ` + "`--realm`" + ` to set the authentication realm.

Use ` + "`--salt`" + ` to change the password hashing salt from the default.
`

Help contains text describing the http authentication to add to the command help.

View Source
var (
	Opt = Options{
		Salt: "dlPL2MqE",
	}
)

Options set by command line flags

Functions

func AddFlags

func AddFlags(flagSet *pflag.FlagSet)

AddFlags adds flags for the http/auth

func AddFlagsPrefix

func AddFlagsPrefix(flagSet *pflag.FlagSet, prefix string, Opt *Options)

AddFlagsPrefix adds flags for http/auth

func Auth

func Auth(opt Options) http.Middleware

Auth instantiates middleware that authenticates users based on the configuration

func CustomAuth

func CustomAuth(fn CustomAuthFn, realm string) httplib.Middleware

CustomAuth instantiates middleware that authenticates using a custom function

func HtPasswdAuth

func HtPasswdAuth(path, realm string) httplib.Middleware

HtPasswdAuth instantiates middleware that authenticates against the passed htpasswd file

func SingleAuth

func SingleAuth(user, pass, realm, salt string) httplib.Middleware

SingleAuth instantiates middleware that authenticates for a single user

Types

type CustomAuthFn

type CustomAuthFn func(user, pass string) (value interface{}, err error)

CustomAuthFn if used will be used to authenticate user, pass. If an error is returned then the user is not authenticated.

If a non nil value is returned then it is added to the context under the key

type LoggedBasicAuth

type LoggedBasicAuth struct {
	auth.BasicAuth
}

LoggedBasicAuth extends BasicAuth to include access logging

func NewLoggedBasicAuthenticator

func NewLoggedBasicAuthenticator(realm string, secrets auth.SecretProvider) *LoggedBasicAuth

NewLoggedBasicAuthenticator instantiates a new instance of LoggedBasicAuthenticator

func (*LoggedBasicAuth) CheckAuth

func (a *LoggedBasicAuth) CheckAuth(r *http.Request) string

CheckAuth extends BasicAuth.CheckAuth to emit a log entry for unauthorised requests

type Options

type Options struct {
	HtPasswd  string       // htpasswd file - if not provided no authentication is done
	Realm     string       // realm for authentication
	BasicUser string       // single username for basic auth if not using Htpasswd
	BasicPass string       // password for BasicUser
	Salt      string       // password hashing salt
	Auth      CustomAuthFn `json:"-"` // custom Auth (not set by command line flags)
}

Options contains options for the http authentication

Jump to

Keyboard shortcuts

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