soid_repo

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfig = errors.New("invalid config")
)

Functions

func AddIdentity

func AddIdentity(ctx context.Context, identity *domain.Identity) error

func AddNamespace

func AddNamespace(ctx context.Context, namespace *domain.Namespace) error

func AddRole

func AddRole(ctx context.Context, role *domain.Role) error

func AddRule

func AddRule(ctx context.Context, rule *domain.Rule) error

func AddSession

func AddSession(ctx context.Context, session *domain.Session) error

func AddUser

func AddUser(ctx context.Context, user *domain.User) error

func GetIdentity

func GetIdentity(ctx context.Context, identityID uint) (*domain.Identity, error)

func GetIdentityByName

func GetIdentityByName(ctx context.Context, namespace, name string) (*domain.Identity, error)

func GetIdentityByUserPass

func GetIdentityByUserPass(ctx context.Context, namespace string, username string, password string) (*domain.Identity, error)

func GetNamespace

func GetNamespace(ctx context.Context, namespaceID uint) (*domain.Namespace, error)

func GetNamespaceByName

func GetNamespaceByName(ctx context.Context, name string) (*domain.Namespace, error)

func GetNamespaceFromIdentity

func GetNamespaceFromIdentity(ctx context.Context, identityId uint) (*domain.Namespace, error)

func GetRole

func GetRole(ctx context.Context, roleID uint) (*domain.Role, error)

func GetRoleByName

func GetRoleByName(ctx context.Context, namespace string, name string) (*domain.Role, error)

func GetRule

func GetRule(ctx context.Context, ruleID uint) (*domain.Rule, error)

func GetRuleByName

func GetRuleByName(ctx context.Context, namespace string, name string) (*domain.Rule, error)

func GetSession

func GetSession(ctx context.Context, sessionID uint) (*domain.Session, error)

func GetSessionFromIdentity

func GetSessionFromIdentity(ctx context.Context, identityID uint) (*domain.Session, error)

func GetSoidConfig

func GetSoidConfig(ctx context.Context) (*domain.SOIDConfig, error)

SOIDConfigRepo

func GetUser

func GetUser(ctx context.Context, userID uint) (*domain.User, error)

func GetUserByName

func GetUserByName(ctx context.Context, namespace string, name string) (*domain.User, error)

func GetUserFromIdentity

func GetUserFromIdentity(ctx context.Context, identityId uint) (*domain.User, error)

func InitializeDefaultRepo

func InitializeDefaultRepo(cfgFile string) error

func RemoveIdentity

func RemoveIdentity(ctx context.Context, identityID uint) error

func RemoveNamespace

func RemoveNamespace(ctx context.Context, namespaceID uint) error

func RemoveRole

func RemoveRole(ctx context.Context, roleID uint) error

func RemoveRule

func RemoveRule(ctx context.Context, ruleID uint) error

func RemoveSession

func RemoveSession(ctx context.Context, sessionID uint) error

func RemoveUser

func RemoveUser(ctx context.Context, userID uint) error

func SetSoidConfig

func SetSoidConfig(ctx context.Context, cfg *domain.SOIDConfig) error

func UpdateIdentity

func UpdateIdentity(ctx context.Context, identity *domain.Identity) error

func UpdateNamespace

func UpdateNamespace(ctx context.Context, namespace *domain.Namespace) error

func UpdateRole

func UpdateRole(ctx context.Context, role *domain.Role) error

func UpdateRule

func UpdateRule(ctx context.Context, rule *domain.Rule) error

func UpdateSession

func UpdateSession(ctx context.Context, session *domain.Session) error

func UpdateUser

func UpdateUser(ctx context.Context, user *domain.User) error

Types

type FileSoidConfigRepo

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

func (*FileSoidConfigRepo) GetSoidConfig

func (r *FileSoidConfigRepo) GetSoidConfig(ctx context.Context) (*domain.SOIDConfig, error)

func (*FileSoidConfigRepo) SetSoidConfig

func (r *FileSoidConfigRepo) SetSoidConfig(ctx context.Context, cfg *domain.SOIDConfig) error

type IdentityRepo

type IdentityRepo interface {
	Migrate() error
	AddIdentity(ctx context.Context, identity *domain.Identity) error
	RemoveIdentity(ctx context.Context, identityID uint) error
	UpdateIdentity(ctx context.Context, identity *domain.Identity) error
	GetIdentity(ctx context.Context, identityID uint) (*domain.Identity, error)
	GetIdentityByName(ctx context.Context, namespace, name string) (*domain.Identity, error)
	ListIdentities(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListIdentitiesResult, error)
	GetIdentityByUserPass(ctx context.Context, namespace string, username string, password string) (*domain.Identity, error)
}

func NewSQLIdentityRepo

