qsgpm

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 14 Imported by: 0

README

Latest GitHub release Github Actions test Go Report Card License

qsgpm

A commandline tool for management of QuickSight Group and CustomPermission

Install

binary packages

Releases.

QuickStart

$ qsgpm --help                       
NAME:
   qsgpm - A commandline tool for management of QuickSight Group and CustomPermission

USAGE:
   qsgpm --config <config file>

VERSION:
   current

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --config value, -c value     config file path [$CONFIG, $QSGPM_CONFIG]
   --dry-run                    (default: false) [$QSGPM_DRY_RUN]
   --log-level value, -l value  output log level (debug|info|notice|warn|error) (default: "info") [$QSGPM_LOG_LEVEL]
   --help, -h                   show help (default: false)
   --version, -v                print the version (default: false)

The simplest configuration is:

required_version: ">=0.0.0"

user:
  namespace: default
groups:
  - all

rules:
  - user:
      role: Admin
    groups:
      - admin

  - user:
      role: Author
    groups:
      - author
    custom_permission: DefaultAuthor

  - user:
      role: Reader
    groups:
      - reader

The above setting means that all users will belong to the group "all" and also to the group for each account role, and Author will have a custom permission named DefaultAuthor.

What conditions do the rules match for users? and if they match, which group they belong to and what custom permissions they should have. The rule matches only one. The Yaml array is evaluated from the top and the first matching rule is applied to each user.

For example, for a more complex configuration where the QuickSight user is an external user, the following is an example of another configuration.

required_version: ">=0.0.0"

user:
  identity_type: IAM
  namespace: default
groups:
  - all

rules:
  - user:
      role: Admin
    groups:
      - admin

   - user:
      identity_type: QuickSight 
      email_suffix: "@internal.example.com"
      role: Author
    groups:
      - internal_author
      - author
    custom_permission: InternalAuthor

   - user:
      role: Author
    groups:
      - external_author
      - author
    custom_permission: ExternalAuthor

  - user:
      session_name_suffix: "@external.example.com"
      role: Author
    groups:
      - external_author
      - author
    custom_permission: ExternalAuthor
  
  - user:
      role: Author
    groups:
      - internal_author
      - author
    custom_permission: InternalAuthor


  - user:
      role: Reader
    groups:
      - reader

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCreateOnly added in v0.1.0

func WithCreateOnly(f bool) func(*ApplyGroupsOptions) error

Types

type App

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

func New

func New(ctx context.Context, cfg *Config) (*App, error)

func (*App) Run

func (app *App) Run(ctx context.Context, opt RunOption) error

type ApplyGroupsOptions added in v0.1.0

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

type Config

type Config struct {
	RequiredVersion string `yaml:"required_version"`

	CreateOnly       bool          `yaml:"create_only"`
	User             *UserConfig   `yaml:"user"`
	Groups           []string      `yaml:"groups"`
	CustomPermission string        `yaml:"custom_permission"`
	Rules            []*RuleConfig `yaml:"rules"`
	// contains filtered or unexported fields
}

func NewDefaultConfig

func NewDefaultConfig() *Config

func (*Config) GetCustomPermissionName

func (cfg *Config) GetCustomPermissionName(user *User) *string

func (*Config) GetGroupNames

func (cfg *Config) GetGroupNames(user *User) ([]string, bool)

func (*Config) GetNamespaces

func (cfg *Config) GetNamespaces() []string

func (*Config) Load

func (cfg *Config) Load(path string) error

func (*Config) Restrict

func (cfg *Config) Restrict() error

func (*Config) ValidateVersion

func (c *Config) ValidateVersion(version string) error

ValidateVersion validates a version satisfies required_version.

type Group

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

func (Group) Add

func (group Group) Add(user string)

func (Group) Diff

func (group Group) Diff(other Group) (add, stable, delete []Membership)

func (Group) Membership

func (group Group) Membership() []Membership

type Groups

type Groups map[string]Group

func (Groups) Add

func (groups Groups) Add(group, user string)

func (Groups) AddGroup

func (groups Groups) AddGroup(group string) Group

func (Groups) Assign added in v0.1.0

func (groups Groups) Assign(user string, groupNames []string)

func (Groups) DiffGroup

func (groups Groups) DiffGroup(other Groups) (add, stable, delete []string)

func (Groups) DiffMembership

func (groups Groups) DiffMembership(other Groups) (add, stable, delete []Membership)

type Membership

type Membership struct {
	GroupName string
	UserName  string
}

type QuickSightDryRunClient

type QuickSightDryRunClient struct {
	QuickSightClient
}

func (QuickSightDryRunClient) CreateGroup

func (QuickSightDryRunClient) CreateGroupMembership

func (QuickSightDryRunClient) DeleteGroup

func (QuickSightDryRunClient) DeleteGroupMembership

func (QuickSightDryRunClient) UpdateUser

type QuickSightService

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

func (QuickSightService) ApplyGroups

func (svc QuickSightService) ApplyGroups(ctx context.Context, namespace string, groups Groups, optFns ...func(opt *ApplyGroupsOptions) error) error

func (QuickSightService) GetDryRunService

func (svc QuickSightService) GetDryRunService() *QuickSightService

func (QuickSightService) GetGroups

func (svc QuickSightService) GetGroups(ctx context.Context, namespace string) (Groups, error)

func (QuickSightService) NewUsersPaginator

func (svc QuickSightService) NewUsersPaginator(namespace string) UsersPaginator

func (QuickSightService) UpdateUserCustomPermission

func (svc QuickSightService) UpdateUserCustomPermission(ctx context.Context, user *User, customPermissionName *string) error

type RuleConfig

type RuleConfig struct {
	User             *UserConfig `yaml:"user"`
	Groups           []string    `yaml:"groups"`
	CustomPermission string      `yaml:"custom_permission"`
}

func (*RuleConfig) GetCustomPermissionName

func (cfg *RuleConfig) GetCustomPermissionName(user *User) (string, bool)

func (*RuleConfig) GetGroupNames

func (cfg *RuleConfig) GetGroupNames(user *User) ([]string, bool)

func (*RuleConfig) Restrict

func (cfg *RuleConfig) Restrict() error

type RunOption

type RunOption struct {
	DryRun bool
}

type User

type User struct {
	types.User
	Namespace string
}

func (*User) IAMRoleName

func (u *User) IAMRoleName() string

func (*User) IsNeedUpdateCustomPermission

func (u *User) IsNeedUpdateCustomPermission(customPermissionName *string) bool

func (*User) SessionName

func (u *User) SessionName() string

func (*User) String

func (u *User) String() string

type UserConfig

type UserConfig struct {
	IdentityType      string `yaml:"identity_type"`
	SessionNameSuffix string `yaml:"session_name_suffix"`
	EmailSuffix       string `yaml:"email_suffix"`
	Namespace         string `yaml:"namespace"`
	IAMRoleName       string `yaml:"iam_role_name"`
	Role              string `yaml:"role"`
	// contains filtered or unexported fields
}

func (*UserConfig) Clone

func (cfg *UserConfig) Clone() *UserConfig

func (*UserConfig) Match

func (cfg *UserConfig) Match(user *User) bool

func (*UserConfig) Merge

func (cfg *UserConfig) Merge(other *UserConfig) *UserConfig

func (*UserConfig) Restrict

func (cfg *UserConfig) Restrict() error

type UsersPaginator

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

func (UsersPaginator) HasMoreUsers

func (p UsersPaginator) HasMoreUsers() bool

func (UsersPaginator) NextUsers

func (p UsersPaginator) NextUsers(ctx context.Context) ([]*User, error)

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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