core

package
v8.0.15+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2018 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const APIVersion = 2
View Source
const SessionCookieName = "shield7"

Variables

View Source
var DataDir = "setme"
View Source
var DefaultCompressionType = "bzip2"
View Source
var Problems = map[string]string{
	"legacy-shield-agent-version": "This SHIELD agent is not reporting its version, which means that it is probably a v6.x version of SHIELD.  It will not be able to report back health and status information to this SHIELD Core.  Similarly, plugin metadata will be unavailable for this agent, and SHIELD operators and site administrators will have to operate without it for all targets that use this agent for backup and restore operations.",

	"dev-shield-agent-version": "This SHIELD agent is reporting its version as 'dev', which makes it difficult to determine its exact featureset.  Dev builds of SHIELD are not recommended for production.",
}
View Source
var (
	RoleTower map[string]int
)
View Source
var Version = "(development)"

Functions

func IsValidSystemRole

func IsValidSystemRole(role string) bool

func IsValidTenantRole

func IsValidTenantRole(role string) bool

func JSON

func JSON(w http.ResponseWriter, thing interface{})

func JSONLiteral

func JSONLiteral(w http.ResponseWriter, thing string)

func Sentencify

func Sentencify(words []string) string

func SessionCookie

func SessionCookie(value string, valid bool) *http.Cookie

func SetAuthHeaders

func SetAuthHeaders(r *route.Request, sessionID uuid.UUID)

func ValidCompressionType

func ValidCompressionType(t string) bool

Types

type AgentClient

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

func NewAgentClient

func NewAgentClient(keyfile string) (*AgentClient, error)

func (*AgentClient) Run

func (c *AgentClient) Run(host string, stdout, stderr chan string, command *AgentCommand) error

FIXME: add a stderr here and move O:/E: out of core/core.go

type AgentCommand

type AgentCommand struct {
	Op             string `json:"operation"`
	TargetPlugin   string `json:"target_plugin,omitempty"`
	TargetEndpoint string `json:"target_endpoint,omitempty"`
	StorePlugin    string `json:"store_plugin,omitempty"`
	StoreEndpoint  string `json:"store_endpoint,omitempty"`
	RestoreKey     string `json:"restore_key,omitempty"`
	EncryptType    string `json:"encrypt_type,omitempty"`
	EncryptKey     string `json:"encrypt_key,omitempty"`
	EncryptIV      string `json:"encrypt_iv,omitempty"`
	Compression    string `json:"compression,omitempty"`
}

type AuthConfig

type AuthConfig struct {
	Name       string `yaml:"name"`
	Identifier string `yaml:"identifier"`
	Backend    string `yaml:"backend"`

	Properties map[interface{}]interface{} `yaml:"properties"`
}

type AuthProvider

type AuthProvider interface {
	Configure(map[interface{}]interface{}) error
	Configuration(bool) AuthProviderConfig

	ReferencedTenants() []string

	Initiate(http.ResponseWriter, *http.Request)
	HandleRedirect(*http.Request) *db.User
}

type AuthProviderBase

type AuthProviderBase struct {
	Name       string
	Identifier string
	Type       string
	// contains filtered or unexported fields
}

func (*AuthProviderBase) Assign

func (p *AuthProviderBase) Assign(user *db.User, tenant, role string) bool

func (*AuthProviderBase) ClearAssignments

func (p *AuthProviderBase) ClearAssignments()

func (AuthProviderBase) Configuration

func (p AuthProviderBase) Configuration(private bool) AuthProviderConfig

func (AuthProviderBase) Debugf

func (p AuthProviderBase) Debugf(m string, args ...interface{})

func (AuthProviderBase) Errorf

func (p AuthProviderBase) Errorf(m string, args ...interface{})

func (AuthProviderBase) Fail

func (AuthProviderBase) Infof

func (p AuthProviderBase) Infof(m string, args ...interface{})

func (*AuthProviderBase) SaveAssignments

func (p *AuthProviderBase) SaveAssignments(DB *db.DB, user *db.User) bool

type AuthProviderConfig

type AuthProviderConfig struct {
	Name       string `json:"name"`
	Identifier string `json:"identifier"`
	Type       string `json:"type"`

	WebEntry string `json:"web_entry"`
	CLIEntry string `json:"cli_entry"`
	Redirect string `json:"redirect"`

	Properties map[string]interface{} `json:"properties,omitempty"`
}

