user

package
v1.9.0-beta5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAffiliation

func GetAffiliation(user Affiliation) string

GetAffiliation return a joined version version of the affiliation path with '.' as the seperator

func GetNewAttributes

func GetNewAttributes(modifyAttrs, newAttrs []api.Attribute) []api.Attribute

GetNewAttributes updates existing attribute, or add attribute if it does not already exist

Types

type Affiliation

type Affiliation interface {
	GetAffiliationPath() []string
}

Affiliation is interface that defines functions needed to get a user's affiliation

type DbTxResult

type DbTxResult struct {
	Affiliations []spi.Affiliation
	Identities   []User
}

DbTxResult returns information on any affiliations and/or identities affected during a database transaction

type Impl

type Impl struct {
	Info
	// contains filtered or unexported fields
}

Impl is the databases representation of a user

func GetUserLessThanLevel

func GetUserLessThanLevel(tx userDB, level int) ([]*Impl, error)

GetUserLessThanLevel returns all identities that are less than the level specified Otherwise, returns no users if requested level is zero

func New

func New(userRec *Record, db userDB) *Impl

New creates a DBUser object from the DB user record

func (*Impl) GetAffiliationPath

func (u *Impl) GetAffiliationPath() []string

GetAffiliationPath returns the complete path for the user's affiliation.

func (*Impl) GetAttribute

func (u *Impl) GetAttribute(name string) (*api.Attribute, error)

GetAttribute returns the value for an attribute name

func (*Impl) GetAttributes

func (u *Impl) GetAttributes(attrNames []string) ([]api.Attribute, error)

GetAttributes returns the requested attributes. Return all the user's attributes if nil is passed in

func (*Impl) GetFailedLoginAttempts

func (u *Impl) GetFailedLoginAttempts() int

GetFailedLoginAttempts returns the number of times the user has entered an incorrect password

func (*Impl) GetLevel

func (u *Impl) GetLevel() int

GetLevel returns the level of the user

func (*Impl) GetMaxEnrollments

func (u *Impl) GetMaxEnrollments() int

GetMaxEnrollments returns the max enrollments of the user

func (*Impl) GetName

func (u *Impl) GetName() string

GetName returns the enrollment ID of the user

func (*Impl) GetPass

func (u *Impl) GetPass() []byte

GetPass returns the hashed password of the user

func (*Impl) GetType

func (u *Impl) GetType() string

GetType returns the type of the user

func (*Impl) IncrementIncorrectPasswordAttempts

func (u *Impl) IncrementIncorrectPasswordAttempts() error

IncrementIncorrectPasswordAttempts updates the incorrect password count of user

func (*Impl) IsRevoked

func (u *Impl) IsRevoked() bool

IsRevoked returns back true if user is revoked

func (*Impl) Login

func (u *Impl) Login(pass string, caMaxEnrollments int) error

Login the user with a password

func (*Impl) LoginComplete

func (u *Impl) LoginComplete() error

LoginComplete completes the login process by incrementing the state of the user

func (*Impl) Migrate

func (u *Impl) Migrate(tx userDB) error

Migrate will migrate the user to the latest version

func (*Impl) ModifyAttributes

func (u *Impl) ModifyAttributes(newAttrs []api.Attribute) error

ModifyAttributes adds a new attribute, modifies existing attribute, or delete attribute

func (*Impl) ModifyAttributesTx

func (u *Impl) ModifyAttributesTx(tx userDB, newAttrs []api.Attribute) error

ModifyAttributesTx adds a new attribute, modifies existing attribute, or delete attribute

func (*Impl) Revoke

func (u *Impl) Revoke() error

Revoke will revoke the user, setting the state of the user to be -1

func (*Impl) SetLevel

func (u *Impl) SetLevel(level int) error

SetLevel sets the level of the user

func (*Impl) SetLevelTx

func (u *Impl) SetLevelTx(tx userDB, level int) error

SetLevelTx sets the level of the user

type Info

type Info struct {
	Name                      string
	Pass                      string `mask:"password"`
	Type                      string
	Affiliation               string
	Attributes                []api.Attribute
	State                     int
	MaxEnrollments            int
	Level                     int
	IncorrectPasswordAttempts int
}

Info contains information about a user

type Record

type Record struct {
	Name                      string `db:"id"`
	Pass                      []byte `db:"token"`
	Type                      string `db:"type"`
	Affiliation               string `db:"affiliation"`
	Attributes                string `db:"attributes"`
	State                     int    `db:"state"`
	MaxEnrollments            int    `db:"max_enrollments"`
	Level                     int    `db:"level"`
	IncorrectPasswordAttempts int    `db:"incorrect_password_attempts"`
}

Record defines the properties of a user

type Registry

type Registry interface {
	GetUser(id string, attrs []string) (User, error)
	InsertUser(user *Info) error
	UpdateUser(user *Info, updatePass bool) error
	DeleteUser(id string) (User, error)
	GetAffiliation(name string) (spi.Affiliation, error)
	GetAllAffiliations(name string) (*sqlx.Rows, error)
	InsertAffiliation(name string, prekey string, level int) error
	GetUserLessThanLevel(version int) ([]User, error)
	GetFilteredUsers(affiliation, types string) (*sqlx.Rows, error)
	DeleteAffiliation(name string, force, identityRemoval, isRegistrar bool) (*DbTxResult, error)
	ModifyAffiliation(oldAffiliation, newAffiliation string, force, isRegistrar bool) (*DbTxResult, error)
	GetAffiliationTree(name string) (*DbTxResult, error)
}

Registry is the API for retreiving users and groups

type User

type User interface {
	// Returns the enrollment ID of the user
	GetName() string
	// Return the type of the user
	GetType() string
	// Return the max enrollments of the user
	GetMaxEnrollments() int
	// Login the user with a password
	Login(password string, caMaxEnrollment int) error
	// Get the complete path for the user's affiliation.
	GetAffiliationPath() []string
	// GetAttribute returns the value for an attribute name
	GetAttribute(name string) (*api.Attribute, error)
	// GetAttributes returns the requested attributes
	GetAttributes(attrNames []string) ([]api.Attribute, error)
	// ModifyAttributes adds, removes, or deletes attribute
	ModifyAttributes(attrs []api.Attribute) error
	// LoginComplete completes the login process by incrementing the state of the user
	LoginComplete() error
	// Revoke will revoke the user, setting the state of the user to be -1
	Revoke() error
	// IsRevoked returns back true if user is revoked
	IsRevoked() bool
	// GetLevel returns the level of the user, level is used to verify if the user needs migration
	GetLevel() int
	// SetLevel sets the level of the user
	SetLevel(level int) error
	// IncrementIncorrectPasswordAttempts updates the incorrect password count of user
	IncrementIncorrectPasswordAttempts() error
	// GetFailedLoginAttempts returns the number of times the user has entered an incorrect password
	GetFailedLoginAttempts() int
}

User is the SPI for a user

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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