options

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CredentialOptions

type CredentialOptions struct {
	// Time - The number of iterations that the argon algorithm will run
	Time uint32

	// Memory - The maximum amount of memory (in Megabytes) that Argon can use to hash secrets
	Memory uint32

	// Threads - The number of threads to use when hashing secrets
	Threads uint8

	// KeyLength - The length of the hash that Argon will produce
	KeyLength uint32

	// SaltLength - The length of the hash that Argon will use when hashing passwords
	SaltLength uint32

	// MinSecretLength - Sets the minimum password length that a new user must provide. Defaults to 12
	MinSecretLength uint32

	// MaxSecretLength - Sets the maximum password length that a new user must provide. Defaults to 48
	MaxSecretLength uint32
}

func Credential

func Credential() *CredentialOptions

Credential - Initializes a new CredentialOptions struct with sane defaults that can be applied

func (*CredentialOptions) FromConfig

func (opts *CredentialOptions) FromConfig() *CredentialOptions

FromConfig - Initializes CredentialOptions using values provided by Viper. Overwrites any previous options that were set

func (*CredentialOptions) SetKeyLength

func (opts *CredentialOptions) SetKeyLength(length uint32) *CredentialOptions

SetKeyLength - Sets the length in bytes that the generated hash should be. This is set to 16 by default

func (*CredentialOptions) SetMaxPasswordLength

func (opts *CredentialOptions) SetMaxPasswordLength(length uint32) *CredentialOptions

SetMaxPasswordLength - Sets the maximum plain text password length that a user must provide during registration or password reset operations

func (*CredentialOptions) SetMemory

func (opts *CredentialOptions) SetMemory(memory uint32) *CredentialOptions

SetMemory - Sets the amount of memory that the Argon algorithm will consume during hashing operations. The `memory` parameter should represent the number of megabytes you wish to set this to

func (*CredentialOptions) SetMinPasswordLength

func (opts *CredentialOptions) SetMinPasswordLength(length uint32) *CredentialOptions

SetMinPasswordLength - Sets the minimum plain text password length that a user must provide during registration or password reset operations

func (*CredentialOptions) SetSaltLength

func (opts *CredentialOptions) SetSaltLength(length uint32) *CredentialOptions

SetSaltLength - Sets the length in bytes that the generated salt should be. This is set to 32 by default

func (*CredentialOptions) SetThreads

func (opts *CredentialOptions) SetThreads(threads uint8) *CredentialOptions

SetThreads - Sets the number of go-routines that will actively be used in hashing. This is set to 1 by default, however if higher performance is required this can be increased.

func (*CredentialOptions) SetTime

func (opts *CredentialOptions) SetTime(time uint32) *CredentialOptions

SetTime - Sets the number of iterations that the argon algorithm will apply to the secret. Generally, this should be set to one but can be increased in more sensitive environments

type DatabaseOptions

type DatabaseOptions struct {
	// Hostname - Defines the hostname that the MongoDB server can be accessed at
	Hostname string

	// Port - Defines the port number that the MongoDB server is listening for connections on
	Port uint32

	// DefaultDatabase - Defines the default database that should be used for storing collections
	DefaultDatabase string

	// UseAuthentication - If set to false, then any other auth related configs wont be evaluated
	UseAuthentication bool

	// AuthenticationDatabase - Defines the database that should be used for authentication
	AuthenticationDatabase string

	// Username - Defines the username that should be used for authentication with MongoDB
	Username string

	// Password - Defines the password that should be used for authentication with MongoDB
	Password string

	// ConnectionTimeout - The duration that credstack should wait for before force closing a Mongo connection
	ConnectionTimeout time.Duration
}

func Database

func Database() *DatabaseOptions

Database - Returns a DatabaseOptions structure with some sensible defaults. Authentication is not enabled here by default as MongoDB does not have default authentication. Despite this not being enabled, the AuthenticationDatabase is set to admin by default as this tends to be common when working with MongoDB (although not recommended)

func (*DatabaseOptions) DefaultCollections

func (opts *DatabaseOptions) DefaultCollections() []string

DefaultCollections - Returns the default collections that credstack expects to be able to read/write to. This is primarily used with Database.Init. This really shouldn't be changed so there is no setter defined for these

func (*DatabaseOptions) FromConfig

func (opts *DatabaseOptions) FromConfig() *DatabaseOptions

FromConfig - Fills in all fields present in the DatabaseOptions structure with the values from viper. Any previously present configuration values will be overwritten with this call

func (*DatabaseOptions) IndexingMap

func (opts *DatabaseOptions) IndexingMap() map[string]bson.D

IndexingMap - Returns the map used for creating indexes on the credstack's default collections. All the indexes listed here are created as unique indexes. This really shouldn't be changed so there is no setter defined for these

func (*DatabaseOptions) SetAuthenticationDatabase

func (opts *DatabaseOptions) SetAuthenticationDatabase(value string) *DatabaseOptions

