model

package
v19.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessPermission

type AccessPermission struct {
	ID              uint   `gorm:"primary_key; AUTO_INCREMENT"`
	ResourcePattern string `gorm:"not nul"`
	Action          string `gorm:"not nul"`
	RoleID          uint
}

AccessPermission defines access pemission of a role towards a resource offered by a service

type DataAccess

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

DataAccess wraps access to the database and implements utility requests

func NewDataAccess

func NewDataAccess(dialect, dsn string) *DataAccess

NewDataAccess creates a new DataAccess

func (*DataAccess) Get

func (da *DataAccess) Get() (*gorm.DB, error)

Get returns database access

func (*DataAccess) GetServiceByName

func (da *DataAccess) GetServiceByName(name string) (srv *Service, err error)

GetServiceByName get service by name

func (*DataAccess) GetUserAccessPermissionsByService

func (da *DataAccess) GetUserAccessPermissionsByService(email, serviceName string) (permissions []AccessPermission, err error)

GetUserAccessPermissionsByService get user access permission by service

func (*DataAccess) Init

func (da *DataAccess) Init() (err error)

Init initialize the database: drop tables if exists and create new empty ones

type Role

type Role struct {
	ID                uint `gorm:"primary_key; AUTO_INCREMENT"`
	Name              string
	ServiceID         uint
	AccessPermissions []AccessPermission
	Users             []User `gorm:"many2many:user_roles;" `
}

Role define a role relative to a service

type Service

type Service struct {
	ID      uint   `gorm:"primary_key; AUTO_INCREMENT"`
	Name    string `gorm:"unique_index"`
	BaseURL string
	Roles   []Role
}

Service is a resource secured by the Gateway

type User

type User struct {
	ID    uint   `gorm:"primary_key; AUTO_INCREMENT"`
	Email string `gorm:"unique_index"`
	Roles []Role `gorm:"many2many:user_roles;"`
}

User defines a user

Jump to

Keyboard shortcuts

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