Documentation ¶
Index ¶
- Variables
- func NewDB(config DatabaseConfig) (bucket *gocb.Bucket, err error)
- type AFCAccessClaims
- type AccessClaims
- type Accesser
- func (a *Accesser) AFCAdminMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func (a *Accesser) AFCAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func (a *Accesser) AdminAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func (a *Accesser) AdminInitAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func (a *Accesser) AuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func (a *Accesser) FindAdminToken(r *http.Request) bool
- func (a *Accesser) GetAFCToken(r *http.Request) (*AFCAccessClaims, error)
- func (a *Accesser) GetAdminToken(r *http.Request) (*jwt.Token, error)
- func (a *Accesser) GetAdminTokenKIDAndClaims(r *http.Request) (string, *jwt.StandardClaims, error)
- func (a *Accesser) GetToken(r *http.Request) (*AccessClaims, error)
- func (a *Accesser) NilMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- type Admin
- type AdminRequest
- type AdminResponse
- type Config
- type DatabaseConfig
- type Defaults
- type Error
- type Mail
- type MailConfig
- type Mailer
- type Permission
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoToken = errors.New("token not found") ErrInvalidToken = errors.New("invalid token") )
Functions ¶
func NewDB ¶
func NewDB(config DatabaseConfig) (bucket *gocb.Bucket, err error)
NewDB Initialises the connection to the database
Types ¶
type AFCAccessClaims ¶
type AFCAccessClaims struct { Id uint64 `json:"id"` Role string `json:"role"` jwt.StandardClaims }
type AccessClaims ¶
type AccessClaims struct { UserID int `json:"id"` Role string `json:"role"` Permissions []string `json:"perms"` jwt.StandardClaims }
AccessClaims represents an identifiable JWT
type Accesser ¶
type Accesser struct {
// contains filtered or unexported fields
}
func NewAccesser ¶
NewAccesser allows the validation of JWT tokens both as headers and as cookies
func (*Accesser) AFCAdminMiddleware ¶
func (a *Accesser) AFCAdminMiddleware(next echo.HandlerFunc) echo.HandlerFunc
func (*Accesser) AFCAuthMiddleware ¶
func (a *Accesser) AFCAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
AFCAuthMiddleware checks a HTTP request for a valid token either in the header or cookie
func (*Accesser) AdminAuthMiddleware ¶
func (a *Accesser) AdminAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
AdminAuthMiddleware checks a HTTP request for a valid token either in the header or cookie
func (*Accesser) AdminInitAuthMiddleware ¶
func (a *Accesser) AdminInitAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
AdminInitAuthMiddleware checks a HTTP request for a valid token either in the header or cookie
func (*Accesser) AuthMiddleware ¶
func (a *Accesser) AuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc
AuthMiddleware checks a HTTP request for a valid token either in the header or cookie
func (*Accesser) FindAdminToken ¶
FindAdminToken will return the claims from an AFC access token JWT
First will check the Authorization header, if unset will check the access cookie
func (*Accesser) GetAFCToken ¶
func (a *Accesser) GetAFCToken(r *http.Request) (*AFCAccessClaims, error)
GetAFCToken will return the claims from an AFC access token JWT
First will check the Authorization header, if unset will check the access cookie
func (*Accesser) GetAdminToken ¶
GetAdminToken will return the claims from an admin access token JWT
First will check the Authorization header, if unset will check the access cookie
func (*Accesser) GetAdminTokenKIDAndClaims ¶
GetAdminToken will return the claims from an admin access token JWT
First will check the Authorization header, if unset will check the access cookie
func (*Accesser) GetToken ¶
func (a *Accesser) GetToken(r *http.Request) (*AccessClaims, error)
GetToken will return the claims from an access token JWT
First will check the Authorization header, if unset will check the access cookie
func (*Accesser) NilMiddleware ¶
func (a *Accesser) NilMiddleware(next echo.HandlerFunc) echo.HandlerFunc
NilMiddleware checks a HTTP request for a valid token either in the header or cookie
type AdminRequest ¶
type AdminResponse ¶
type AdminResponse struct {
JWTToken string `json:"jwt_token"`
}
type DatabaseConfig ¶
type DatabaseConfig struct { Host string SSLMode string Bucket string Username string Password string }
DatabaseConfig represents a configuration to connect to an SQL database
type Mail ¶
type Mail struct { Subject string To string Cc []string Bcc []string From string Error error UseDefaults bool Tpl *template.Template TplData interface{} }
Mail represents an email to be sent
type MailConfig ¶
MailConfig represents a configuration to connect to an SMTP server
type Mailer ¶
type Mailer struct { *mail.SMTPClient Defaults Defaults Enabled bool }
Mailer encapsulates the dependency
func NewMailer ¶
func NewMailer(config MailConfig) (*Mailer, error)
NewMailer creates a new SMTP client
func (*Mailer) AddDefaults ¶
AddDefaults adds the default recipients
func (*Mailer) CheckSendable ¶
CheckSendable verifies that the email can be sent
func (*Mailer) SendErrorFatalMail ¶
SendErrorFatalMail sends a standard template error fatal email
func (*Mailer) SendErrorMail ¶
SendErrorMail sends a standard template error email
type Permission ¶
type Permission struct {
Name string `json:"name"`
}
Permission represents the permissions that a user has