whitelister

package
v0.0.0-...-2f83369 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2019 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandString

func RandString() string

RandString generates a random, 6-character string

Types

type AdminCredentials

type AdminCredentials struct {
	Password string `json:"password"`
	Username string `json:"username"`
	NewUser  string `json:"newusername"`
	NewPass  string `json:"newpassword"`
}

type Credentials

type Credentials struct {
	Password string `json:"password"`
	Username string `json:"username"`
	Base64   string `json:"base64"`
}

type OneTimePassword

type OneTimePassword struct {
	CurrentPass string
	Revokables  map[string]string
	// contains filtered or unexported fields
}

OneTimePassword is an account-generation method where a password is pre-generated. The administrator of the VPN gives that password to a client, and the client uses it to create an account. After this, that password cannot be re-used to create a new account.

func NewOneTimePassRotator

func NewOneTimePassRotator() (*OneTimePassword, error)

NewOneTimePassRotator generates a new whitelister using the One-Time-Password creation pattern

func (*OneTimePassword) Check

func (o *OneTimePassword) Check(bodyStringOrBytes interface{}) (string, interface{}, bool)

Check determines if the string or bytes it is passed correspond to a current password. If so, it creates an account. If the password corresponds to an already created account, then the the user is informed the account is active and if not, it says the user is anauthorized.

func (*OneTimePassword) CurrentPassword

func (o *OneTimePassword) CurrentPassword() string

CurrentPassword returns the current password for creating a new account.

func (*OneTimePassword) RefreshPassword

func (o *OneTimePassword) RefreshPassword() string

RefreshPassword generates a new password to replace the old password with.

func (*OneTimePassword) ServeHTTP

func (o *OneTimePassword) ServeHTTP(rw http.ResponseWriter, rq *http.Request)

func (*OneTimePassword) String

func (o *OneTimePassword) String() string

func (*OneTimePassword) Whitelist

func (o *OneTimePassword) Whitelist() []string

Whitelist prints the whitelist of keys to be consumed by a tunnel

type UserNamePassword

type UserNamePassword struct {
	Pairs map[string][]string
	// contains filtered or unexported fields
}

func NewUserNamePassword

func NewUserNamePassword(adminuser, adminpass string) (*UserNamePassword, error)

pairs map[string][]string

func (*UserNamePassword) Check

func (o *UserNamePassword) Check(bodyStringOrBytes interface{}) (string, interface{}, bool)

func (*UserNamePassword) CheckAdmin

func (o *UserNamePassword) CheckAdmin(bodyStringOrBytes interface{}) (string, bool)

func (*UserNamePassword) ServeHTTP

func (o *UserNamePassword) ServeHTTP(rw http.ResponseWriter, rq *http.Request)

func (*UserNamePassword) String

func (o *UserNamePassword) String() string

func (*UserNamePassword) Whitelist

func (o *UserNamePassword) Whitelist() []string

type WhiteLister

type WhiteLister interface {
	// Check is used to determine if a client is to be authorized by the WhiteLister.
	// The interface is sent by an authentication method, it may contain a password or
	//  a message encrypted for the server and signed with a private key.
	// The string is a base64 string to whitelist if the authentication passes.
	// The first string it returns should be the base64 of the client to be whitelisted.
	// The second interface may be used to pass information from the whitelister to another
	//  routine but is optional
	// The final bool should be true if the client is to be whitelisted, false if it is
	//  not authorized.
	Check(interface{}) (string, interface{}, bool)
	// Whitelist returns the stored client whitelist
	Whitelist() []string
	// ServeHTTP implements an HTTP handler that does the login stuff
	ServeHTTP(http.ResponseWriter, *http.Request)
	// String returns a string to be used for identifying the auth method in use
	// to the server so it can expose it to the admin
	String() string
}

Jump to

Keyboard shortcuts

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