Documentation
¶
Overview ¶
Package configs contains Readeck configuration.
Index ¶
- Variables
- func BuildTime() time.Time
- func ExtractorDeniedIPs() []*net.IPNet
- func GenerateKey() string
- func InitConfiguration()
- func LoadConfiguration(configPath string) error
- func TrustedProxies() []*net.IPNet
- func Version() string
- func WriteConfig(filename string) error
- type EncodingKey
- type KeyMaterial
- type SigningKey
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidSize is returned when an encoded string is not 128-bit long. ErrInvalidSize = errors.New("invalid encoded string size") // ErrInvalidData is returned when input data does not match its signature. ErrInvalidData = errors.New("invalid data") )
var Config = config{ Main: configMain{ LogLevel: slog.LevelInfo, DataDirectory: "data", }, Server: configServer{ Host: "127.0.0.1", Port: 8000, Session: configSession{ CookieName: "sxid", MaxAge: 86400 * 30, }, TrustedProxies: []configIPNet{ newConfigIPNet("127.0.0.0/8"), newConfigIPNet("10.0.0.0/8"), newConfigIPNet("172.16.0.0/12"), newConfigIPNet("192.168.0.0/16"), newConfigIPNet("fd00::/8"), newConfigIPNet("::1/128"), }, }, Database: configDB{}, Email: configEmail{ Port: 25, }, Auth: configAuth{ Forwarded: configForwardedAuth{ Enabled: false, HeaderUser: "Remote-User", HeaderEmail: "Remote-Email", HeaderGroup: "Remote-Groups", ProvisioningEnabled: true, }, }, Bookmarks: configBookmarks{ PublicShareTTL: 24, }, Worker: configWorker{ DSN: "memory://", NumWorkers: max(1, runtime.NumCPU()-1), StartWorker: true, }, Extractor: configExtractor{ NumWorkers: runtime.NumCPU(), DeniedIPs: []configIPNet{ newConfigIPNet("127.0.0.0/8"), newConfigIPNet("::1/128"), }, ProxyMatch: []configProxyMatch{}, }, Metrics: configMetrics{ Host: "127.0.0.1", Port: 0, }, }
Config holds the configuration data from configuration files or flags.
This variable sets some default values that might be overwritten by a configuration file.
var Keys = KeyMaterial{}
Keys contains the encryption and signin keys.
Functions ¶
func BuildTime ¶
BuildTime returns the build time or, if empty, the time when the application started.
func ExtractorDeniedIPs ¶
ExtractorDeniedIPs returns the value of Config.Extractor.DeniedIPs as a slice of *net.IPNet.
func InitConfiguration ¶
func InitConfiguration()
InitConfiguration applies some default computed values on the configuration.
func LoadConfiguration ¶
LoadConfiguration loads the configuration file.
func TrustedProxies ¶
TrustedProxies returns the value of Config.Server.TrustedProxies as a slice of *net.IPNet.
func WriteConfig ¶
WriteConfig writes configuration to a file.
Types ¶
type EncodingKey ¶
type EncodingKey []byte
EncodingKey is a key that can be used to encode and decode a variable that support JSON marshaling.
func (EncodingKey) Decode ¶
func (k EncodingKey) Decode(encoded []byte) ([]byte, error)
Decode decodes the input data with chacha20-poly1305 using the key.
func (EncodingKey) DecodeJSON ¶
func (k EncodingKey) DecodeJSON(encoded []byte, v any) error
DecodeJSON decodes an encoded value and unmarshals it into the variable v.
func (EncodingKey) Encode ¶
func (k EncodingKey) Encode(data []byte) ([]byte, error)
Encode encodes the input data with chacha20-poly1305 using the key.
func (EncodingKey) EncodeJSON ¶
func (k EncodingKey) EncodeJSON(v any) ([]byte, error)
EncodeJSON marshals a variable to JSON and encodes it using the key.
type KeyMaterial ¶
type KeyMaterial struct {
// contains filtered or unexported fields
}
KeyMaterial contains the signing and encryption keys.
func (KeyMaterial) Expand ¶
func (km KeyMaterial) Expand(name string, keyLength int) ([]byte, error)
Expand call hkdf.Expand using the [KeyMaterial.prk] main key.
func (KeyMaterial) OauthRequestKey ¶
func (km KeyMaterial) OauthRequestKey() EncodingKey
OauthRequestKey returns a 256-bit key used to encode the oauth authorization payload.
func (KeyMaterial) SessionKey ¶
func (km KeyMaterial) SessionKey() []byte
SessionKey returns a 256-bit key used by the session's secure cookie.
func (KeyMaterial) TOTPKey ¶
func (km KeyMaterial) TOTPKey() EncodingKey
TOTPKey returns a 256-bit key used to encrypt the TOTP secret information.
func (KeyMaterial) TokenKey ¶
func (km KeyMaterial) TokenKey() SigningKey
TokenKey returns a 256-bit key used to genrate a token's MAC.
type SigningKey ¶
type SigningKey []byte
SigningKey is a key that can be used to sign and verify a base58 payload.