config.go 538 B

12345678910111213141516171819202122
  1. package auth
  2. import (
  3. "git.linuxforward.com/byom/byom-golang-lib/pkg/errors"
  4. )
  5. // Config holds the authentication configuration
  6. type Config struct {
  7. SecretKey string `yaml:"secret_key"`
  8. TokenDuration int `yaml:"token_duration"` // in seconds
  9. }
  10. // Validate implements the config.Validator interface
  11. func (c *Config) Validate() error {
  12. if c.SecretKey == "" {
  13. return errors.NewConfigError("auth.secret_key", errors.ErrInvalidInput)
  14. }
  15. if c.TokenDuration == 0 {
  16. c.TokenDuration = 86400 // 24 hours default
  17. }
  18. return nil
  19. }