type Broadcaster

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

func NewBroadcaster

func NewBroadcaster(slots int) Broadcaster

func (*Broadcaster) Broadcast

func (b *Broadcaster) Broadcast(ev Event)

func (*Broadcaster) Register

func (b *Broadcaster) Register(ch chan Event) (int, error)

func (*Broadcaster) Unregister

func (b *Broadcaster) Unregister(idx int) error

type ClientError

type ClientError struct {
	Error string `json:"error"`
}

func ClientErrorf

func ClientErrorf(format string, v ...interface{}) ClientError

func (ClientError) JSON

func (e ClientError) JSON() string

type Config

type Config struct {
	SlowLoop int `yaml:"slow_loop"`
	FastLoop int `yaml:"fast_loop"`

	Debug bool `yaml:"debug"`

	DataDir string `yaml:"data_directory"`

	Addr          string `yaml:"listen_addr"`
	KeyFile       string `yaml:"private_key"`
	Workers       int    `yaml:"workers"`
	Purge         string `yaml:"purge_agent"`
	Timeout       int    `yaml:"max_timeout"`
	SkipSSLVerify bool   `yaml:"skip_ssl_verify"`
	WebRoot       string `yaml:"web_root"`

	Environment string `yaml:"env"`
	Color       string `yaml:"color"`
	MOTD        string `yaml:"motd"`

	EncryptionType string `yaml:"encryption_type"`

	VaultAddress string `yaml:"vault_address"`
	VaultCACert  string `yaml:"vault_ca_cert"`

	SessionTimeout int `yaml:"session_timeout"`

	Failsafe FailsafeConfig `yaml:"failsafe"`

	Auth []AuthConfig `yaml:"auth"`
}

func ReadConfig

func ReadConfig(file string) (Config, error)

type Core

type Core struct {
	DB *db.DB
	// contains filtered or unexported fields
}

func NewCore

func NewCore(file string) (*Core, error)

func (*Core) AreStoresHealthy

func (core *Core) AreStoresHealthy() bool

func (*Core) AuthenticatedUser

func (core *Core) AuthenticatedUser(r *route.Request) (*db.User, error)

func (*Core) CanManageTenants

func (core *Core) CanManageTenants(r *route.Request, tenant string) bool

func (*Core) CanSeeCredentials

func (core *Core) CanSeeCredentials(r *route.Request, tenant string) bool

func (*Core) DeltaIncrease

func (core *Core) DeltaIncrease(filter *db.ArchiveFilter) (int64, error)

DeltaIncrease calculates the delta in storage space over the period specified. It stores the number of bytes increased/decreased in the period specified in the stores table. Calculation is preformed by taking (total new archives created - any archives newly purged)

func (*Core) Initialize

func (core *Core) Initialize(master string) (bool, string, error)

func (*Core) IsNotAuthenticated

func (core *Core) IsNotAuthenticated(r *route.Request) bool

func (*Core) IsNotSystemAdmin

func (core *Core) IsNotSystemAdmin(r *route.Request) bool

func (*Core) IsNotSystemEngineer

func (core *Core) IsNotSystemEngineer(r *route.Request) bool

func (*Core) IsNotSystemManager

func (core *Core) IsNotSystemManager(r *route.Request) bool

func (*Core) IsNotTenantAdmin

func (core *Core) IsNotTenantAdmin(r *route.Request, tenant string) bool

func (*Core) IsNotTenantEngineer

func (core *Core) IsNotTenantEngineer(r *route.Request, tenant string) bool

func (*Core) IsNotTenantOperator

func (core *Core) IsNotTenantOperator(r *route.Request, tenant string) bool

func (*Core) Rekey

func (core *Core) Rekey(current, proposed string, rotateFixed bool) (string, error)

func (*Core) Run

func (core *Core) Run() error

func (*Core) ServeHTTP

func (core *Core) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Core) Unlock

func (core *Core) Unlock(master string) (bool, error)

type Event

type Event struct {
	Task *db.Task
	JSON []byte
}

type FailsafeConfig

type FailsafeConfig struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type GithubAuthProvider

type GithubAuthProvider struct {
	AuthProviderBase

	ClientID         string `json:"client_id"`
	ClientSecret     string `json:"client_secret"`
	GithubEndpoint   string `json:"github_endpoint"`
	GithubAPI        string `json:"github_api"`
	GithubEnterprise bool   `json:"github_enterprise"`
	Mapping          []struct {
		Github string `json:"github"`
		Tenant string `json:"tenant"`
		Rights []struct {
			Team string `json:"team"`
			Role string `json:"role"`
		} `json:"rights"`
	} `json:"mapping"`
	// contains filtered or unexported fields
}

