config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config provides configuration management

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfig added in v0.0.4

func DefaultConfig()

DefaultConfig sets the default values for the configuration

func GetDbURI added in v0.0.4

func GetDbURI() string

GetDbURI returns a database connection string

func GetServerAddress added in v0.0.4

func GetServerAddress() string

GetServerAddress returns the address string to bind the service to

func InitConfig added in v0.0.4

func InitConfig(configFile string)

InitConfig initializes the configuration

func Random added in v0.0.4

func Random(length int) (string, error)

Random returns a random string of the given length

Types

type K added in v0.0.4

type K string

K is a type alias for string

const (
	// ServiceHost is the host to bind the service to
	ServiceHost K = `service.host`
	// ServicePort is the port to bind the service to
	ServicePort K = `service.port`
	// ServiceBaseURL is the base URL of the service
	ServiceBaseURL K = `service.base_url`
	// ServiceAPIPrefix is the prefix to use for the API set to "" for /
	ServiceAPIPrefix K = `service.api_prefix`

	// ServiceJWTSigningMethod is the signing method to use for JWT
	ServiceJWTSigningMethod K = `service.jwt.signing_method`
	// ServiceJWTSigningSecret is the secret to use for JWT (only for HS256)
	//nolint:gosec // False positive: this is a configuration key name, not a credential
	ServiceJWTSigningSecret K = `service.jwt.signing_secret`
	// ServiceJWTSigningKey is the key to use for JWT (only for RS256)
	ServiceJWTSigningKey K = `service.jwt.signing_key`
	// ServiceJWTPublicKey is the public key to use for JWT (only for RS256)
	ServiceJWTPublicKey K = `service.jwt.public_key`
	// ServiceJWTRefreshSigningSecret is the secret to use for JWT refresh token (only for HS256)
	//nolint:gosec // False positive: this is a configuration key name, not a credential
	ServiceJWTRefreshSigningSecret K = `service.jwt.refresh_signing_secret`
	// ServiceJWTRefreshSigningKey is the key to use for JWT refresh token (only for RS256)
	ServiceJWTRefreshSigningKey K = `service.jwt.refresh_signing_key`
	// ServiceJWTRefreshPublicKey is the public key to use for JWT refresh token (only for RS256)
	ServiceJWTRefreshPublicKey K = `service.jwt.refresh_public_key`

	// TotpSkew is the skew to use for TOTP (max 255)
	ServiceTotpSkew K = `service.totp.skew`

	// ReCAPTCHA configuration
	// ServiceReCAPTCHAEnabled enables or disables reCAPTCHA verification
	ServiceReCAPTCHAEnabled K = `service.recaptcha.enabled`
	// ServiceReCAPTCHASecretKey is the secret key for reCAPTCHA verification
	ServiceReCAPTCHASecretKey K = `service.recaptcha.secret_key`
	// ServiceReCAPTCHAMinScore is the minimum score threshold for reCAPTCHA verification (0.0 to 1.0)
	ServiceReCAPTCHAMinScore K = `service.recaptcha.min_score`
	// ServiceReCAPTCHAFieldName is the field name in the JSON payload containing the reCAPTCHA token
	ServiceReCAPTCHAFieldName K = `service.recaptcha.field_name`

	// CORS configuration
	// ServiceCorsAllowedOrigins is the list of allowed origins
	ServiceCorsAllowOrigins K = `service.cors.allowed_origins`
	// ServiceCorsAllowMethods is the list of allowed methods
	ServiceCorsAllowMethods K = `service.cors.allow_methods`
	// ServviceCorsCredentials is whether to allow credentials in a CORS request
	ServiceCorsAllowCredentials K = `service.cors.allow_credentials`
	// ServiceCorsMaxAge is the max age of the CORS response
	ServiceCorsMaxAge K = `service.cors.max_age`

	// Cookie options
	// ServiceCookieSameSiteNone is whether to set SameSite=None in a cookie
	ServiceCookieSameSiteNone K = `service.cookie.same_site_none`

	// ServiceMailEnabled controls whether the mail service is enabled
	ServiceMailEnabled K = `service.mail.enabled`
	// ServiceMailWorkers is the number of mail worker goroutines to run
	ServiceMailWorkers K = `service.mail.workers`
	// ServiceMailTemplateDir is the directory containing email templates
	ServiceMailTemplateDir K = `service.mail.template_dir`
	// ServiceMailDefaultTemplate is the default template to use for emails
	ServiceMailDefaultTemplate K = `service.mail.default_template`

	// ServiceShutdownTimeoutSeconds is the timeout in seconds for graceful shutdown
	ServiceShutdownTimeoutSeconds K = `service.shutdown_timeout_seconds`

	// HTTP Server timeout configurations
	// ServiceHTTPReadHeaderTimeoutSeconds is the timeout for reading request headers
	ServiceHTTPReadHeaderTimeoutSeconds K = `service.http.read_header_timeout_seconds`
	// ServiceHTTPReadTimeoutSeconds is the timeout for reading the entire request
	ServiceHTTPReadTimeoutSeconds K = `service.http.read_timeout_seconds`
	// ServiceHTTPWriteTimeoutSeconds is the timeout for writing the response
	ServiceHTTPWriteTimeoutSeconds K = `service.http.write_timeout_seconds` //nolint:gosec // G101: This is a configuration key, not a credential
	// ServiceHTTPIdleTimeoutSeconds is the timeout for keep-alive connections
	ServiceHTTPIdleTimeoutSeconds K = `service.http.idle_timeout_seconds`

	// ServiceDevMode indicates if the service is running in development mode
	ServiceDevMode K = `service.dev_mode`
	// ServicePendingUserExpirationHours is the number of hours a pending user registration is valid
	ServicePendingUserExpirationHours K = `service.pending_user_expiration_hours`
	// DatabaseHost is the host to connect to the database
	DatabaseHost K = `database.host`
	// DatabasePort is the port to connect to the database
	DatabasePort K = `database.port`
	// DatabaseUsername is the username to connect to the database
	DatabaseUsername K = `database.username`
	// DatabasePassword is the password to connect to the database
	DatabasePassword K = `database.password`
	// DatabaseName is the name of the database to connect to
	DatabaseName K = `database.name`
	// DatabaseAutoMigration is whether to automatically apply the migrations to the database
	DatabaseAutoMigration K = `database.auto_migration`

	// RedisHost is the host to connect to the redis
	RedisHost K = `redis.host`
	// RedisPort is the port to connect to the redis
	RedisPort K = `redis.port`
	// RedisPassword is the password to connect to the redis
	RedisPassword K = `redis.password`
	// RedisDatabase is the database to connect to the redis
	RedisDatabase K = `redis.database`

	// SMTPHost is the host of the SMTP server
	SMTPHost K = `smtp.host`
	// SMTPPort is the port of the SMTP server
	SMTPPort K = `smtp.port`
	// SMTPUsername is the username for SMTP authentication
	SMTPUsername K = `smtp.username`
	// SMTPPassword is the password for SMTP authentication
	SMTPPassword K = `smtp.password`
	// SMTPUseTLS determines if TLS should be used for SMTP
	SMTPUseTLS K = `smtp.use_tls`
	// SMTPFromEmail is the default from email address
	SMTPFromEmail K = `smtp.from_email`
	// SMTPFromName is the default from name
	SMTPFromName K = `smtp.from_name`

	// Password Reset Token configuration
	// ServicePasswordResetTokenLength is the length of generated password reset tokens
	ServicePasswordResetTokenLength K = `service.password_reset.token_length`
	// ServicePasswordResetTokenLifetimeMinutes is how long password reset tokens are valid in minutes
	ServicePasswordResetTokenLifetimeMinutes K = `service.password_reset.token_lifetime_minutes`
	// ServicePasswordResetCleanupIntervalHours is how often to clean up expired tokens in hours
	ServicePasswordResetCleanupIntervalHours K = `service.password_reset.cleanup_interval_hours`
	// ServicePasswordResetMaxTokensPerUser is the maximum number of active tokens per user
	ServicePasswordResetMaxTokensPerUser K = `service.password_reset.max_tokens_per_user`

	// Cron configuration
	// ServiceCronEnabled controls whether the cron service is enabled
	ServiceCronEnabled K = `service.cron.enabled`
	// ServiceCronPasswordResetCleanup is the cron expression for password reset token cleanup
	ServiceCronPasswordResetCleanup K = `service.cron.password_reset_cleanup`
	// ServiceCronTimeZone is the timezone for cron jobs
	ServiceCronTimeZone K = `service.cron.timezone`
)

func (K) Get added in v0.0.4

func (k K) Get() interface{}

Get returns the raw value of the key

func (K) GetBool added in v0.0.4

func (k K) GetBool() bool

GetBool returns the value of the key as a bool

func (K) GetFloat64 added in v0.0.11

func (k K) GetFloat64() float64

GetFloat64 returns the value of the key as a float64

func (K) GetInt added in v0.0.4

func (k K) GetInt() int

GetInt returns the value of the key as an int

func (K) GetInt64 added in v0.1.0

func (k K) GetInt64() int64

GetUInt64 returns the value of the key as an uint64

func (K) GetString added in v0.0.4

func (k K) GetString() string

GetString returns the value of the key as a string

func (K) GetStringSlice added in v0.0.8

func (k K) GetStringSlice() []string

GetStringSlice returns the value of the key as a string slice

func (K) GetUint added in v0.0.7

func (k K) GetUint() uint

GetInt returns the value of the key as an int

func (K) GetUint8 added in v0.0.8

func (k K) GetUint8() uint8

GetUint8 returns the value of the key as an uint8

func (K) Set added in v0.0.4

func (k K) Set(value interface{})

Set sets the value of the key

Jump to

Keyboard shortcuts

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