groups

package
v0.15.11 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateCommand = cli.Command{
	Name: "create",
	Flags: []cli.Flag{
		&cli.StringFlag{Name: "group-name", Aliases: []string{"n"}, Usage: "The group ID", Required: true},
		&cli.StringFlag{Name: "description", Aliases: []string{"desc"}, Usage: "The description of the group"},
	},
	Description: "Create a new Cognito user group",
	Action: func(c *cli.Context) error {
		ctx := c.Context

		group := c.String("group-name")
		desc := c.String("description")

		dc, err := deploy.ConfigFromContext(ctx)
		if err != nil {
			return err
		}
		o, err := dc.LoadOutput(ctx)
		if err != nil {
			return err
		}
		cfg, err := cfaws.ConfigFromContextOrDefault(ctx)
		if err != nil {
			return err
		}

		o, err = dc.LoadOutput(ctx)
		if err != nil {
			return err
		}

		cog := cognitoidentityprovider.NewFromConfig(cfg)
		_, err = cog.CreateGroup(ctx, &cognitoidentityprovider.CreateGroupInput{
			GroupName:   &group,
			UserPoolId:  &o.UserPoolID,
			Description: &desc,
		})
		if err != nil {
			return err
		}

		clio.Successf("Successfully created group '%s'", group)
		clio.Warn("Run 'gdeploy identity sync' to sync your changes now.")
		return nil
	},
}
View Source
var DeleteCommand = cli.Command{
	Name: "delete",
	Flags: []cli.Flag{
		&cli.StringFlag{Name: "group-name", Aliases: []string{"n"}, Usage: "The name of the group to be deleted", Required: true},
	},
	Description: "Delete Cognito user group if exists",
	Action: func(c *cli.Context) error {
		ctx := c.Context

		group := c.String("group-name")

		dc, err := deploy.ConfigFromContext(ctx)
		if err != nil {
			return err
		}

		if group == deploy.DefaultCommonFateAdministratorsGroup || group == dc.Deployment.Parameters.AdministratorGroupID {
			return errors.New("you cannot delete the administrators group")
		}

		o, err := dc.LoadOutput(ctx)
		if err != nil {
			return err
		}
		cfg, err := cfaws.ConfigFromContextOrDefault(ctx)
		if err != nil {
			return err
		}

		o, err = dc.LoadOutput(ctx)
		if err != nil {
			return err
		}

		cog := cognitoidentityprovider.NewFromConfig(cfg)
		_, err = cog.DeleteGroup(ctx, &cognitoidentityprovider.DeleteGroupInput{
			GroupName:  &group,
			UserPoolId: &o.UserPoolID,
		})
		if err != nil {
			return err
		}

		clio.Successf("Successfully deleted group '%s'", group)
		clio.Warn("Run 'gdeploy identity sync' to sync your changes now.")
		return nil
	},
}
View Source
var GroupsCommand = cli.Command{
	Name:        "groups",
	Description: "Add or remove groups from the default cognito user pool.\nThese commands are only available when you are using the default Cognito user pool. If you have connected an SSO provider, like Okta, Google or AzureAD, use those tools to manage your users and groups instead.",
	Subcommands: []*cli.Command{&CreateCommand, &DeleteCommand, &members.MembersCommand},
	Action:      cli.ShowSubcommandHelp,
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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