apps

package
v0.0.0-...-df8b58b Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PermTypeConfig perm type config
	PermTypeConfig = 0
	// PermTypeService perm type service
	PermTypeService = 1
	// PermTypeApp perm type app
	PermTypeApp = 2

	// PermTargetApp perm target app
	PermTargetApp = 0
	// PermTargetGroup perm target group
	PermTargetGroup = 1

	// PermPublicTargetID perm public target id
	PermPublicTargetID = 0
)

Variables

This section is empty.

Functions

func HasAnyPrefixPerm

func HasAnyPrefixPerm(db *sql.DB, permType int, appID int64, groupIDs []int64, needWrite bool, content string) (bool, error)

HasAnyPrefixPerm has any prefix perm

func InsertApp

func InsertApp(db *sql.DB, app *App) error

InsertApp insert app

func InsertConfigItem

func InsertConfigItem(db *sql.DB, item *ConfigItem) (bool, error)

InsertConfigItem insert config item

func InsertGroup

func InsertGroup(db *sql.DB, group *Group) error

InsertGroup insert group

func InsertPerm

func InsertPerm(db *sql.DB, perm *Perm) error

InsertPerm insert perm

func NewGroupMember

func NewGroupMember(db *sql.DB, groupID, appID int64) error

NewGroupMember new group member

Types

type App

type App struct {
	ID          int64     `json:"-"`
	Status      int       `json:"status"`
	Name        string    `json:"name"`
	Description string    `json:"description,omitempty"`
	PrivateKey  string    `json:"-"`
	Cert        string    `json:"cert"`
	CreateTime  time.Time `json:"create_time"`
	ModifyTime  time.Time `json:"modify_time"`
	// contains filtered or unexported fields
}

App app table

func GetAppByName

func GetAppByName(db *sql.DB, name string) (*App, error)

GetAppByName get app by name

func GetAppGroupByName

func GetAppGroupByName(db *sql.DB, name string) (*App, []int64, error)

GetAppGroupByName get app group by name

func GetAppList

func GetAppList(db *sql.DB) (apps []App, err error)

GetAppList get app list

func GetGroupMembers

func GetGroupMembers(db *sql.DB, groupID int64) (apps []App, err error)

GetGroupMembers get group members

func ListApp

func ListApp(db *sql.DB, skip, limit int) ([]App, error)

ListApp list app

func (*App) Certificate

func (app *App) Certificate() (*x509.Certificate, error)

Certificate cert

type AppCtrl

type AppCtrl struct {
	CertsManager *CertsCtrl
	// contains filtered or unexported fields
}

AppCtrl app ctrl

func NewAppCtrl

func NewAppCtrl(config *Config, db *sql.DB, etcdClient *clientv3.Client) (*AppCtrl, error)

NewAppCtrl new app ctrl

func (*AppCtrl) AddGroupMember

func (ctrl *AppCtrl) AddGroupMember(groupID, appID int64) error

AddGroupMember add group member

func (*AppCtrl) GetAppByName

func (ctrl *AppCtrl) GetAppByName(name string) (*App, error)

GetAppByName get app byname

func (*AppCtrl) GetAppCertPool

func (ctrl *AppCtrl) GetAppCertPool() *x509.CertPool

GetAppCertPool get app certPool

func (*AppCtrl) GetAppGroupByName

func (ctrl *AppCtrl) GetAppGroupByName(name string) (*App, []int64, error)

GetAppGroupByName get app group byname

func (*AppCtrl) GetGroupByName

func (ctrl *AppCtrl) GetGroupByName(name string) (*Group, error)

GetGroupByName get group byname

func (*AppCtrl) GetGroupMembers

func (ctrl *AppCtrl) GetGroupMembers(groupID int64) ([]App, error)

GetGroupMembers get group members

func (*AppCtrl) GetPerms

func (ctrl *AppCtrl) GetPerms(typ int, appName *string, groupName *string, canWrite *bool, prefix *string) ([]Perm, error)

GetPerms get perms

func (*AppCtrl) HasAnyPrefixPerm

func (ctrl *AppCtrl) HasAnyPrefixPerm(typ int, appID int64, groupIDs []int64, needWrite bool, content string) (bool, error)

HasAnyPrefixPerm has any prefix perm

func (*AppCtrl) IsAppNodeOnline

func (ctrl *AppCtrl) IsAppNodeOnline(ctx context.Context, name, label, key string) (bool, error)

IsAppNodeOnline is app node online

func (*AppCtrl) ListApp

func (ctrl *AppCtrl) ListApp(skip, limit int) ([]App, error)

ListApp list app

func (*AppCtrl) NewApp

func (ctrl *AppCtrl) NewApp(app *App, key crypto.Signer, dnsNames []string, ips []net.IP, days int) (crypto.Signer, error)

NewApp new app

func (*AppCtrl) NewAppPerm