func NewSQLIdentityRepo(db *gorm.DB) IdentityRepo

type ListIdentitiesResult

type ListIdentitiesResult struct {
	Identities    []*domain.Identity
	TotalSize     int64
	NextPageToken string
}

func ListIdentities

func ListIdentities(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListIdentitiesResult, error)

type ListNamespacesResult

type ListNamespacesResult struct {
	Namespaces    []*domain.Namespace
	TotalSize     int64
	NextPageToken string
}

func ListNamespaces

func ListNamespaces(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, nextPageToken string, preload string) (*ListNamespacesResult, error)

type ListRolesResult

type ListRolesResult struct {
	Roles         []*domain.Role
	TotalSize     int64
	NextPageToken string
}

func ListRoles

func ListRoles(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListRolesResult, error)

type ListRulesResult

type ListRulesResult struct {
	Rules         []*domain.Rule
	TotalSize     int64
	NextPageToken string
}

func ListRules

func ListRules(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListRulesResult, error)

type ListSessionsResult

type ListSessionsResult struct {
	Sessions      []*domain.Session
	TotalSize     int64
	NextPageToken string
}

func ListSessions

func ListSessions(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListSessionsResult, error)

type ListUsersResult

type ListUsersResult struct {
	Users         []*domain.User
	TotalSize     int64
	NextPageToken string
}

func ListUsers

func ListUsers(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListUsersResult, error)

type NamespaceRepo

type NamespaceRepo interface {
	Migrate() error
	AddNamespace(ctx context.Context, namespace *domain.Namespace) error
	RemoveNamespace(ctx context.Context, namespaceID uint) error
	UpdateNamespace(ctx context.Context, namespace *domain.Namespace) error
	GetNamespace(ctx context.Context, namespaceID uint) (*domain.Namespace, error)
	GetNamespaceByName(ctx context.Context, name string) (*domain.Namespace, error)
	GetNamespaceFromIdentity(ctx context.Context, identityID uint) (*domain.Namespace, error)
	ListNamespaces(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, nextPageToken string, preload string) (*ListNamespacesResult, error)
}

func NewSQLNamespaceRepo

func NewSQLNamespaceRepo(db *gorm.DB) NamespaceRepo

type Query

type Query struct {
	Query       string
	QueryParams []interface{}
	OrderBy     string
	PageSize    int
	Page        int
	// contains filtered or unexported fields
}

func FromToken

func FromToken(token string, preload string) (*Query, error)

func NewQuery

func NewQuery(query string, queryParams []interface{}, orderBy string, pageSize int, preload string) *Query

func (*Query) Exec

func (q *Query) Exec(db *gorm.DB, result interface{}, totalCount *int64) error

func (*Query) IsCompatibleWith

func (q *Query) IsCompatibleWith(other *Query) bool

func (*Query) List

func (q *Query) List(db *gorm.DB, result interface{}, totalCount *int64) (*Query, error)

func (*Query) ToToken

func (q *Query) ToToken() (string, error)

type RoleRepo

type RoleRepo interface {
	Migrate() error
	AddRole(ctx context.Context, role *domain.Role) error
	RemoveRole(ctx context.Context, roleID uint) error
	UpdateRole(ctx context.Context, role *domain.Role) error
	GetRole(ctx context.Context, roleID uint) (*domain.Role, error)
	GetRoleByName(ctx context.Context, namespace string, name string) (*domain.Role, error)

	ListRoles(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListRolesResult, error)
}

type RuleRepo

type RuleRepo interface {
	Migrate() error
	AddRule(ctx context.Context, rule *domain.Rule) error
	RemoveRule(ctx context.Context, ruleID uint) error
	UpdateRule(ctx context.Context, rule *domain.Rule) error
	GetRule(ctx context.Context, ruleID uint) (*domain.Rule, error)
	GetRuleByName(ctx context.Context, namespace string, name string) (*domain.Rule, error)
	FindRulesForName(ctx context.Context, namespace string, name string) ([]*domain.Rule, error)
	ListRules(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListRulesResult, error)
}

func NewSQLRuleRepo

func NewSQLRuleRepo(db *gorm.DB) RuleRepo

type SOIDConfigRepo

type SOIDConfigRepo interface {
	GetSoidConfig(ctx context.Context) (*domain.SOIDConfig, error)
	SetSoidConfig(ctx context.Context, cfg *domain.SOIDConfig) error
}

func NewFileSoidConfigRepo

func NewFileSoidConfigRepo(filePath string) (SOIDConfigRepo, error)

type SQLIdentityRepo

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

func (*SQLIdentityRepo) AddIdentity

func (r *SQLIdentityRepo) AddIdentity(ctx context.Context, identity *domain.Identity) error

func (*SQLIdentityRepo) GetIdentity

