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 AccesserConfig
- type Admin
- type AdminRequest
- type AdminResponse
- type Config
- type DatabaseConfig
- type Defaults
- type Error
- type Mail
- type Mailer
- type MailerInit
- 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 ¶
func NewAccesser(conf AccesserConfig) *Accesser
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 ¶
GetAdminTokenKIDAndClaims 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 AccesserConfig ¶
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 Tpl *template.Template TplData interface{} }
Mail represents an email to be sent
type Mailer ¶
type Mailer struct { *mail.SMTPClient Defaults Defaults }
Mailer is the struct that is used to send mail, can only be used once connected to mailer
func (*Mailer) CheckSendable ¶
CheckSendable verifies that the email can be sent
type MailerInit ¶
type MailerInit struct { SMTPServer mail.SMTPServer Defaults Defaults }
MailerInit is the config store for the mailer, can be initialised once then connected multiple times
func (*MailerInit) ConnectMailer ¶
func (m *MailerInit) ConnectMailer() *Mailer
ConnectMailer connects to the mail server
type Permission ¶
type Permission struct {
Name string `json:"name"`
}
Permission represents the permissions that a user has