func (ctrl *AppCtrl) NewAppPerm(permType int, appID int64, canWrite bool, content string) (int64, error)

NewAppPerm new app perm

func (*AppCtrl) NewGroup

func (ctrl *AppCtrl) NewGroup(group *Group) error

NewGroup new group

func (*AppCtrl) NewGroupPerm

func (ctrl *AppCtrl) NewGroupPerm(permType int, groupID int64, canWrite bool, content string) (int64, error)

NewGroupPerm new group perm

func (*AppCtrl) PlugAppNode

func (ctrl *AppCtrl) PlugAppNode(ctx context.Context, appName string, node *AppNode, leaseID clientv3.LeaseID) (bool, error)

PlugAppNode plug app node

func (*AppCtrl) RemoveAppNode

func (ctrl *AppCtrl) RemoveAppNode(ctx context.Context, name, label, key string) error

RemoveAppNode remove app node

func (*AppCtrl) WatchAppNodes

func (ctrl *AppCtrl) WatchAppNodes(ctx context.Context, name, label string, revision int64) (*AppNodes, error)

WatchAppNodes watch app nodes

type AppNode

type AppNode struct {
	Label  string `json:"label"`
	Key    string `json:"key"`
	Config string `json:"config"`
}

AppNode app node

type AppNodes

type AppNodes struct {
	Nodes    map[string]*string `json:"nodes"`
	Revision int64              `json:"revision"`
}

AppNodes app nodes

type CertsConfig

type CertsConfig struct {
	RootCert string `default:"rootcert.pem"`
	RootKey  string `default:"rootkey.pem"`
}

CertsConfig certs config

type CertsCtrl

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

CertsCtrl certs ctrl

func NewCertsCtrl

func NewCertsCtrl(config *CertsConfig, serialGenerator SerialGenerator) (*CertsCtrl, error)

NewCertsCtrl new certs ctrl

func (*CertsCtrl) CertPool

func (mgr *CertsCtrl) CertPool() *x509.CertPool

CertPool cert poll

func (*CertsCtrl) NewCert

func (mgr *CertsCtrl) NewCert(pubkey crypto.PublicKey, subject pkix.Name,
	dnsNames []string, ips []net.IP, days int) ([]byte, error)

NewCert new cert

type Config

type Config struct {
	Cert                  CertsConfig
	EcdsaCruve            string
	RSABits               int    `default:"2048"`
	Organization          string `default:"XBus"`
	KeyPrefix             string `default:"/apps" yaml:"key_prefix"`
	DumpKeyCertDir        string `yaml:"dump_keycert_dir"`
	DumpKeyCertWithAppDir bool   `default:"true" yaml:"dump_keycert_with_appdir"`
}

Config module config

type ConfigItem

type ConfigItem struct {
	ID         int64
	Name       string
	Value      string
	Ver        int64
	CreateTime time.Time
	ModifyTime time.Time
}

ConfigItem config item table

func GetConfigItem

func GetConfigItem(db *sql.DB, name string) (*ConfigItem, error)

GetConfigItem get config item

func (*ConfigItem) GetIntValue

func (m *ConfigItem) GetIntValue() (int64, error)

GetIntValue get int value

func (*ConfigItem) Refresh

func (m *ConfigItem) Refresh(db *sql.DB) error

Refresh refresh

func (*ConfigItem) SetIntValue

func (m *ConfigItem) SetIntValue(n int64)

SetIntValue set int value

func (*ConfigItem) UpdateValue

func (m *ConfigItem) UpdateValue(db *sql.DB) error

UpdateValue update value

type Group

type Group struct {
	ID          int64     `json:"-"`
	Status      int       `json:"status"`
	Name        string    `json:"name"`
	Description string    `json:"description,omitempty"`
	CreateTime  time.Time `json:"create_time"`
	ModifyTime  time.Time `json:"modify_time"`
}

Group group table

func GetGroupByName

func GetGroupByName(db *sql.DB, name string) (*Group, error)

GetGroupByName get group by name

func GetGroupList

func GetGroupList(db *sql.DB) (groups []Group, err error)

GetGroupList get group list

type GroupMember

type GroupMember struct {
	ID         int64
	AppID      int64
	GroupID    int64
	CreateTime time.Time
}

GroupMember group member

type Perm

type Perm struct {
	ID         int64
	PermType   int
	TargetType int
	TargetID   int64
	CanWrite   bool
	Content    string
	CreateTime time.Time
}

Perm perm table

func GetPerms

func GetPerms(db *sql.DB, typ int, targetType *int, targetID *int64,
	canWrite *bool, prefix *string) ([]Perm, error)

GetPerms get perms

type SerialGenerator

type SerialGenerator interface {
	Generate() (*big.Int, error)
}

SerialGenerator serial generator

Jump to

Keyboard shortcuts

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