Documentation ¶
Index ¶
- Constants
- Variables
- func CleanExpiredRefresh(ctx context.Context, hndl *db.Db) error
- func CleanExpiredRegistrations(ctx context.Context, hndl *db.Db) error
- func DoLogin(lf *pages.LoginForm, db *db.Db, w http.ResponseWriter, r *http.Request) error
- func DoRegister(rf *pages.RegisterPage, mail *util.SmtpClient, db *db.Db, ...) bool
- func DoRegisterDone(db *db.Db, w http.ResponseWriter, r *http.Request) (*pages.PostRegisterPage, bool)
- func FinishRegistration(ctx context.Context, hndl *db.Db, token string) error
- func GetEcdsaKey(config *lutra.LutraConfig) *ecdsa.PrivateKey
- func LoadEscdaKeyAsBin(config *lutra.LutraConfig) []byte
- type Credentials
- func (c *Credentials) CheckPassword(pwText string) error
- func (c *Credentials) CheckUser(ctx context.Context, hndl *db.Db) error
- func (c *Credentials) CreateRefreshToken(ctx context.Context, w http.ResponseWriter, r *http.Request, hndl *db.Db) error
- func (c *Credentials) SetJWTCookie(w http.ResponseWriter, r *http.Request)
- type Env
- type RefreshToken
Constants ¶
View Source
const ( // NotAuthorized means, Authorization Cookie not Found NotAuthorized = iota // CookieError reports trouble with the golang Request CookieError // AuthorizationExpired say Authorization Cookie is Ok, but Expired AuthorizationExpired // AuthorizationFound says that the Cookie is presend and needs to be validated AuthorizationFound // Authorized says that the User is Authorized via JWT Cookie Authorized // SignatureInvalid Error SignatureInvalid // AuthorizationFailed is a general Error in Authorizing a Request AuthorizationFailed )
Variables ¶
View Source
var ErrNoAuth = errors.New("Not Authorized")
View Source
var ErrPassword = errors.New("Password do not match")
ErrPassword indicates that the given Password does not match its master in the DB
View Source
var ErrRefresh = errors.New("refresh of Authorization failed")
ErrRefresh indicates that the Request Token handeling failed
Functions ¶
func DoRegister ¶
func DoRegister(rf *pages.RegisterPage, mail *util.SmtpClient, db *db.Db, w http.ResponseWriter, r *http.Request) bool
DoRegister handles the Register Requests
func DoRegisterDone ¶
func DoRegisterDone(db *db.Db, w http.ResponseWriter, r *http.Request) (*pages.PostRegisterPage, bool)
DoRegisterDone activates the User after registration
func FinishRegistration ¶
FinishRegistration finishes the Registration and activates the User
func GetEcdsaKey ¶
func GetEcdsaKey(config *lutra.LutraConfig) *ecdsa.PrivateKey
func LoadEscdaKeyAsBin ¶
func LoadEscdaKeyAsBin(config *lutra.LutraConfig) []byte
Types ¶
type Credentials ¶
type Credentials struct { Username string `json:"username"` Password string `json:"-", bson:"-"` jwt.StandardClaims // contains filtered or unexported fields }
Credentials are decoded from the Token Cookie
func CheckRefresh ¶
func CheckRefresh(w http.ResponseWriter, r *http.Request) (*Credentials, error)
ChecksRefresh updates auth and refresh token
func FindAuthorization ¶
FindAuthorization tries to Authorize a http Request via Cookie
func (*Credentials) CheckPassword ¶
func (c *Credentials) CheckPassword(pwText string) error
CheckPassword checks the user Password entered from Form
func (*Credentials) CreateRefreshToken ¶
func (c *Credentials) CreateRefreshToken(ctx context.Context, w http.ResponseWriter, r *http.Request, hndl *db.Db) error
CreateRefreshToken creates a new Refresh Token on given claims
func (*Credentials) SetJWTCookie ¶
func (c *Credentials) SetJWTCookie(w http.ResponseWriter, r *http.Request)
SetJWTCookie sets a JWT Cookie for valid trusted Credentials
Click to show internal directories.
Click to hide internal directories.