func (r *SQLIdentityRepo) GetIdentity(ctx context.Context, identityID uint) (*domain.Identity, error)

func (*SQLIdentityRepo) GetIdentityByName

func (r *SQLIdentityRepo) GetIdentityByName(ctx context.Context, namespace, name string) (*domain.Identity, error)

func (*SQLIdentityRepo) GetIdentityByUserPass

func (r *SQLIdentityRepo) GetIdentityByUserPass(ctx context.Context, namespace string, username string, password string) (*domain.Identity, error)

func (*SQLIdentityRepo) ListIdentities

func (r *SQLIdentityRepo) ListIdentities(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListIdentitiesResult, error)

func (*SQLIdentityRepo) Migrate

func (r *SQLIdentityRepo) Migrate() error

func (*SQLIdentityRepo) RemoveIdentity

func (r *SQLIdentityRepo) RemoveIdentity(ctx context.Context, identityID uint) error

func (*SQLIdentityRepo) UpdateIdentity

func (r *SQLIdentityRepo) UpdateIdentity(ctx context.Context, identity *domain.Identity) error

type SQLNamespaceRepo

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

func (*SQLNamespaceRepo) AddNamespace

func (r *SQLNamespaceRepo) AddNamespace(ctx context.Context, namespace *domain.Namespace) error

func (*SQLNamespaceRepo) GetNamespace

func (r *SQLNamespaceRepo) GetNamespace(ctx context.Context, namespaceID uint) (*domain.Namespace, error)

func (*SQLNamespaceRepo) GetNamespaceByName

func (r *SQLNamespaceRepo) GetNamespaceByName(ctx context.Context, name string) (*domain.Namespace, error)

func (*SQLNamespaceRepo) GetNamespaceFromIdentity

func (r *SQLNamespaceRepo) GetNamespaceFromIdentity(ctx context.Context, identityId uint) (*domain.Namespace, error)

func (*SQLNamespaceRepo) ListNamespaces

func (r *SQLNamespaceRepo) ListNamespaces(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, nextPageToken string, preload string) (*ListNamespacesResult, error)

func (*SQLNamespaceRepo) Migrate

func (r *SQLNamespaceRepo) Migrate() error

func (*SQLNamespaceRepo) RemoveNamespace

func (r *SQLNamespaceRepo) RemoveNamespace(ctx context.Context, namespaceID uint) error

func (*SQLNamespaceRepo) UpdateNamespace

func (r *SQLNamespaceRepo) UpdateNamespace(ctx context.Context, namespace *domain.Namespace) error

type SQLRepository

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

func GetDefaultRepo

func GetDefaultRepo() *SQLRepository

func NewSqlRepository

func NewSqlRepository(soidCfgFile string) (*SQLRepository, error)

func (*SQLRepository) DB

func (r *SQLRepository) DB() *gorm.DB

func (*SQLRepository) Identities

func (r *SQLRepository) Identities() IdentityRepo

func (*SQLRepository) Migrate

func (r *SQLRepository) Migrate() error

func (*SQLRepository) Namespaces

func (r *SQLRepository) Namespaces() NamespaceRepo

func (*SQLRepository) Roles

func (r *SQLRepository) Roles() RoleRepo

func (*SQLRepository) Rules

func (r *SQLRepository) Rules() RuleRepo

func (*SQLRepository) SOIDConfig

func (r *SQLRepository) SOIDConfig() SOIDConfigRepo

func (*SQLRepository) Sessions

func (r *SQLRepository) Sessions() SessionRepo

func (*SQLRepository) Users

func (r *SQLRepository) Users() UserRepo

type SQLRoleRepo

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

func NewSQLRoleRepo

func NewSQLRoleRepo(db *gorm.DB) *SQLRoleRepo

func (*SQLRoleRepo) AddRole

func (r *SQLRoleRepo) AddRole(ctx context.Context, role *domain.Role) error

func (*SQLRoleRepo) GetRole

func (r *SQLRoleRepo) GetRole(ctx context.Context, roleID uint) (*domain.Role, error)

func (*SQLRoleRepo) GetRoleByName

func (r *SQLRoleRepo) GetRoleByName(ctx context.Context, namespace string, name string) (*domain.Role, error)

func (*SQLRoleRepo) ListRoles

func (r *SQLRoleRepo) ListRoles(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListRolesResult, error)

func (*SQLRoleRepo) Migrate

func (r *SQLRoleRepo) Migrate() error

func (*SQLRoleRepo) RemoveRole

func (r *SQLRoleRepo) RemoveRole(ctx context.Context, roleID uint) error

func (*SQLRoleRepo) UpdateRole

func (r *SQLRoleRepo) UpdateRole(ctx context.Context, role *domain.Role) error

type SQLRuleRepo

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

func (*SQLRuleRepo) AddRule