func (*GithubAuthProvider) Configure

func (p *GithubAuthProvider) Configure(raw map[interface{}]interface{}) error

func (*GithubAuthProvider) HandleRedirect

func (p *GithubAuthProvider) HandleRedirect(req *http.Request) *db.User

func (*GithubAuthProvider) Initiate

func (p *GithubAuthProvider) Initiate(w http.ResponseWriter, req *http.Request)

func (*GithubAuthProvider) ReferencedTenants

func (p *GithubAuthProvider) ReferencedTenants() []string

type Health

type Health struct {
	Health struct {
		Core    string `json:"core"`
		Storage bool   `json:"storage_ok"`
		Jobs    bool   `json:"jobs_ok"`
	} `json:"health"`

	Storage []StorageHealth `json:"storage"`
	Jobs    []JobHealth     `json:"jobs"`

	Stats struct {
		Jobs     int   `json:"jobs"`
		Systems  int   `json:"systems"`
		Archives int   `json:"archives"`
		Storage  int64 `json:"storage"`
		Daily    int64 `json:"daily"`
	} `json:"stats"`
}

type Info

type Info struct {
	Version string `json:"version,omitempty"`
	IP      string `json:"ip,omitempty"`
	Env     string `json:"env,omitempty"`
	Color   string `json:"color,omitempty"`
	MOTD    string `json:"motd,omitempty"`

	API int `json:"api"`
}

type InvalidParametersError

type InvalidParametersError struct {
	Errors map[string]string
}

func InvalidParameters

func InvalidParameters(names ...string) InvalidParametersError

func (InvalidParametersError) Error

func (e InvalidParametersError) Error() string

func (*InvalidParametersError) IsValid

func (e *InvalidParametersError) IsValid() bool

func (InvalidParametersError) JSON

func (e InvalidParametersError) JSON() string

func (*InvalidParametersError) Validate

func (e *InvalidParametersError) Validate(name string, value interface{}, fn Validator)

type JSONError

type JSONError interface {
	JSON() string
}

type JobHealth

type JobHealth struct {
	UUID    uuid.UUID `json:"uuid"`
	Target  string    `json:"target"`
	Job     string    `json:"job"`
	Healthy bool      `json:"healthy"`
}

type MissingParametersError

type MissingParametersError struct {
	Missing []string `json:"missing"`
}

func MissingParameters

func MissingParameters(names ...string) MissingParametersError

func (*MissingParametersError) Check

func (e *MissingParametersError) Check(name string, value string)

func (MissingParametersError) Error

func (e MissingParametersError) Error() string

func (MissingParametersError) IsValid

func (e MissingParametersError) IsValid() bool

func (MissingParametersError) JSON

func (e MissingParametersError) JSON() string

type StorageHealth

type StorageHealth struct {
	UUID    uuid.UUID `json:"uuid"`
	Name    string    `json:"name"`
	Healthy bool      `json:"healthy"`
}

type UAAAuthProvider

type UAAAuthProvider struct {
	AuthProviderBase

	ClientID      string `json:"client_id"`
	ClientSecret  string `json:"client_secret"`
	UAAEndpoint   string `json:"uaa_endpoint"`
	SkipVerifyTLS bool   `json:"skip_verify_tls"`

	Mapping []struct {
		Tenant string `json:"tenant"`
		Rights []struct {
			SCIM string `json:"scim"`
			Role string `json:"role"`
		} `json:"rights"`
	} `json:"mapping"`
	// contains filtered or unexported fields
}

func (*UAAAuthProvider) Configure

func (p *UAAAuthProvider) Configure(raw map[interface{}]interface{}) error

func (*UAAAuthProvider) HandleRedirect

func (p *UAAAuthProvider) HandleRedirect(req *http.Request) *db.User

func (*UAAAuthProvider) Initiate

func (p *UAAAuthProvider) Initiate(w http.ResponseWriter, req *http.Request)

func (*UAAAuthProvider) ReferencedTenants

func (p *UAAAuthProvider) ReferencedTenants() []string

type Validator

type Validator func(name string, value interface{}) error

Jump to

Keyboard shortcuts

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