Documentation
¶
Index ¶
- func CreateNonExistingFolder(path string, mode fs.FileMode) error
- func FileExists(filename string) bool
- func FormatFilePath(path string) string
- func GenerateCSRAndPrivateKey(privateKey, keyType, domain string, SAN []string) (string, []byte, error)
- func GenerateFingerprint(content []byte) string
- func GenerateRequestID() string
- func GetKeyType(keyTypeStr string) (certcrypto.KeyType, error)
- func GetRequestID(ctx context.Context) string
- func HashAPIKey(apiKey string) string
- func HashToken(token string) string
- func LoggerWithRequestID(ctx context.Context, logger log.Logger) log.Logger
- func RandomStringCrypto(numBytes int) (string, error)
- func RandomWeekdayBeforeExpiration(expiration time.Time, minDays, maxDays int) time.Time
- func RequestLogHook(logger *logrus.Logger) retryablehttp.RequestLogHook
- func ResponseLogHook(logger *logrus.Logger, logJSONBody bool) retryablehttp.ResponseLogHook
- func ResponseLogHookDebug(logger *logrus.Logger) retryablehttp.ResponseLogHook
- func SHA1Hash(content string) string
- func SHA256Hash(content string) string
- func SanitizedDomain(logger log.Logger, domain string) (string, error)
- func SecureCompare(a, b string) bool
- func SetTLSConfig(cert string, key string, ca string, insecure bool) (*tls.Config, error)
- func SetupLoggers(logLevel, logFormat string) (log.Logger, *logrus.Logger)
- func StructToMapInterface(data interface{}) map[string]interface{}
- func ValidateCertificateName(name string) error
- func ValidateLabels(labels string) (errors []error)
- func ValidateRenewalDays(value string) (int, int, error)
- func VerifyHash(storedHash, plaintext string) bool
- func WithRequestID(ctx context.Context, requestID string) context.Context
- type CustomTextFormatter
- type CustomWriter
- type DebugLevelHook
- type UTCFormatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileExists ¶
func FormatFilePath ¶
func GenerateCSRAndPrivateKey ¶
func GenerateCSRAndPrivateKey(privateKey, keyType, domain string, SAN []string) (string, []byte, error)
GenerateCSRAndPrivateKey generates a Certificate Signing Request (CSR) and a private key.
func GenerateFingerprint ¶
func GenerateRequestID ¶ added in v0.6.4
func GenerateRequestID() string
GenerateRequestID generates a unique request ID using crypto/rand
func GetKeyType ¶
func GetKeyType(keyTypeStr string) (certcrypto.KeyType, error)
GetKeyType the type from which private keys should be generated.
func GetRequestID ¶ added in v0.6.4
GetRequestID retrieves the request ID from the context
func HashAPIKey ¶ added in v0.8.1
HashAPIKey returns the hash used to store a management API key. The write/emit algorithm is centralized here (sha256).
func HashToken ¶ added in v0.8.1
HashToken returns the hash used to store/emit a bearer token. The write/emit algorithm is centralized here (sha256).
func LoggerWithRequestID ¶ added in v0.6.4
LoggerWithRequestID returns a logger with the request ID from context
func RandomStringCrypto ¶
RandomStringCrypto returns a base64url-encoded string derived from numBytes of cryptographically secure random data. The full encoding is returned without truncation so the caller keeps the requested entropy.
func RandomWeekdayBeforeExpiration ¶
Function to generate a random weekday within a given range before an expiration date
func RequestLogHook ¶
func RequestLogHook(logger *logrus.Logger) retryablehttp.RequestLogHook
RequestLogHook logs outgoing HTTP requests
func ResponseLogHook ¶
func ResponseLogHook(logger *logrus.Logger, logJSONBody bool) retryablehttp.ResponseLogHook
ResponseLogHook logs the response status code and body
func ResponseLogHookDebug ¶
func ResponseLogHookDebug(logger *logrus.Logger) retryablehttp.ResponseLogHook
ResponseLogHookDebug logs all responses with full details
func SHA1Hash ¶
SHA1Hash returns the sha1 hex digest of a string. Kept for legacy dual-read verification only; do not use on write paths.
func SHA256Hash ¶ added in v0.8.1
SHA256Hash returns the sha256 hex digest of a string.
func SecureCompare ¶ added in v0.8.1
SecureCompare reports whether a and b are equal using a constant-time comparison to avoid leaking secret length/content through timing.
func SetTLSConfig ¶
func SetupLoggers ¶ added in v0.7.1
SetupLoggers creates and configures all loggers (logrus, go-kit, and lego slog). Returns the go-kit logger and logrus logger.
func StructToMapInterface ¶
func StructToMapInterface(data interface{}) map[string]interface{}
func ValidateCertificateName ¶ added in v0.9.0
SanitizedDomain validates a domain and returns a filesystem/Vault-path safe representation. It rejects empty, over-long or malformed domains, and allows at most a single leading "*." wildcard label. On any failure it returns a non-nil error instead of a partial value so callers never build paths from unvalidated input. ValidateCertificateName rejects names that would escape the storage layout. A named certificate is stored at "<prefix>/<owner>/<name>" in Vault and on disk, so a name carrying a path separator or a parent reference would resolve outside the owner's namespace. Anything else is accepted, to stay compatible with names already in use.
func ValidateLabels ¶
func VerifyHash ¶ added in v0.8.1
VerifyHash implements a dual-read verification: it returns true when the stored hash constant-time-matches the sha256 hash of plaintext (current write algorithm) OR the legacy sha1 hash of plaintext. This lets existing sha1-stored hashes keep working while all new writes use sha256.
Types ¶
type CustomTextFormatter ¶
type CustomTextFormatter struct {
TimestampFormat string
CallerPrettyfier func(*runtime.Frame) (string, string)
}
CustomTextFormatter is a custom logrus formatter
type CustomWriter ¶
Custom Writer to block INFO messages containg [DEBUG] in message
type DebugLevelHook ¶
Hook to redirect logs with message starting with [DEBUG] from INFO to DEBUG level
func (*DebugLevelHook) Levels ¶
func (hook *DebugLevelHook) Levels() []logrus.Level