Documentation ¶
Index ¶
- Constants
- Variables
- func AuthClearCookie(w http.ResponseWriter)
- func AuthCookieMiddleware(tokenFunc AuthTokenFunc, unauthorizedHandler http.HandlerFunc) func(http.Handler) http.Handler
- func AuthHeaderMiddleware(tokenFunc AuthTokenFunc, unauthorizedHandler http.HandlerFunc) func(http.Handler) http.Handler
- func AuthRequired(unauthorizedHandler http.HandlerFunc) func(http.Handler) http.Handler
- func AuthSetCookie(w http.ResponseWriter, t string)
- func Bind(r *http.Request, v interface{}) ([]string, bool)
- func Env() string
- func ExtractUser(ctx context.Context) *models.UserInfo
- func GetVersion(overrides ...string) string
- func NewLogger() (*slog.Logger, error)
- type AuthTokenFunc
- type LoggerConfig
- type Password
Constants ¶
View Source
const AuthCookieName = "home-auth-token"
Variables ¶
View Source
var ( EnvDev = "dev" EnvProd = "prod" )
View Source
var ErrAuthInvalidToken = errors.New("invalid token")
Functions ¶
func AuthClearCookie ¶
func AuthClearCookie(w http.ResponseWriter)
func AuthCookieMiddleware ¶
func AuthCookieMiddleware(tokenFunc AuthTokenFunc, unauthorizedHandler http.HandlerFunc) func(http.Handler) http.Handler
func AuthHeaderMiddleware ¶
func AuthHeaderMiddleware(tokenFunc AuthTokenFunc, unauthorizedHandler http.HandlerFunc) func(http.Handler) http.Handler
func AuthRequired ¶
func AuthSetCookie ¶
func AuthSetCookie(w http.ResponseWriter, t string)
func Env ¶
func Env() string
Env returns which environment we're running in. Currently this only checks if stdin is a tty, but in the future we might use environment variables.
func GetVersion ¶
GetVersion extracts the commit information from the build info, falling back to the string "unknown". If any non-empty "override" variables are passed in, they will override the returned version. This still allows for stamping releases, while also providing a fallback.
Types ¶
type AuthTokenFunc ¶
AuthTokenFunc takes a token and returns either a UserInfo object or an error.
If ErrAuthInvalidToken is returned, a 401 will be returned to the user, otherwise a 500.
type LoggerConfig ¶
type Password ¶
type Password struct {
// contains filtered or unexported fields
}
func (*Password) BytesValue ¶
Click to show internal directories.
Click to hide internal directories.