user

package
v0.0.0-...-6bdf688 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ADMIN_USER_UUID = "00000000-0000-0000-0000-000000000000"

special admin user with global privs

View Source
const UsersPrefix = "users"

UsersPrefix - KV store prefix for users

Variables

This section is empty.

Functions

func StartExternalServer

func StartExternalServer(listenAddr string, stop <-chan struct{}, um UserManager) error

Types

type AuthenticateRequest

type AuthenticateRequest struct {
	Username string
	Password string
}

type AuthenticateResponse

type AuthenticateResponse struct {
	User User
	Type string
}

type AuthenticationType

type AuthenticationType int
const (
	AuthenticationTypeNone AuthenticationType = iota
	AuthenticationTypePassword
	AuthenticationTypeAPIKey
)

func AuthenticationTypeFromString

func AuthenticationTypeFromString(at string) (AuthenticationType, error)

func (AuthenticationType) Privileged

func (at AuthenticationType) Privileged() bool

Privileged - authentication type that enables certain API action

func (AuthenticationType) String

func (at AuthenticationType) String() string

type AuthorizeNamespaceAdminRequest

type AuthorizeNamespaceAdminRequest struct {
	User      User
	Namespace string
}

type AuthorizeRequest

type AuthorizeRequest struct {
	User               User
	OwnerAction        bool
	TopLevelFilesystem types.TopLevelFilesystem
}

type AuthorizeResponse

type AuthorizeResponse struct {
	Allowed bool
}

type DeleteRequest

type DeleteRequest struct {
	UserID string
}

type ExternalManager

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

func NewExternal

func NewExternal(url string, httpClient *http.Client) *ExternalManager

func (*ExternalManager) Authenticate

func (m *ExternalManager) Authenticate(username, password string) (*User, AuthenticationType, error)

func (*ExternalManager) Authorize

func (m *ExternalManager) Authorize(user *User, ownerAction bool, tlf *types.TopLevelFilesystem) (bool, error)

func (*ExternalManager) Delete

func (m *ExternalManager) Delete(id string) error

func (*ExternalManager) Get

func (m *ExternalManager) Get(q *Query) (*User, error)

func (*ExternalManager) Import

func (m *ExternalManager) Import(user *User) error

Import user without hashing password or generating API key

func (*ExternalManager) List

func (m *ExternalManager) List(selector string) ([]*User, error)

func (*ExternalManager) New

func (m *ExternalManager) New(name, email, password string) (*User, error)

func (*ExternalManager) NewAdmin

func (m *ExternalManager) NewAdmin(user *User) error

func (*ExternalManager) ResetAPIKey

func (m *ExternalManager) ResetAPIKey(id string) (*User, error)

func (*ExternalManager) Update

func (m *ExternalManager) Update(user *User) (*User, error)

func (*ExternalManager) UpdatePassword

func (m *ExternalManager) UpdatePassword(id string, password string) (*User, error)

func (*ExternalManager) UserIsNamespaceAdministrator

func (m *ExternalManager) UserIsNamespaceAdministrator(user *User, namespace string) (bool, error)

type InternalManager

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

func NewInternal

func NewInternal(kv store.KVStoreWithIndex) *InternalManager

func (*InternalManager) Authenticate

func (m *InternalManager) Authenticate(username, password string) (*User, AuthenticationType, error)

func (*InternalManager) Authorize

func (m *InternalManager) Authorize(user *User, collabsAllowed bool, tlf *types.TopLevelFilesystem) (bool, error)

func (*InternalManager) Delete

func (m *InternalManager) Delete(id string) error

func (*InternalManager) Get

func (m *InternalManager) Get(q *Query) (*User, error)

func (*InternalManager) Import

func (m *InternalManager) Import(user *User) error

Import - imports user without generating password, API key

func (*InternalManager) List

func (m *InternalManager) List(selector string) ([]*User, error)

func (*InternalManager) New

func (m *InternalManager) New(username, email, password string) (*User, error)

func (*InternalManager) NewAdmin

func (m *InternalManager) NewAdmin(user *User) error

func (*InternalManager) ResetAPIKey

func (m *InternalManager) ResetAPIKey(username string) (*User, error)

func (*InternalManager) Update

func (m *InternalManager) Update(user *User) (*User, error)

func (*InternalManager) UpdatePassword

func (m *InternalManager) UpdatePassword(username string, password string) (*User, error)

func (*InternalManager) UserIsNamespaceAdministrator

func (m *InternalManager) UserIsNamespaceAdministrator(user *User, namespace string) (bool, error)

type ListRequest

type ListRequest struct {
	Selector string
}

type NewUserRequest

type NewUserRequest struct {
	Name     string
	Email    string
	Password string
}

type Query

type Query = types.Query

type ResetAPIKeyRequest

type ResetAPIKeyRequest struct {
	UserID string
}

type SafeUser

type SafeUser = types.SafeUser

type UpdatePasswordRequest

type UpdatePasswordRequest struct {
	UserID      string
	NewPassword string
}

type User

type User = types.User

Alias

type UserManager

type UserManager interface {
	NewAdmin(user *User) error

	New(name, email, password string) (*User, error)
	Get(q *Query) (*User, error)
	Update(user *User) (*User, error)

	// Import user without hashing password or generating API key
	Import(user *User) error

	UpdatePassword(id string, password string) (*User, error)
	ResetAPIKey(id string) (*User, error)

	Delete(id string) error
	List(selector string) ([]*User, error)

	// Authenticate user, if successful returns User struct and
	// authentication type or error if unsuccessful
	Authenticate(username, password string) (*User, AuthenticationType, error)

	// Authorize user action on a tlf, returns (true, nil) for OK, (false, nil) for not OK,
	// and (false, error) for an error happened (so not OK).
	Authorize(user *User, ownerAction bool, tlf *types.TopLevelFilesystem) (bool, error)

	// Is the user the administrator for this namespace?
	UserIsNamespaceAdministrator(user *User, namespace string) (bool, error)
}

Jump to

Keyboard shortcuts

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