Versions in this module Expand all Collapse all v0 v0.1.1 Jan 22, 2023 v0.1.0 Jan 22, 2023 Changes in this version + const AuthUserKey + const AuthorizationHeader + const PolicyTableName + const UserTableName + func GenJWTToken(secret []byte, data map[string]any) (string, error) + func HashPassword(password string) (string, error) + func ParseJWTToken(secret []byte, tokenString string) (map[string]any, error) + func Setup(db *sql.DB) (username, password string, err error) + type Action int + const ActionCreate + const ActionDelete + const ActionRead + const ActionReadMine + const ActionUpdate + func (a Action) String() string + type AuthUserCtxKey string + type Handler struct + func NewHandler(dbURL string, secret []byte) (*Handler, error) + func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) + type Middleware func(http.Handler) http.Handler + func NewMiddleware(secret []byte) Middleware + type Policy struct + Action string + Description string + Expression string + ID int64 + TableName string + type User struct + ID int64 + IsAdmin bool + Password string + Username string + func GetUser(r *http.Request) *User + func (u *User) HasPerm(table string, action Action, policies map[string]map[string]string) (hasPerm bool, withUserIDColumn string) + func (u *User) IsAnonymous() bool + func (u *User) IsAuthenticated() bool