entities

package
v0.0.0-...-718b68f Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Employee

type Employee struct {
	ID        primitive.ObjectID `bson:"_id"`
	Email     string             `bson:"email,omitempty"`
	Password  string             `bson:"password,omitempty" json:"-"`
	Name      string             `bson:"name,omitempty"`
	Phone     string             `bson:"phone,omitempty"`
	CreatedAt *time.Time         `bson:"created_at,omitempty"`
	UpdatedAt *time.Time         `bson:"updated_at,omitempty"`
	Roles     []Role             `bson:"roles,omitempty"`
}

Employee entity definition.

func (*Employee) GetEntity

func (employee *Employee) GetEntity() string

GetEntity returns type employee's type of entity.

func (*Employee) GetID

func (employee *Employee) GetID() primitive.ObjectID

GetID returns employee's ID.

func (*Employee) GetLogin

func (employee *Employee) GetLogin() string

GetLogin returns employee's email as Login.

func (*Employee) GetRoles

func (employee *Employee) GetRoles() []Role

GetRoles returns employee's roles.

type Event

type Event struct {
	EventID       string `bson:"event_id"`
	Channel       string
	Type          EventType
	AggregateID   string
	AggregateType string
	Data          interface{}
	Originator    EventOriginator
	CreatedAt     time.Time
}

Event entity definition.

type EventOriginator

type EventOriginator struct {
	EntityID primitive.ObjectID `bson:"entity_id"`
	Entity   string
	Login    string
}

type EventType

type EventType string
const (
	NewEmployeeEvent    EventType = "NewEmployee"
	UpdateEmployeeEvent EventType = "UpdateEmployee"
	DeleteEmployeeEvent EventType = "DeleteEmployee"
)

type Role

type Role struct {
	ID   primitive.ObjectID `bson:"_id"`
	Name string             `bson:"name,omitempty"`
}

Role entity definition.

type TokenClaimer

type TokenClaimer interface {
	GetID() primitive.ObjectID
	GetEntity() string
	GetLogin() string
	GetRoles() []Role
}

TokenClaimer represents interface of entity that is able to provide auth claims parameters and login into system.

type TokenClaims

type TokenClaims struct {
	Entity             string             `json:"entity"`
	EntityID           primitive.ObjectID `json:"entity_id"`
	Login              string             `json:"login"`
	Roles              []string           `json:"roles"`
	jwt.StandardClaims `bson:"-"`
}

TokenClaims repesents JWT authentication claims.

func NewTokenClaims

func NewTokenClaims(expiration time.Duration, entity TokenClaimer) *TokenClaims

NewTokenClaims returns JWT claims for specified entity.

func (*TokenClaims) HasRole

func (claims *TokenClaims) HasRole(authorizedRoles []string) bool

HasRole verifies that claims has at least one of given roles.

Jump to

Keyboard shortcuts

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