db

package
v0.0.0-...-86f439f Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserNoAdmin = iota
	NsAdmin
	QuidAdmin
)

Variables

View Source
var (
	ErrUsernameTooShort = errors.New("username must have more than 2 characters")
	ErrPasswordTooShort = errors.New("password must have more than 5 characters")
)

Functions

func AddUserInGroup

func AddUserInGroup(usrID, grpID int64) error

AddUserInGroup : add a user into a group.

func AddUserInOrg

func AddUserInOrg(usrID, orgID int64) error

AddUserInOrg : add a user into an org.

func Connect

func Connect(url string) error

Connect : connect to the db.

func CountUsersForNamespace

func CountUsersForNamespace(id int64) (int, error)

CountUsersForNamespace : count users in a namespace.

func CountUsersInGroup

func CountUsersInGroup(grpID int64) (int, error)

CountUsersInGroup : count the users in a group.

func CreateAdministrator

func CreateAdministrator(nsID, usrID int64) error

CreateAdministrator : create an admin user.

func CreateGroup

func CreateGroup(name string, nsID int64) (int64, error)

CreateGroup : create a group.

func CreateNamespace

func CreateNamespace(name, ttl, refreshTTL, algo string, accessKey, refreshKey []byte, endpoint bool) (int64, error)

CreateNamespace : create a namespace.

func CreateOrg

func CreateOrg(name string) (int64, error)

CreateOrg : create an org.

func CreateQuidAdminIfMissing

func CreateQuidAdminIfMissing(username, password string) error

func CreateTablesIndexesIfMissing

func CreateTablesIndexesIfMissing() error

CreateTablesIndexesIfMissing : execute the schema.

func CreateUser

func CreateUser(name, password string, nsID int64) (server.User, error)

CreateUser : create a user.

func CreateUserFromNameAndPassword

func CreateUserFromNameAndPassword(name, passwordHash string, nsID int64) (int64, error)

CreateUserFromNameAndPassword : create a user.

func DeleteAdministrator

func DeleteAdministrator(usrID, nsID int64) error

DeleteAdministrator : delete an admin user for a namespace.

func DeleteGroup

func DeleteGroup(id int64) error

DeleteGroup : delete a group.

func DeleteOrg

func DeleteOrg(id int64) error

DeleteOrg : delete an org.

func DeleteUser

func DeleteUser(id int64) error

DeleteUser : delete a user.

func DropDatabase

func DropDatabase(dbName string) error

DropDatabase executes "DROP DATABASE $POSTGRES_DB;".

func DropTablesIndexes

func DropTablesIndexes() error

DropTablesIndexes deletes all tables and indexes from DB.

func EnableNsEndpoint

func EnableNsEndpoint(id int64, enable bool) error

EnableNsEndpoint : enable or disable public endpoint.

func GroupExists

func GroupExists(name string, nsID int64) (bool, error)

GroupExists : check if an group exists.

func IsUserAnAdmin

func IsUserAnAdmin(usrID, nsID int64) (bool, error)

IsUserAnAdmin : check if an admin user exists.

func IsUserInAdminGroup

func IsUserInAdminGroup(uID, nsID int64) (bool, error)

IsUserInAdminGroup : check if a user is in quid admin group

func IsUserInGroup

func IsUserInGroup(usrID, grpID int64) (bool, error)

IsUserInGroup : check if a user is in a group.

func NamespaceExists

func NamespaceExists(name string) (bool, error)

NamespaceExists : check if a namespace exists.

func OrgExists

func OrgExists(name string) (bool, error)

OrgExists : check if an org exists.

func RemoveUserFromGroup

func RemoveUserFromGroup(usrID, grpID int64) error

RemoveUserFromGroup : remove a user from a group.

func RemoveUserFromOrg

func RemoveUserFromOrg(usrID, orgID int64) error

RemoveUserFromOrg : remove a user from an org.

func SelectAllGroups

func SelectAllGroups() ([]server.Group, error)

SelectAllGroups : get all the groups.

func SelectAllNamespaces

func SelectAllNamespaces() ([]server.Namespace, error)

SelectAllNamespaces : get the namespaces.

func SelectAllOrgs

func SelectAllOrgs() ([]server.Org, error)

