Documentation
¶
Index ¶
- Constants
- func CheckVerifyCode(token string, signingKey string, email string) bool
- func CheckVerifyCodeTS(token string, signingKey string, email string, timestamp time.Time) bool
- func FileServer(r chi.Router, path string, root http.FileSystem)
- func MakeToken(srv *Server, email string) (string, error)
- func MakeVerifyCodeNow(signingKey string, email string) string
- func MakeVerifyCodeTS(signingKey string, email string, timestamp time.Time) string
- type AuthConfig
- type Config
- type CookieAuthConfig
- type EmailConfig
- type JWTConfig
- type MailjetConfig
- type MailjetSender
- type RateLimitConfig
- type RateLimitConfigItem
- type Server
- type ServerConfig
Constants ¶
const (
CodeChars = "2379HJKLNQSTVXYZ" // Limited to a nice even 16 options
)
Variables ¶
This section is empty.
Functions ¶
func CheckVerifyCodeTS ¶
func FileServer ¶
func FileServer(r chi.Router, path string, root http.FileSystem)
FileServer conveniently sets up a http.FileServer handler to serve static files from a http.FileSystem.
func MakeVerifyCodeNow ¶
Types ¶
type AuthConfig ¶
type AuthConfig struct { Mode string `yaml:"mode" validate:"required,oneof=email"` RateLimit RateLimitConfig `yaml:"rate_limit"` }
AuthConfig changes how authentication works
type Config ¶
type Config struct { Title string `yaml:"title" validate:"min=1,max=64"` Brand string `yaml:"brand" validate:"min=1,max=64"` Support string `yaml:"support" validate:"min=1,max=255"` SigningKey string `yaml:"signing_key" validate:"required,min=16,max=64"` CookieAuth CookieAuthConfig `yaml:"cookie_auth"` Auth AuthConfig `yaml:"auth"` Email EmailConfig `yaml:"email"` Mailjet MailjetConfig `yaml:"mailjet"` Server ServerConfig `yaml:"server"` JWT JWTConfig `yaml:"jwt"` }
Config provides all the configuration parsed from praga.yaml
func LoadConfig ¶
LoadConfig loads a praga.yaml file and parses it into a Config
type CookieAuthConfig ¶
type CookieAuthConfig struct { CookieName string `yaml:"cookie_name" validate:"required,min=1,max=64"` Domain string `yaml:"domain" validate:"required,min=1,max=255"` Secure bool `yaml:"secure" validate:""` }
CookieAuthConfig contains configuration for cookie authentication
type EmailConfig ¶
type EmailConfig struct { ValidDomains []string `yaml:"valid_domains" validate:"dive,min=1,max=255"` ValidEmails []string `yaml:"valid_emails" validate:"dive,email"` EmailProvider string `yaml:"email_provider" validate:"required,oneof=mailjet"` From string `yaml:"from" validate:"required,email"` FromName string `yaml:"from_name" validate:"required,min=1"` }
EmailConfig configures email related settings
type JWTConfig ¶
type JWTConfig struct {
ValidSeconds int `yaml:"valid_seconds" validate:"required,gte=1,lte=1576800000"`
}
JWTConfig configures the authentication token properties
type MailjetConfig ¶
type MailjetConfig struct { APIKeyPublic string `yaml:"apikey_public" validate:"min=0,max=255"` APIKeyPrivate string `yaml:"apikey_private" validate:"min=0,max=255"` }
MailjetConfig provides Mailjet API configuration
type MailjetSender ¶
type MailjetSender struct {
// contains filtered or unexported fields
}
type RateLimitConfig ¶
type RateLimitConfig struct { IP RateLimitConfigItem `yaml:"ip"` Email RateLimitConfigItem `yaml:"email"` }
RateLimitConfig defines rate limiting for different things
type RateLimitConfigItem ¶
type RateLimitConfigItem struct {
PerHour int `yaml:"per_hour" validate:"gte=0,lte=100000"`
}
RateLimitConfigItem contains details for rate limiting
type Server ¶
type Server struct { Config Config MailjetSender *MailjetSender }
Server provides the interface for setting up a HTTP server
type ServerConfig ¶
type ServerConfig struct { ListenType string `yaml:"listen_type" validate:"required,oneof=unix http"` Socket string `yaml:"socket" validate:"min=1,max=255"` Host string `yaml:"host" validate:"min=1,max=255"` Port int `yaml:"port" validate:"gte=1,lte=65535"` }
ServerConfig contains configuration for the HTTP server