func (r *SQLRuleRepo) AddRule(ctx context.Context, rule *domain.Rule) error

func (*SQLRuleRepo) FindRulesForName

func (r *SQLRuleRepo) FindRulesForName(ctx context.Context, namespace string, name string) ([]*domain.Rule, error)

Find all rules that apply for the namespace/name combination

func (*SQLRuleRepo) GetRule

func (r *SQLRuleRepo) GetRule(ctx context.Context, ruleID uint) (*domain.Rule, error)

func (*SQLRuleRepo) GetRuleByName

func (r *SQLRuleRepo) GetRuleByName(ctx context.Context, namespace string, name string) (*domain.Rule, error)

func (*SQLRuleRepo) ListRules

func (r *SQLRuleRepo) ListRules(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListRulesResult, error)

func (*SQLRuleRepo) Migrate

func (r *SQLRuleRepo) Migrate() error

func (*SQLRuleRepo) RemoveRule

func (r *SQLRuleRepo) RemoveRule(ctx context.Context, ruleID uint) error

func (*SQLRuleRepo) UpdateRule

func (r *SQLRuleRepo) UpdateRule(ctx context.Context, rule *domain.Rule) error

type SQLSessionRepo

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

func (*SQLSessionRepo) AddSession

func (r *SQLSessionRepo) AddSession(ctx context.Context, session *domain.Session) error

func (*SQLSessionRepo) GetSession

func (r *SQLSessionRepo) GetSession(ctx context.Context, sessionID uint) (*domain.Session, error)

func (*SQLSessionRepo) GetSessionFromIdentity

func (r *SQLSessionRepo) GetSessionFromIdentity(ctx context.Context, identityId uint) (*domain.Session, error)

func (*SQLSessionRepo) ListSessions

func (r *SQLSessionRepo) ListSessions(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListSessionsResult, error)

func (*SQLSessionRepo) Migrate

func (r *SQLSessionRepo) Migrate() error

func (*SQLSessionRepo) RemoveSession

func (r *SQLSessionRepo) RemoveSession(ctx context.Context, sessionID uint) error

func (*SQLSessionRepo) UpdateSession

func (r *SQLSessionRepo) UpdateSession(ctx context.Context, session *domain.Session) error

type SQLUserRepo

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

func (*SQLUserRepo) AddUser

func (r *SQLUserRepo) AddUser(ctx context.Context, user *domain.User) error

func (*SQLUserRepo) GetUser

func (r *SQLUserRepo) GetUser(ctx context.Context, userID uint) (*domain.User, error)

func (*SQLUserRepo) GetUserByName

func (r *SQLUserRepo) GetUserByName(ctx context.Context, namespace, name string) (*domain.User, error)

func (*SQLUserRepo) GetUserFromIdentity

func (r *SQLUserRepo) GetUserFromIdentity(ctx context.Context, identityId uint) (*domain.User, error)

func (*SQLUserRepo) ListUsers

func (r *SQLUserRepo) ListUsers(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListUsersResult, error)

func (*SQLUserRepo) Migrate

func (r *SQLUserRepo) Migrate() error

func (*SQLUserRepo) RemoveUser

func (r *SQLUserRepo) RemoveUser(ctx context.Context, userID uint) error

func (*SQLUserRepo) UpdateUser

func (r *SQLUserRepo) UpdateUser(ctx context.Context, user *domain.User) error

type SessionRepo

type SessionRepo interface {
	Migrate() error
	AddSession(ctx context.Context, session *domain.Session) error
	RemoveSession(ctx context.Context, sessionID uint) error
	UpdateSession(ctx context.Context, session *domain.Session) error
	GetSession(ctx context.Context, sessionID uint) (*domain.Session, error)
	GetSessionFromIdentity(ctx context.Context, identityID uint) (*domain.Session, error)
	ListSessions(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListSessionsResult, error)
}

func NewSQLSessionRepo

func NewSQLSessionRepo(db *gorm.DB) SessionRepo

type UserRepo

type UserRepo interface {
	Migrate() error
	AddUser(ctx context.Context, user *domain.User) error
	RemoveUser(ctx context.Context, userID uint) error
	UpdateUser(ctx context.Context, user *domain.User) error
	GetUser(ctx context.Context, userID uint) (*domain.User, error)
	GetUserByName(ctx context.Context, namespace, name string) (*domain.User, error)

	ListUsers(ctx context.Context, query string, queryParams []interface{}, orderBy string, pageSize int, page int, nextPageToken string, preload string) (*ListUsersResult, error)
	GetUserFromIdentity(ctx context.Context, identityID uint) (*domain.User, error)
}

func NewSQLUserRepo

func NewSQLUserRepo(db *gorm.DB) UserRepo

Jump to

Keyboard shortcuts

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