app

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SudoersGroup represent a sudoers unix group name
	SudoersGroup string = "ssh-manager-sudoers"
	// UsersGroup represent a users unix group name
	UsersGroup string = "ssh-manager-users"
)
View Source
const Version string = "1.0.4"

Version contains current application version

Variables

This section is empty.

Functions

func CreateUsers

func CreateUsers(user, key string, sudoer bool) error

CreateUsers will create a local users and assign them to the relevant groups.

func DemoteUser

func DemoteUser(user string) error

DemoteUser make sudo user a standard user

func PromoteUser

func PromoteUser(user string) error

PromoteUser make standard user a sudo user

func SliceToString

func SliceToString(slice []string) string

SliceToString is a helper function to format a slice of strings into a comma separated string.

func ValidateSudoersGroup

func ValidateSudoersGroup() error

ValidateSudoersGroup ensures that custom sudoers group exists

func ValidateSudoersPermissions

func ValidateSudoersPermissions() error

ValidateSudoersPermissions ensures that sudoers file contains a custom sudoers group.

func ValidateUsersGroup

func ValidateUsersGroup() error

ValidateUsersGroup ensures that custom users group exists

Types

type Config

type Config struct {
	Users        map[string]string   `json:"users"`
	ServerGroups map[string]*Members `json:"server_groups"`
}

Config represents a remote configuration

func GetConfig

func GetConfig(service *secretsmanager.SecretsManager, name string) (*Config, error)

GetConfig fetches an AWS Secret and returns an application configuration

func (*Config) GetSudoers

func (c *Config) GetSudoers(serverGroups []string) map[string]string

GetSudoers returns a map of sudo users and their public ssh keys for a matching server groups

func (*Config) GetUsers

func (c *Config) GetUsers(serverGroups []string) map[string]string

GetUsers returns a map of users and their public ssh keys for a matching server groups

type Members

type Members struct {
	Sudoers []string `json:"sudoers"`
	Users   []string `json:"users"`
}

Members ia a single server group in a configuration

type State

type State struct {
	Users   []string `json:"users"`
	Sudoers []string `json:"sudoers"`
}

State represents local application state and reflects a current status and a results of a previous run.

func LoadState

func LoadState(file string) (*State, error)

LoadState from disk

func (*State) DeleteUsers

func (s *State) DeleteUsers(users, sudoers []string)

DeleteUsers that exists in a runtime state but not in a provided slices, which provided from a remote configuration.

func (*State) Save

func (s *State) Save(file string) error

Save runtime state to disk

func (*State) SudoersLoop

func (s *State) SudoersLoop(sudoers map[string]string, listOfUsers []string)

SudoersLoop is a main loop for sudo users creation and standard users promotion

func (*State) Update

func (s *State) Update(users, sudoers []string)

Update runtime state.

**Warning**: This will not save the state to disk.

func (*State) UsersLoop

func (s *State) UsersLoop(users map[string]string)

UsersLoop is a main loop for standard users creation and sudoers demotion

Jump to

Keyboard shortcuts

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