data

package
v0.0.0-...-16f93d8 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBManager

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

DBManager is the database manager for user/application/role storage token storage

func NewDBManager

func NewDBManager(systemdbpath, tokendbpath string) (*DBManager, error)

NewDBManager creates a new instance of a SystemDB

func (DBManager) AddResource

func (store DBManager) AddResource(context User, resource Resource) (Resource, error)

AddResource adds a resource to the system

func (DBManager) AddRole

func (store DBManager) AddRole(context User, role Role) (Role, error)

AddRole adds a role to the system

func (DBManager) AddUser

func (store DBManager) AddUser(context User, user User, userPassword string) (User, error)

AddUser adds a user to the system

func (DBManager) AddUserToResourceWithRole

func (store DBManager) AddUserToResourceWithRole(context, user User, resource Resource, role Role) (UserResourceRole, error)

AddUserToResourceWithRole adds the specified user to the resource and assigns the given role. Returns an error if the user, resource, or role don't already exist

func (DBManager) AuthSystemBootstrap

func (store DBManager) AuthSystemBootstrap() (User, string, error)

AuthSystemBootstrap initializes the SystemDB and creates any default admin users / roles / resources

func (DBManager) Close

func (store DBManager) Close() error

Close closes the SystemDB database

func (DBManager) GetAllResources

func (store DBManager) GetAllResources(context User) ([]Resource, error)

GetAllResources returns an array of all resources

func (DBManager) GetAllRoles

func (store DBManager) GetAllRoles(context User) ([]Role, error)

GetAllRoles returns an array of all roles

func (DBManager) GetAllUsers

func (store DBManager) GetAllUsers(context User) ([]User, error)

GetAllUsers returns an array of all users

func (DBManager) GetNewToken

func (store DBManager) GetNewToken(user User, expiresafter time.Duration) (Token, error)

GetNewToken gets a token for the given user. If a token already exists it expires the existing token, generates a new token, stores it, and returns it. If a token doesn't already exist (or it has expired) it generates a new token, stores it, and returns it

func (DBManager) GetScopesForToken

func (store DBManager) GetScopesForToken(tokenID string) (ScopeUser, error)

GetScopesForToken gets scope information for a given token

func (DBManager) GetUserScopesWithCredentials

func (store DBManager) GetUserScopesWithCredentials(name, secret string) (ScopeUser, error)

GetUserScopesWithCredentials - verifies credentials and returns the scopeuser hierarchy

type Defaults

type Defaults struct {
	// AdminUser is the admin user id
	AdminUser string

	// SystemResource is the system resource id
	SystemResource string

	// AdminRole is the system admin role id
	AdminRole string

	// ResourceDelegateRole is the resource delegate role id
	ResourceDelegateRole string
}

Defaults encapsulates system defaults

var BuiltIn Defaults

BuiltIn is a catalog of system default values

type Resource

type Resource struct {
	ID          string      `json:"id"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Created     time.Time   `json:"created"`
	CreatedBy   string      `json:"created_by"`
	Updated     time.Time   `json:"updated"`
	UpdatedBy   string      `json:"updated_by"`
	Deleted     zero.Time   `json:"deleted"`
	DeletedBy   null.String `json:"deleted_by"`
}

Resource represents an application / resource / service in the system It is associated with users (and user roles)

type Role

type Role struct {
	ID          string      `json:"id"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Created     time.Time   `json:"created"`
	CreatedBy   string      `json:"created_by"`
	Updated     time.Time   `json:"updated"`
	UpdatedBy   string      `json:"updated_by"`
	Deleted     zero.Time   `json:"deleted"`
	DeletedBy   null.String `json:"deleted_by"`
}

Role defines a role or permission that a user is assigned within an application/role/service

type ScopeResource

type ScopeResource struct {
	ID          string
	Name        string
	Description string
	ScopeRoles  []ScopeRole
}

ScopeResource is part of the user/resource/role scope hierarchy

type ScopeRole

type ScopeRole struct {
	ID          string
	Name        string
	Description string
}

ScopeRole is part of the user/resource/role scope hierarchy

type ScopeUser

type ScopeUser struct {
	ID             string
	Name           string
	Description    string
	ScopeResources []ScopeResource
}

ScopeUser is a hierarchy of a user and the resource and role scopes they have been assigned

type Token

type Token struct {
	ID        string `json:"token"`
	UserID    string
	Created   time.Time
	Expires   time.Time `json:"expires"`
	Deleted   zero.Time
	DeletedBy null.String
}

Token represents an auth token

type User

type User struct {
	ID          string      `json:"id"`
	Enabled     bool        `json:"enabled"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	SecretHash  string      `json:"secrethash"`
	Created     time.Time   `json:"created"`
	CreatedBy   string      `json:"created_by"`
	Updated     time.Time   `json:"updated"`
	UpdatedBy   string      `json:"updated_by"`
	Deleted     zero.Time   `json:"deleted"`
	DeletedBy   null.String `json:"deleted_by"`
}

User represents a user in the system. Users are associated with resources and roles within those applications/resources/services. They can be created/updated/deleted. If they are deleted, eventually they will be removed from the system. The admin user can only be disabled, not deleted

type UserResourceRole

type UserResourceRole struct {
	UserID     string      `json:"userid"`
	ResourceID string      `json:"resourceid"`
	RoleID     string      `json:"roleid"`
	Created    time.Time   `json:"created"`
	CreatedBy  string      `json:"created_by"`
	Updated    time.Time   `json:"updated"`
	UpdatedBy  string      `json:"updated_by"`
	Deleted    zero.Time   `json:"deleted"`
	DeletedBy  null.String `json:"deleted_by"`
}

UserResourceRole defines a relationship between a user, a resource (application/service), and the roles that user has been assigned within the resource (application/service)

Jump to

Keyboard shortcuts

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