model

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ApiKeyCollectionName = "api_keys"
View Source
const KeystoreCollectionName = "keystores"

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiKey

type ApiKey struct {
	ID          primitive.ObjectID `bson:"_id,omitempty"`
	Key         string             `bson:"key" validate:"required,max=1024"`
	Version     int                `bson:"version" validate:"required,min=1,max=100"`
	Permissions []Permission       `bson:"permissions" validate:"required"`
	Comments    []string           `bson:"comments" validate:"required,max=1000"`
	Status      bool               `bson:"status" validate:"-"`
	CreatedAt   time.Time          `bson:"createdAt" validate:"-"`
	UpdatedAt   time.Time          `bson:"updatedAt" validate:"-"`
}

func NewApiKey

func NewApiKey(key string, version int, permissions []Permission, comments []string) *ApiKey

func (*ApiKey) EnsureIndexes

func (*ApiKey) EnsureIndexes(db mongo.Database)

func (*ApiKey) GetValue

func (apikey *ApiKey) GetValue() *ApiKey

func (*ApiKey) Validate

func (apikey *ApiKey) Validate() error

type Keystore

type Keystore struct {
	ID           primitive.ObjectID `bson:"_id,omitempty"`
	Client       primitive.ObjectID `bson:"client" validate:"required"`
	PrimaryKey   string             `bson:"pKey" validate:"required"`
	SecondaryKey string             `bson:"sKey" validate:"required"`
	Status       bool               `bson:"status" validate:"-"`
	CreatedAt    time.Time          `bson:"createdAt" validate:"required"`
	UpdatedAt    time.Time          `bson:"updatedAt" validate:"required"`
}

func NewKeystore

func NewKeystore(clientID primitive.ObjectID, primaryKey string, secondaryKey string) (*Keystore, error)

func (*Keystore) EnsureIndexes

func (*Keystore) EnsureIndexes(db mongo.Database)

func (*Keystore) GetValue

func (keystore *Keystore) GetValue() *Keystore

func (*Keystore) Validate

func (keystore *Keystore) Validate() error

type Permission

type Permission string
const (
	GeneralPermission Permission = "GENERAL"
)

Jump to

Keyboard shortcuts

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