shield

package
v0.12.8-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 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

func NewShieldNewClient

func NewShieldNewClient(config *ClientConfig, logger log.Logger) (*shieldNewclient, error)

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"`
	ClientVersion string `json:"client_version" mapstructure:"client_version"`
}

type DeleteRelation

type DeleteRelation struct {
	ObjectId  string `json:"object_id" mapstructure:"object_id"`
	SubjectId string `json:"subject_id" mapstructure:"subject_id"`
	Role      string `json:"role" mapstructure:"role"`
}

type Group

type Group 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 (*Group) FromDomain

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

func (*Group) ToDomain

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

type GroupRelation

type GroupRelation struct {
	SubjectType string `json:"subject_type" mapstructure:"subject_type"`
	Role        string `json:"role" mapstructure:"role"`
	User        *User  `json:"user" mapstructure:"user"`
	Group       *Group `json:"group" mapstructure:"group"`
}

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 Relation

type Relation struct {
	Id              string `json:"id" mapstructure:"id"`
	ObjectId        string `json:"object_id" mapstructure:"object_id"`
	ObjectNamespace string `json:"object_namespace" mapstructure:"object_namespace"`
	Subject         string `json:"subject" mapstructure:"subject"`
	RoleName        string `json:"role_name" mapstructure:"role_name"`
}

type ShieldClient

type ShieldClient interface {
	GetGroups(ctx context.Context) ([]*Group, error)
	GetProjects(ctx context.Context) ([]*Project, error)
	GetOrganizations(ctx context.Context) ([]*Organization, error)
	GrantGroupAccess(ctx context.Context, team *Group, userId string, role string) error
	RevokeGroupAccess(ctx context.Context, team *Group, 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 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