shield

package
v0.11.1-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleMember = "users"
	RoleAdmin  = "admins"

	AccountTypeUser = "user"
)
View Source
const (
	ResourceTypeTeam         = "team"
	ResourceTypeProject      = "project"
	ResourceTypeOrganization = "organization"
)

Variables

View Source
var (
	ErrInvalidPermissionConfig = errors.New("invalid permission config type")
	ErrInvalidResourceType     = errors.New("invalid resource type")
)

Functions

func NewClient

func NewClient(config *ClientConfig, logger log.Logger) (*client, error)

func NewProvider

func NewProvider(typeName string, logger log.Logger) *provider

Types

type ClientConfig

type ClientConfig struct {
	Host       string `validate:"required,url" mapstructure:"host"`
	AuthHeader string `validate:"required" mapstructure:"auth_header"`
	AuthEmail  string `validate:"required" mapstructure:"auth_email"`
	HTTPClient HTTPClient
}

type Config

type Config struct {
	ProviderConfig *domain.ProviderConfig
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(pc *domain.ProviderConfig) *Config

func (*Config) ParseAndValidate

func (c *Config) ParseAndValidate() error

type Credentials

type Credentials struct {
	Host       string `json:"host" mapstructure:"host" validate:"required"`
	AuthHeader string `json:"auth_header" mapstructure:"auth_header" validate:"required"`
	AuthEmail  string `json:"auth_email" mapstructure:"auth_email" validate:"required"`
}

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type Metadata

type Metadata struct {
	Email   string `json:"email" mapstructure:"email"`
	Privacy string `json:"privacy" mapstructure:"privacy"`
	Slack   string `json:"slack" mapstructure:"slack"`
}

type Organization

type Organization struct {
	ID     string   `json:"id" mapstructure:"id"`
	Name   string   `json:"name" mapstructure:"name"`
	Slug   string   `json:"slug" mapstructure:"slug"`
	Admins []string `json:"admins" mapstructure:"admins"`
}

func (*Organization) FromDomain

func (o *Organization) FromDomain(r *domain.Resource) error

func (*Organization) ToDomain

func (o *Organization) ToDomain() *domain.Resource

type Permission

type Permission string

type Project

type Project struct {
	ID     string   `json:"id" mapstructure:"id"`
	Name   string   `json:"name" mapstructure:"name"`
	Slug   string   `json:"slug" mapstructure:"slug"`
	OrgId  string   `json:"orgId" mapstructure:"orgId"`
	Admins []string `json:"admins" mapstructure:"admins"`
}

func (*Project) FromDomain

func (p *Project) FromDomain(r *domain.Resource) error

func (*Project) ToDomain

func (p *Project) ToDomain() *domain.Resource

type ShieldClient

type ShieldClient interface {
	GetTeams(ctx context.Context) ([]*Team, error)
	GetProjects(ctx context.Context) ([]*Project, error)
	GetOrganizations(ctx context.Context) ([]*Organization, error)
	GrantTeamAccess(ctx context.Context, team *Team, userId string, role string) error
	RevokeTeamAccess(ctx context.Context, team *Team, userId string, role string) error
	GrantProjectAccess(ctx context.Context, project *Project, userId string, role string) error
	RevokeProjectAccess(ctx context.Context, project *Project, userId string, role string) error
	GrantOrganizationAccess(ctx context.Context, organization *Organization, userId string, role string) error
	RevokeOrganizationAccess(ctx context.Context, organization *Organization, userId string, role string) error
	GetSelfUser(ctx context.Context, email string) (*User, error)
}

type Team

type Team struct {
	ID       string   `json:"id" mapstructure:"id"`
	Name     string   `json:"name" mapstructure:"name"`
	Slug     string   `json:"slug" mapstructure:"slug"`
	OrgId    string   `json:"orgId" mapstructure:"orgId"`
	Metadata Metadata `json:"metadata" mapstructure:"metadata"`
	Admins   []string `json:"admins" mapstructure:"admins"`
}

func (*Team) FromDomain

func (t *Team) FromDomain(r *domain.Resource) error

func (*Team) ToDomain

func (t *Team) ToDomain() *domain.Resource

type User

type User struct {
	ID    string `json:"id" mapstructure:"id"`
	Name  string `json:"name" mapstructure:"name"`
	Email string `json:"email" mapstructure:"email"`
}

Jump to

Keyboard shortcuts

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