auth

package
v0.0.0-...-1eee0f7 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserType_User    = iota
	UserType_Machine = iota
)

Variables

This section is empty.

Functions

func AddProvider

func AddProvider(p Provider)

func AuthenticateUser

func AuthenticateUser(w http.ResponseWriter, username string, password string) bool

func CreateInitialUser

func CreateInitialUser(p Provider)

func Logout

func Logout(w http.ResponseWriter, r *http.Request)

func SetSessionStore

func SetSessionStore(ss SessionStore)

func UserTypeName

func UserTypeName(ut int) string

Types

type Authenticator

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

Authenticator Right now at least, this is a singleton

func GetAuthenticator

func GetAuthenticator() *Authenticator

type LDAPAuthenticator

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

func GetLDAPAuthenticator

func GetLDAPAuthenticator(conf *config.Config) LDAPAuthenticator

func (*LDAPAuthenticator) AddUser

func (ldap *LDAPAuthenticator) AddUser(username string, password string, usertype int) error

func (*LDAPAuthenticator) AddUserToGroup

func (ldap *LDAPAuthenticator) AddUserToGroup(username string, group string) error

func (*LDAPAuthenticator) GetName

func (ldap *LDAPAuthenticator) GetName() string

func (*LDAPAuthenticator) GetUser

func (ldap *LDAPAuthenticator) GetUser(username string) (User, error)

func (*LDAPAuthenticator) GetWritable

func (ldap *LDAPAuthenticator) GetWritable() bool

func (*LDAPAuthenticator) LoginUser

func (ldap *LDAPAuthenticator) LoginUser(username string, password string) (User, error)

type MemorySessionStore

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

func CreateMemorySessionStore

func CreateMemorySessionStore() *MemorySessionStore

func (*MemorySessionStore) AddUser

func (mss *MemorySessionStore) AddUser(u *User) string

func (*MemorySessionStore) GetUser

func (mss *MemorySessionStore) GetUser(cookie string) *User

func (*MemorySessionStore) RemoveUser

func (mss *MemorySessionStore) RemoveUser(cookie string)

type Provider

type Provider interface {
	GetName() string
	GetWritable() bool
	LoginUser(username string, password string) (User, error)

	AddUser(username string, password string, usertype int) error
	GetUser(username string) (User, error)

	AddUserToGroup(username string, group string) error
}

type RedisProvider

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

func CreateRedisProvider

func CreateRedisProvider(conn *redis.Client) *RedisProvider

func (*RedisProvider) AddUser

func (rp *RedisProvider) AddUser(username string, password string, usertype int) error

func (*RedisProvider) AddUserToGroup

func (rp *RedisProvider) AddUserToGroup(username string, group string) error

func (*RedisProvider) GetName

func (rp *RedisProvider) GetName() string

func (*RedisProvider) GetUser

func (rp *RedisProvider) GetUser(username string) (User, error)

func (*RedisProvider) GetWritable

func (rp *RedisProvider) GetWritable() bool

func (*RedisProvider) LoginUser

func (rp *RedisProvider) LoginUser(username string, password string) (User, error)

type RedisSessionStore

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

func CreateRedisSessionStore

func CreateRedisSessionStore(conn *redis.Client) *RedisSessionStore

func (*RedisSessionStore) AddUser

func (rss *RedisSessionStore) AddUser(u *User) string

func (*RedisSessionStore) GetUser

func (rss *RedisSessionStore) GetUser(cookie string) *User

func (*RedisSessionStore) RemoveUser

func (rss *RedisSessionStore) RemoveUser(cookie string)

type SessionStore

type SessionStore interface {
	AddUser(u *User) string
	RemoveUser(cookie string)
	GetUser(cookie string) *User
}

type User

type User struct {
	UserType int
	Name     string   `json:"name"`
	UserName string   `json:"username"`
	Groups   []string `json:"groups"`
	// contains filtered or unexported fields
}

func CheckAuthAPI

func CheckAuthAPI(w http.ResponseWriter, r *http.Request) (bool, *User)

CheckAuthAPI Check for auth - either for a (human) user, or an API user

func CheckAuthUser

func CheckAuthUser(w http.ResponseWriter, r *http.Request) (bool, *User)

CheckAuthUser Check for auth - endpoint only for (human) user use

func (*User) IsAdmin

func (u *User) IsAdmin(config *config.Config) bool

Jump to

Keyboard shortcuts

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