Documentation
¶
Index ¶
- Constants
- func BucketTokenCount() int
- func BucketTokenMatches(bucketName, secret string) bool
- func GetEnvAsBoolOrDefault(key string, defaultValue bool) bool
- func GetEnvAsIntOrDefault(key string, defaultValue int) int
- func GetEnvOrDefault(key, defaultValue string) string
- func LoadBucketTokens(path string) (int, error)
- type AWSConfig
- type AppConfig
- type BucketToken
- type Config
- type FeatureConfig
- type MinioConfig
- type RedisConfig
- type TokenConfig
- type WorkerConfig
Constants ¶
const MinBucketTokenLength = 32
MinBucketTokenLength is the minimum accepted length of a bucket-scoped token secret. Bucket tokens are machine-generated credentials, so there is no reason for a short one and a weak entry would silently widen the write surface.
Variables ¶
This section is empty.
Functions ¶
func BucketTokenCount ¶ added in v1.8.0
func BucketTokenCount() int
BucketTokenCount returns the number of loaded bucket-scoped tokens.
func BucketTokenMatches ¶ added in v1.8.0
BucketTokenMatches reports whether secret is the configured token for bucketName, compared in constant time.
An unknown bucket still runs a full comparison against a zero digest so that "no token configured for this bucket" and "wrong secret" cost the same.
func GetEnvAsBoolOrDefault ¶
func GetEnvAsIntOrDefault ¶
func GetEnvOrDefault ¶
func LoadBucketTokens ¶ added in v1.8.0
LoadBucketTokens reads bucket-scoped tokens from path and returns how many were loaded.
A missing file is not an error: it is the normal state of a deployment that uses only the general TOKEN, and boot must succeed unchanged in that case. A file that exists but cannot be parsed or fails validation IS an error, because silently serving with zero bucket tokens after an operator wrote the file is the worse failure: callers would fall back to "invalid token" with no clue why.
Types ¶
type BucketToken ¶ added in v1.8.0
type BucketToken struct {
Bucket string `json:"bucket"`
Token string `json:"token"`
// Label is an optional free-text note (who or what uses this token). It is
// never used for authorization.
Label string `json:"label,omitempty"`
}
BucketToken is one entry of the token file.
type Config ¶
type Config struct {
App AppConfig
Minio MinioConfig
AWS AWSConfig
Redis RedisConfig
Worker WorkerConfig
Features FeatureConfig
}
type FeatureConfig ¶
type MinioConfig ¶
type RedisConfig ¶
type RedisConfig struct {
URL string
}
type TokenConfig ¶ added in v1.8.0
type TokenConfig struct {
Buckets []BucketToken `json:"buckets"`
}
TokenConfig is the on-disk shape of the token file.