cli

package
v0.0.50 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Key to sign the tokens with
	Key = cli.StringFlag{
		Name:    "key",
		Aliases: []string{"public-key", "signing-key"},
		EnvVars: []string{"PRIVATE_KEY", "KEY", "SIGNING_KEY"},
		Usage:   "private key to sign the tokens with",
	}
	// Jwks set containing the public keys
	Jwks = cli.StringFlag{
		Name:    "jwks",
		Aliases: []string{"jwks-json", "jwk-set"},
		EnvVars: []string{"JWKS", "JWK_SET", "JWKS_JSON"},
		Usage:   "json encoded jwk set containing the public keys",
	}
	// KeyFile with private key to sign the tokens with
	KeyFile = cli.PathFlag{
		Name:    "key-file",
		Aliases: []string{"public-key-file", "signing-key-file"},
		EnvVars: []string{"PRIVATE_KEY_FILE", "KEY_FILE", "SIGNING_KEY_FILE"},
		Usage:   "file with private key to sign the tokens with",
	}
	// JwksFile with the jwk set containing the public keys
	JwksFile = cli.PathFlag{
		Name:    "jwks-file",
		Aliases: []string{"jwks-json-file", "jwk-set-file"},
		EnvVars: []string{"JWKS_FILE", "JWK_SET_FILE", "JWKS_JSON_FILE"},
		Usage:   "json file with the jwk set containing the public keys",
	}
	// Generate configures if keys should be generated if not supplied
	Generate = cli.BoolFlag{
		Name:    "generate",
		Value:   false,
		Aliases: []string{"gen", "create"},
		EnvVars: []string{"GENERATE"},
		Usage:   "generate new keys if none were supplied",
	}
	// ExpirationTime of JWT tokens
	ExpirationTime = cli.GenericFlag{
		Name: "expiration-time",
		Value: &DurationValue{
			Default: 24 * time.Hour,
		},
		Aliases: []string{"token-expire"},
		EnvVars: []string{"EXPIRATION_TIME", "EXPIRATION"},
		Usage:   "expiration times for JWT tokens (e.g. 5h30m40s). Default is 24h",
	}
	// Issuer for the JWT tokens
	Issuer = cli.StringFlag{
		Name:    "issuer",
		Value:   "issuer@example.org",
		Aliases: []string{"jwt-issuer"},
		EnvVars: []string{"ISSUER"},
		Usage:   "JWT token issuer",
	}
	// Audience for the JWT tokens
	Audience = cli.StringFlag{
		Name:    "audience",
		Value:   "example.org",
		Aliases: []string{"jwt-audience"},
		EnvVars: []string{"AUDIENCE"},
		Usage:   "JWT token audience",
	}
	// AuthFlags is a set of all CLI flags
	AuthFlags = []cli.Flag{
		&Key,
		&Jwks,
		&KeyFile,
		&JwksFile,
		&Generate,
		&ExpirationTime,
		&Issuer,
		&Audience,
	}
)
View Source
var (
	// LdapHost configures the LDAP server host
	LdapHost = cli.StringFlag{
		Name:    "ldap-host",
		Value:   "localhost",
		EnvVars: []string{"LDAP_HOST"},
		Usage:   "LDAP host",
	}
	// LdapPort configures the LDAP server port
	LdapPort = cli.IntFlag{
		Name:    "ldap-port",
		Value:   389,
		EnvVars: []string{"LDAP_PORT"},
		Usage:   "LDAP port",
	}
	// LdapProtocol configures the LDAP server protocol
	LdapProtocol = cli.StringFlag{
		Name:    "ldap-protocol",
		Value:   "ldap",
		EnvVars: []string{"LDAP_PROTOCOL"},
		Usage:   "LDAP protocol",
	}
	// LdapAdminUsername configures the LDAP admin username
	LdapAdminUsername = cli.StringFlag{
		Name:    "ldap-admin-username",
		Value:   "admin",
		EnvVars: []string{"LDAP_ADMIN_USERNAME"},
		Usage:   "LDAP admin username",
	}
	// LdapAdminPassword configures the LDAP admin password
	LdapAdminPassword = cli.StringFlag{
		Name:    "ldap-admin-password",
		Value:   "admin",
		EnvVars: []string{"LDAP_ADMIN_PASSWORD"},
		Usage:   "LDAP admin password",
	}
	// LdapReadOnlyUsername configures the LDAP read-only user
	LdapReadOnlyUsername = cli.StringFlag{
		Name:    "ldap-readonly-username",
		Value:   "",
		EnvVars: []string{"LDAP_READONLY_USERNAME"},
		Usage:   "LDAP read-only user",
	}
	// LdapReadOnlyPassword configures the LDAP read-only user
	LdapReadOnlyPassword = cli.StringFlag{
		Name:    "ldap-readonly-password",
		Value:   "",
		EnvVars: []string{"LDAP_READONLY_PASSWORD"},
		Usage:   "LDAP read-only password",
	}
	// LdapConfigUsername configures the LDAP config user
	LdapConfigUsername = cli.StringFlag{
		Name:    "ldap-config-username",
		Value:   "config",
		EnvVars: []string{"LDAP_CONFIG_USERNAME"},
		Usage:   "LDAP config user",
	}
	// LdapConfigPassword configures the LDAP config user
	LdapConfigPassword = cli.StringFlag{
		Name:    "ldap-config-password",
		Value:   "config",
		EnvVars: []string{"LDAP_CONFIG_PASSWORD"},
		Usage:   "LDAP config password",
	}
	// LdapOrganization configures the LDAP organization
	LdapOrganization = cli.StringFlag{
		Name:    "ldap-organization",
		Value:   "Example Inc.",
		EnvVars: []string{"LDAP_ORGANIZATION"},
		Usage:   "LDAP organization",
	}
	// LdapDomain configures the LDAP domain
	LdapDomain = cli.StringFlag{
		Name:    "ldap-domain",
		Value:   "example.org",
		EnvVars: []string{"LDAP_DOMAIN"},
		Usage:   "LDAP domain",
	}
	// LdapBaseDn configures the LDAP base DN
	LdapBaseDn = cli.StringFlag{
		Name:    "ldap-base-dn",
		Value:   "dc=example,dc=org",
		EnvVars: []string{"LDAP_BASE_DN"},
		Usage:   "LDAP base DN",
	}
	// LdapTLS configures if TLS shoudld be used for LDAP
	LdapTLS = cli.BoolFlag{
		Name:    "ldap-tls",
		Value:   false,
		EnvVars: []string{"LDAP_TLS"},
		Usage:   "LDAP use TLS",
	}
	// LdapUseRfc2307Bis configures if the LDAP server uses the RFC2307BIS schema
	LdapUseRfc2307Bis = cli.BoolFlag{
		Name:    "ldap-use-rfc2307bis",
		Value:   true,
		EnvVars: []string{"LDAP_USE_RFC2307BIS"},
		Usage:   "LDAP use RFC2307BIS schema",
	}
	// LdapConfigFlags is a set of all LDAP CLI flags
	LdapConfigFlags = []cli.Flag{
		&LdapHost,
		&LdapPort,
		&LdapProtocol,
		&LdapAdminUsername,
		&LdapAdminPassword,
		&LdapReadOnlyUsername,
		&LdapReadOnlyPassword,
		&LdapConfigPassword,
		&LdapOrganization,
		&LdapDomain,
		&LdapBaseDn,
		&LdapTLS,
		&LdapUseRfc2307Bis,
	}
)
View Source
var (
	// GroupsOu configures the LDAP group organizational unit
	GroupsOu = cli.StringFlag{
		Name:    "groups-ou",
		Value:   "groups",
		EnvVars: []string{"GROUPS_OU"},
		Usage:   "group organizational unit",
	}
	// UsersOu configures the LDAP user organizational unit
	UsersOu = cli.StringFlag{
		Name:    "users-ou",
		Value:   "users",
		EnvVars: []string{"USERS_OU"},
		Usage:   "user organizational unit",
	}
	// GroupsDn configures the LDAP groups DN
	GroupsDn = cli.StringFlag{
		Name:    "groups-dn",
		Value:   "",
		EnvVars: []string{"GROUPS_DN"},
		Usage:   "groups DN (default is ou=$GROUPS_OU,$BASE_DN)",
	}
	// UsersDn configures the LDAP users DN
	UsersDn = cli.StringFlag{
		Name:    "users-dn",
		Value:   "",
		EnvVars: []string{"USERS_DN"},
		Usage:   "users DN (default is ou=$USERS_DN,$BASE_DN)",
	}
	// GroupMembershipAttribute configures the LDAP group membership attribute
	GroupMembershipAttribute = cli.GenericFlag{
		Name: "group-membership-attribute",
		Value: &EnumValue{
			Enum:    []string{"uniqueMember", "memberUID"},
			Default: "uniqueMember",
		},
		EnvVars: []string{"GROUP_MEMBERSHIP_ATTRIBUTE"},
		Usage:   "group membership attribute (e.g. uniqueMember)",
	}
	// GroupMembershipUsesUID configures if LDAP uses UID for group membership
	GroupMembershipUsesUID = cli.BoolFlag{
		Name:    "group-membership-uses-uid",
		Value:   false,
		EnvVars: []string{"GROUP_MEMBERSHIP_USES_UID"},
		Usage:   "group membership uses UID only instead of full DN",
	}
	// AccountAttribute configures the LDAP account attribute
	AccountAttribute = cli.StringFlag{
		Name:    "account-attribute",
		Value:   "uid",
		EnvVars: []string{"ACCOUNT_ATTRIBUTE"},
		Usage:   "account attribute",
	}
	// GroupAttribute configures the LDAP group attribute
	GroupAttribute = cli.StringFlag{
		Name:    "group-attribute",
		Value:   "gid",
		EnvVars: []string{"GROUP_ATTRIBUTE"},
		Usage:   "group attribute",
	}
	// DefaultUserGroup configures the default LDAP user group
	DefaultUserGroup = cli.StringFlag{
		Name:    "default-user-group",
		Value:   "users",
		EnvVars: []string{"DEFAULT_USER_GROUP"},
		Usage:   "default user group",
	}
	// DefaultAdminGroup configures the default LDAP admin group
	DefaultAdminGroup = cli.StringFlag{
		Name:    "default-admin-group",
		Value:   "admins",
		EnvVars: []string{"DEFAULT_ADMIN_GROUP"},
		Usage:   "default admin group",
	}
	// DefaultLoginShell configures the default LDAP login shell
	DefaultLoginShell = cli.StringFlag{
		Name:    "default-login-shell",
		Value:   "/bin/bash",
		EnvVars: []string{"DEFAULT_LOGIN_SHELL"},
		Usage:   "default login shell",
	}
	// DefaultAdminUsername configures the default LDAP admin username
	DefaultAdminUsername = cli.StringFlag{
		Name:    "default-admin-username",
		Value:   "admin",
		EnvVars: []string{"DEFAULT_ADMIN_USERNAME"},
		Usage:   "default admin username",
	}
	// DefaultAdminPassword configures the default LDAP admin password
	DefaultAdminPassword = cli.StringFlag{
		Name:    "default-admin-password",
		Value:   "admin",
		EnvVars: []string{"DEFAULT_ADMIN_PASSWORD"},
		Usage:   "default admin password",
	}
	// ForceCreateAdmin forces creating the default LDAP admin user
	ForceCreateAdmin = cli.BoolFlag{
		Name:    "force-create-admin",
		Value:   false,
		EnvVars: []string{"FORCE_CREATE_ADMIN"},
		Usage:   "force creation of the admin user even if there is a different user in the admin group",
	}
	// LdapFlags is a collection of all LDAP CLI flags
	LdapFlags = []cli.Flag{
		&GroupsOu,
		&UsersOu,
		&GroupsDn,
		&UsersDn,
		&GroupMembershipAttribute,
		&GroupMembershipUsesUID,
		&AccountAttribute,
		&GroupAttribute,
		&DefaultUserGroup,
		&DefaultAdminGroup,
		&DefaultLoginShell,
		&DefaultAdminUsername,
		&DefaultAdminPassword,
		&ForceCreateAdmin,
	}
)
View Source
var (
	// LogLevel configures the logging level of the service
	LogLevel = cli.GenericFlag{
		Name: "log",
		Value: &EnumValue{
			Enum: []string{
				"info",
				"debug",
				"warn",
				"fatal",
				"trace",
				"error",
				"panic",
			},
			Default: "info",
		},
		Aliases: []string{"log-level"},
		EnvVars: []string{"LOG", "LOG_LEVEL"},
		Usage:   "Log level",
	}
	// ForceColors forces colors output
	ForceColors = cli.BoolFlag{
		Name:    "force-colors",
		Value:   true,
		Aliases: []string{"colors"},
		EnvVars: []string{"FORCE_COLORS"},
		Usage:   "Force colors",
	}
	// DisableQuote disables quoting log messages (preserves newlines)
	DisableQuote = cli.BoolFlag{
		Name:    "disable-quotes",
		Value:   true,
		EnvVars: []string{"DISABLE_QUOTES"},
		Usage:   "Disable quoting log messages (preserves newlines)",
	}
	// GRPCPort configures the port to serve GRPC
	GRPCPort = cli.IntFlag{
		Name:    "grpc-port",
		Value:   9090,
		EnvVars: []string{"GRPC_PORT"},
		Usage:   "GRPC service port",
	}
	// HTTPPort configures the port to serve HTTP
	HTTPPort = cli.IntFlag{
		Name:    "http-port",
		Value:   8080,
		Aliases: []string{"port"},
		EnvVars: []string{"HTTP_PORT", "PORT"},
		Usage:   "HTTP service port",
	}
	// NoStatic configures if static assets should not be served
	NoStatic = cli.BoolFlag{
		Name:    "no-static",
		Value:   false,
		Aliases: []string{"disable-serve-static"},
		EnvVars: []string{"NO_STATIC", "DISABLE_SERVE_STATIC"},
		Usage:   "disable serving of the static frontend",
	}
	// StaticRoot configures the static file root dir
	StaticRoot = cli.StringFlag{
		Name:    "static-root",
		Value:   "./web/dist",
		EnvVars: []string{"STATIC_DIR", "STATIC_ROOT"},
		Usage:   "root source directory of the static files to be served",
	}
	// ServiceFlags is the set of all service CLI flags
	ServiceFlags = []cli.Flag{
		&LogLevel,
		&ForceColors,
		&DisableQuote,
		&GRPCPort,
		&HTTPPort,
		&NoStatic,
		&StaticRoot,
	}
)

Functions

This section is empty.

Types

type DurationValue

type DurationValue struct {
	Default time.Duration
	// contains filtered or unexported fields
}

DurationValue is a CLI value that represents a duration

func (*DurationValue) Set

func (dur *DurationValue) Set(value string) error

Set sets the duration value and returns an error if the value is not valid

func (*DurationValue) String

func (dur *DurationValue) String() string

String returns the current duration value or the default duration otherwise

type EnumValue

type EnumValue struct {
	Enum      []string
	Default   string
	AllowNone bool
	// contains filtered or unexported fields
}

EnumValue is a CLI value that can take an enum value

func (*EnumValue) Set

func (enum *EnumValue) Set(value string) error

Set sets the enum value and returns an error if the value is not valid

func (*EnumValue) String

func (enum *EnumValue) String() string

String returns the current enum value or the default value otherwise

Jump to

Keyboard shortcuts

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