Documentation
¶
Index ¶
- type Cache
- type Service
- func (s *Service) CheckPassHash(hash, password []byte) (bool, error)
- func (s *Service) CheckUserAuthStatus(r *http.Request) (int, bool, error)
- func (s *Service) EndUserSession(w http.ResponseWriter, r *http.Request, userID int) error
- func (s *Service) GetPasswordGeneratedKey(userID int) ([]byte, error)
- func (s *Service) HashAndSalt(password []byte) ([]byte, error)
- func (s *Service) InitUserSession(w http.ResponseWriter, r *http.Request, u *user.User, password []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) CheckUserAuthStatus ¶
*
- Check user's authentication status given *http.Request (containing cookies)
func (*Service) EndUserSession ¶
*
- End the user session by removing their session token from the cache,
- decrementing their session count (used for knowing when it is okay to remove
- their password-generated key from the cache), and overwrite the cookie on
- their browser with an immediately-expiring cookie
func (*Service) GetPasswordGeneratedKey ¶
*
- Get password-generated encryption key from cache for a given user-ID
func (*Service) HashAndSalt ¶
*
- Hash and salt a user's password using Bcrypt
- see https://medium.com/@jcox250/password-hash-salt-using-golang-b041dc94cb72
func (*Service) InitUserSession ¶
func (s *Service) InitUserSession(w http.ResponseWriter, r *http.Request, u *user.User, password []byte) error
*
- Initialize a user session by storing a session token in the session cache,
- storing a cookie on the user's browser and storing the password-generated key
- in the cache
Click to show internal directories.
Click to hide internal directories.