SetAuthenticationDatabase - Defines the default database that the MongoDB server will look for users and roles within. When calling DatabaseOptions.Database, this is set to 'admin'. Ideally this should be set to the default database defined at DatabaseOptions.DefaultDatabase. Users should be seperated to only the databases that they need access to, and should be treated more or less as ephemeral

func (*DatabaseOptions) SetConnectionTimeout

func (opts *DatabaseOptions) SetConnectionTimeout(seconds int) *DatabaseOptions

SetConnectionTimeout - Defines the default for amount of time that the MongoDB client should use when attempting to connect to a server. If a value less than 0 is provided, then seconds is set to 15

func (*DatabaseOptions) SetDefaultDatabase

func (opts *DatabaseOptions) SetDefaultDatabase(value string) *DatabaseOptions

SetDefaultDatabase - Set's the default database that cred-stack will assume that its collections will live. If server.Database.Init is called with this set, then collections (and indexes) will be initialized here.

func (*DatabaseOptions) SetHostname

func (opts *DatabaseOptions) SetHostname(hostname string) *DatabaseOptions

SetHostname - Defines the hostname of the MongoDB database that you want to connect to. You do not need to prepend this with the mongo:// protocol identifier, this should just be the FQDN of the MongoDB instance

func (*DatabaseOptions) SetPassword

func (opts *DatabaseOptions) SetPassword(value string) *DatabaseOptions

SetPassword - Defines the clear text password of the MongoDB user that the MongoDB client should use when performing authentication

func (*DatabaseOptions) SetPort

func (opts *DatabaseOptions) SetPort(port int) *DatabaseOptions

SetPort - Sets the port that your MongoDB server is listening for connections on. If this value is set lower than 0, then a default of 27017 is used instead.

func (*DatabaseOptions) SetUseAuthentication

func (opts *DatabaseOptions) SetUseAuthentication(value bool) *DatabaseOptions

SetUseAuthentication - If set to true, then the authentication values provided at DatabaseOptions.Username, DatabaseOptions.Password, and DatabaseOptions.AuthenticationDatabase are evaluated and authentication is attempted on the MongoDB server

func (*DatabaseOptions) SetUsername

func (opts *DatabaseOptions) SetUsername(value string) *DatabaseOptions

SetUsername - Defines the username of the MongoDB user that the MongoDB client should use when performing authentication

func (*DatabaseOptions) ToMongoOptions

func (opts *DatabaseOptions) ToMongoOptions() *options.ClientOptions

ToMongoOptions - Converts any pre-defined options declared in DatabaseOptions to an options.ClientOptions struct so that this can be used cleanly with the Database structure

type LogOptions

type LogOptions struct {
	// UseFileLogging - If set to true, log files will be written in JSON format
	UseFileLogging bool

	// LogPath - The directory that logs should be saved under
	LogPath string

	// LogLevel - A string determining how verbose logs should be. Can be: Info (default), Debug, All
	LogLevel zapcore.Level

	// EncoderConfig - Provides universal configuration options for both stdout logggin and file logging
	EncoderConfig zapcore.EncoderConfig
}

LogOptions - A container for any configurable options for the Zap Logger. Not a lot of options are exposed here as the logger isn't designed to be very featureful.

func Log

func Log() *LogOptions

Log - Returns a LogOptions structure with some sensible defaults. File logging is disabled by default to avoid adding un-needed complexity.

func (*LogOptions) FromConfig

func (opts *LogOptions) FromConfig() *LogOptions

FromConfig - Fills in all fields present in the LogOptions structure with viper. Any previously present configuration values will be overwritten this call. If an invalid log level is passed into viper, it is set to zapcore.InfoLevel instead

func (*LogOptions) SetEncoderConfig

func (opts *LogOptions) SetEncoderConfig(config zapcore.EncoderConfig) *LogOptions

SetEncoderConfig - Sets the specified Zap Encoder Configuration for the logger. This is used primarily for file logging as it is a requirement for tree-ing together multiple loggers (like stdout and file)

func (*LogOptions) SetFileLogging

func (opts *LogOptions) SetFileLogging(value bool) *LogOptions

SetFileLogging - If set to true, logs will be written to JSON files specified at LogOptions.LogPath

func (*LogOptions) SetLogLevel

func (opts *LogOptions) SetLogLevel(level zapcore.Level) *LogOptions

SetLogLevel - Sets the log level for both stdout logging and file logging. The possible values for this are Info, Debug, and All. If an invalid value is passed here, then it defaults to Info. Please see the constants defined here for using this

func (*LogOptions) SetPath

func (opts *LogOptions) SetPath(path string) *LogOptions

SetPath - Sets the path that credstack should write log files to. This will not be evaluated unless LogOptions.UseFileLogging is set to true. Paths that contain a tilda (~) that are passed here are expanded to their absolute paths. If the path provided here is not found then logs are written to: ~/.credstack/logs

Jump to

Keyboard shortcuts

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