SelectAllOrgs : get all the orgs.

func SelectAllUsers

func SelectAllUsers() ([]server.User, error)

SelectAllUsers : get the users.

func SelectEnabledUser

func SelectEnabledUser(name string, nsID int64) (server.User, error)

SelectEnabledUser : get a user from it's name.

func SelectGroup

func SelectGroup(name string, nsID int64) (server.Group, error)

SelectGroup : get a group.

func SelectGroupsForUser

func SelectGroupsForUser(usrID int64) ([]server.Group, error)

SelectGroupsForUser : get the groups for a user.

func SelectGroupsNamesForUser

func SelectGroupsNamesForUser(usrID int64) ([]string, error)

SelectGroupsNamesForUser : get the groups for a user.

func SelectNsFromName

func SelectNsFromName(nsName string) (server.Namespace, error)

SelectNsFromName : get a namespace.

func SelectNsGroups

func SelectNsGroups(nsID int64) ([]server.Group, error)

SelectNsGroups : get the groups for a namespace.

func SelectNsID

func SelectNsID(name string) (int64, error)

SelectNsID : get a namespace.

func SelectNsStartsWith

func SelectNsStartsWith(name string) ([]server.Namespace, error)

SelectNsStartsWith : get a namespace.

func SelectNsUsers

func SelectNsUsers(nsID int64) ([]server.User, error)

SelectNsUsers : get the users in a namespace.

func SelectOrg

func SelectOrg(name string) (server.Org, error)

SelectOrg : get a org.

func SelectOrgStartsWith

func SelectOrgStartsWith(name string) ([]server.Org, error)

SelectOrgStartsWith : get a namespace.

func SelectOrgsForUser

func SelectOrgsForUser(usrID int64) ([]server.Org, error)

SelectOrgsForUser : get the orgs for a user.

func SelectOrgsNamesForUser

func SelectOrgsNamesForUser(usrID int64) ([]string, error)

SelectOrgsNamesForUser : get the orgs for a user.

func SelectVerificationKeyDER

func SelectVerificationKeyDER(id int64) (found bool, algo string, der []byte, _ error)

SelectVerificationKeyDER get the AccessToken key (in DER form) for a namespace.

func UpdateNsRefreshMaxTTL

func UpdateNsRefreshMaxTTL(id int64, refreshMaxTTL string) error

UpdateNsRefreshMaxTTL : update a max refresh token ttl for a namespace.

func UpdateNsTokenMaxTTL

func UpdateNsTokenMaxTTL(id int64, maxTTL string) error

UpdateNsTokenMaxTTL : update a max access token ttl for a namespace.

func UserExists

func UserExists(name string, nsID int64) (bool, error)

UserExists : check if a name exists.

Types

type Administrator

type Administrator struct {
	ID    int64  `json:"id"       db:"id"`
	Name  string `json:"name"     db:"name"`
	UsrID int64  `json:"usr_id"   db:"usr_id"`
	NsID  int64  `json:"ns_id"    db:"ns_id"`
}

Administrator : base model.

func SelectAdministrators

func SelectAdministrators(nsID int64) ([]Administrator, error)

SelectAdministrators : get the admin users in a namespace.

type NonAdmin

type NonAdmin struct {
	Name  string `json:"name"     db:"name"`
	UsrID int64  `json:"usr_id"   db:"usr_id"`
	NsID  int64  `json:"ns_id"    db:"ns_id"`
}

NonAdmin : base model.

func SelectNonAdministrators

func SelectNonAdministrators(nsID int64, qs string) ([]NonAdmin, error)

SelectNonAdministrators : find non admin users in a namespace

type QueryError

type QueryError struct {
	Message        string
	HasUserMessage bool
}

QueryError :.

func (*QueryError) Error

func (e *QueryError) Error() string

type QueryResult

type QueryResult struct {
	Error    QueryError
	HasError bool
}

QueryResult :.

func DeleteNamespace

func DeleteNamespace(id int64) QueryResult

DeleteNamespace : delete a namespace.

type UserType

type UserType int

func GetUserType

func GetUserType(nsName string, nsID, usrID int64) (UserType, error)

GetUserType checks if a user is

Jump to

Keyboard shortcuts

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