vmod

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessConfig = middleware.JWTConfig{
	Claims:     &AccessToken{},
	ContextKey: "token",
	SigningKey: []byte(os.Getenv("JWT_SECRET")),
}

AccessConfig can with echo for middleware.JWTWithConfig(vmod.AccessConfig) to handling access controll The token is reachable with c.Get("token")

View Source
var RefreshConfig = middleware.JWTConfig{
	Claims:     &RefreshToken{},
	ContextKey: "token",
	SigningKey: []byte(os.Getenv("JWT_SECRET")),
}

RefreshConfig can with echo for middleware.JWTWithConfig(vmod.AccessConfig) to handling access controll The token is reachable with c.Get("token")

Functions

func RespCreateBase

func RespCreateBase(model string) (int, interface{})

RespCreateBase creates the created response without payload

func RespCreated

func RespCreated(i interface{}, model string) (int, interface{})

RespCreated creates the created response

func RespDeleted

func RespDeleted(model string) (int, interface{})

RespDeleted creates the updated response

func RespExecuted

func RespExecuted(model string) (int, interface{})

RespExecuted creates the execution response for handling for example sending emails.

func RespSelected

func RespSelected(i interface{}, model string) (int, interface{})

RespSelected creates the selected response

func RespUpdated

func RespUpdated(model string) (int, interface{})

RespUpdated creates the updated response

Types

type APIResponse

type APIResponse struct {
	Message string      `json:"message"`
	Model   string      `json:"model"`
	Payload interface{} `json:"payload,omitempty"`
}

APIResponse type that will response in success cases

type Access

type Access struct {
	Role    string `json:"role" bson:"role"`
	Created int64  `json:"created" bson:"created"`
}

Access represents access to an model.

type AccessList

type AccessList []Access

AccessList list of access model

func (AccessList) Map

func (a AccessList) Map() map[string]string

Map converts an access list into map

type AccessToken

type AccessToken struct {
	User User `json:"user"`
	jwt.StandardClaims
}

AccessToken represents the access token contained in JWTToken

type Campaign

type Campaign struct {
	ID          string        `bson:"_id" json:"id" validate:"required"`
	CiviID      int           `bson:"civi_id" json:"civi_id" validate:"required"`
	Name        string        `bson:"name" json:"name" validate:"required"`
	Description string        `bson:"name" json:"description" validate:"required"`
	Tags        []string      `bson:"tags" json:"tags" validate:"required"`
	Type        string        `bson:"type" json:"type" validate:"required"`
	Modified    vmdb.Modified `bson:"modified" json:"modified" validate:"required"`
}

Campaign represents a default campaign model

type CodeRequest

type CodeRequest struct {
	Code string `json:"code"`
	Case string `json:"case,omitempty"`
}

CodeRequest used for handling LinkToken code.

type ContentText

type ContentText map[string]string

type DisplayContent

type DisplayContent struct {
	Language    []string               `bson:"language" json:"language"`
	Keys        []string               `bson:"keys" json:"keys"`
	Translation map[string]ContentText `bson:"translation" json:"translation"`
	Default     string                 `bson:"default" json:"default"`
}

func (*DisplayContent) Validate

func (dc *DisplayContent) Validate() *DisplayContent

type JWTToken

type JWTToken struct {
	AccessToken  string `json:"access_token" bson:"access_token"`
	RefreshToken string `json:"refresh_token" bson:"refresh_token"`
	TokenType    string `json:"token_type" bson:"token_type"`
	ExpiresAt    int64  `json:"expires_at" bson:"expires_at"`
	Scope        string `json:"scope" bson:"scope"`
}

JWTToken represents the all access and refresh tokens

func NewJWTToken

func NewJWTToken(u *User, scope string) (*JWTToken, error)

NewJWTToken returns a new JWTToken model contains an access and an refresh token

type MID

type MID struct {
	ID   string `bson:"id" json:"id"`
	Type string `bson:"type" json:"type"`
}

func NewMID

func NewMID(id string, t string) *MID

type MailBase

type MailBase struct {
	To       string `json:"to" bson:"to"`
	JobCase  string `json:"job_case"`
	JobScope string `json:"job_scope"`
	Country  string `json:"country"`
}

MailBase base model for request mail-backend via nats

type MailCode

type MailCode struct {
	MailBase
	UserName string `json:"user_name"`
	Code     string `json:"code"`
}

MailCode used for request mail-backend via nats

func NewMailCode

func NewMailCode(to string, jobCase string, jobScope string, userName string, code string) MailCode

NewMailCode initial new MailCode from given variables.

type MailContactAt

type MailContactAt struct {
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Comment   string `json:"comment"`
	Email     string `json:"email"`
	KnownFrom string `json:"known_from"`
}

type MultiLang

type MultiLang struct {
	Language    []string          `bson:"language" json:"language"`
	Translation map[string]string `bson:"translation" json:"translation"`
}

func (*MultiLang) Insert

func (m *MultiLang) Insert() *MultiLang

type PValidate

type PValidate map[string][]string

PValidate used for controller permission handling

func (*PValidate) Restricted

func (pVal *PValidate) Restricted(next echo.HandlerFunc) echo.HandlerFunc

Restricted middleware function for handling Access

type Permission

type Permission map[string]AccessList

Permission represents role to an access

func NewPermission

func NewPermission(app string, role string) *Permission

NewPermission map role to []Access(modelID, created) and initial Permission.

func (*Permission) Add

func (p *Permission) Add(app string, role string) *Permission

Add Access(modelID created) to role.

func (*Permission) Delete

func (p *Permission) Delete(role string, modelID string) *Permission

Delete Access from role. If []Access is nil the role will remove form Permission.

func (*Permission) Validate

func (p *Permission) Validate(pValidate *PValidate) bool

Validate validates the permission for middleware functions

type RefreshToken

type RefreshToken struct {
	UserID string `json:"user_id"`
	jwt.StandardClaims
}

RefreshToken represents the refresh token contained in JWTToken

type SimpleID

type SimpleID struct {
	ID    string `bson:"id" json:"id"`
	Name  string `bson:"name" json:"name"`
	Model string `bson:"model" json:"model"`
}

Jump to

Keyboard shortcuts

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