gcom

package
v0.0.0-...-98f13d6 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRoleType     = errors.New("Invalid role type")
	ErrInvalidApiKey       = errors.New("Invalid API Key")
	ErrInvalidOrgId        = errors.New("Invalid Org Id")
	ErrInvalidInstanceID   = errors.New("Invalid Instance ID")
	ErrInvalidInstanceType = errors.New("Invalid Instance Type")
	ErrInvalidCluster      = errors.New("Invalid Cluster")
)

Typed errors

Functions

func InitInstanceCache

func InitInstanceCache()

func InitTokenCache

func InitTokenCache()

func StopInstanceCache

func StopInstanceCache()

func StopTokenCache

func StopTokenCache()

func ValidateInstance

func ValidateInstance(cacheKey string) error

Types

type Instance

type Instance struct {
	ID           int64  `json:"id"`
	OrgID        int    `json:"orgId"`
	ClusterName  string `json:"clusterName"`
	ClusterID    int    `json:"clusterId"`
	InstanceType string `json:"type"`
}

type InstanceCache

type InstanceCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*InstanceCache) Clear

func (c *InstanceCache) Clear()

func (*InstanceCache) Get

func (c *InstanceCache) Get(key string) (bool, bool)

func (*InstanceCache) Set

func (c *InstanceCache) Set(key string, valid bool)

type InstanceResp

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

type RoleType

type RoleType string
const (
	ROLE_VIEWER            RoleType = "Viewer"
	ROLE_EDITOR            RoleType = "Editor"
	ROLE_METRICS_PUBLISHER RoleType = "MetricsPublisher"
	ROLE_ADMIN             RoleType = "Admin"
)

func (RoleType) IsPublisher

func (r RoleType) IsPublisher() bool

func (RoleType) IsValid

func (r RoleType) IsValid() bool

func (RoleType) IsViewer

func (r RoleType) IsViewer() bool

type SignedInUser

type SignedInUser struct {
	Id        int64     `json:"id"`
	OrgName   string    `json:"orgName"`
	OrgId     int64     `json:"orgId"`
	OrgSlug   string    `json:"orgSlug"`
	Name      string    `json:"name"`
	Role      RoleType  `json:"role"`
	CreatedAt time.Time `json:"createAt"`
	IsAdmin   bool      `json:"-"`
	// contains filtered or unexported fields
}

func Auth

func Auth(adminKey, keyString string) (*SignedInUser, error)

func ValidateToken

func ValidateToken(keyString string) (*SignedInUser, error)

func (*SignedInUser) CheckInstance

func (u *SignedInUser) CheckInstance(instanceID string) error

validate that the signedInUser has a hosted-metrics instance with the passed instanceID. It is assumed that the instanceID has already been confirmed to be an integer.

type TokenCache

type TokenCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*TokenCache) Clear

func (c *TokenCache) Clear()

func (*TokenCache) Get

func (c *TokenCache) Get(key string) (*SignedInUser, bool)

func (*TokenCache) Set

func (c *TokenCache) Set(key string, u *SignedInUser)

type TokenResp

type TokenResp struct {
	User *SignedInUser
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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