config

package
v0.0.0-...-b57c09d Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorCredentialsNotAllowed

func ErrorCredentialsNotAllowed(username string, method string) error

func ErrorUserNotAllowed

func ErrorUserNotAllowed(username string, addr net.Addr) error

Types

type Config

type Config struct {
	Allowed []Network
	User    map[string]User
}

func (*Config) AddUser

func (cfg *Config) AddUser(user User) error

func (*Config) AllowCIDR

func (cfg *Config) AllowCIDR(n net.IPNet)

add CIDR to list of allowed networks

func (*Config) GetUser

func (cfg *Config) GetUser(name string) User

func (*Config) GetUserRemote

func (cfg *Config) GetUserRemote(name string, addr net.Addr) (User, error)

func (*Config) RemoteAllowed

func (cfg *Config) RemoteAllowed(addr net.Addr) error

check if a remote is allowed to connect

type ErrorNotAllowed

type ErrorNotAllowed struct {
	Username string
	Remote   net.Addr
	Method   string
}

func (ErrorNotAllowed) Error

func (e ErrorNotAllowed) Error() string

type IPNet

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

allowed CIDRs

func (IPNet) Contains

func (r IPNet) Contains(addr net.Addr) bool

type Network

type Network interface {
	Contains(net.Addr) bool
}

type User

type User interface {
	Username() string

	// Authentication
	RemoteAllowed(net.Addr) bool                          // User can connect from remote
	CheckPassword(string) bool                            // User can authentication with given password
	CheckChallenge(ssh.KeyboardInteractiveChallenge) bool // User can authentication with given challenge
	CheckPublicKey(ssh.PublicKey) bool                    // User can authentication with given public key
}

Jump to

Keyboard shortcuts

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