Documentation ¶
Index ¶
- func Validate(dto dtos.LoginDto) error
- type Auth
- func (h *Auth) Login(rw http.ResponseWriter, r *http.Request)
- func (h *Auth) Logout(rw http.ResponseWriter, r *http.Request)
- func (h *Auth) Register(rw http.ResponseWriter, r *http.Request)
- func (h *Auth) Session(rw http.ResponseWriter, r *http.Request)
- func (h *Auth) VerifyLoggedIn(rw http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Auth ¶
type Auth struct { Auth authentication.IAuthentication Rabbit *rabbit.RabbitMessageBroker // contains filtered or unexported fields }
Auth is the user handler to handle authentication requests of users.
func NewAuth ¶
func NewAuth(logger *zap.SugaredLogger, auth authentication.IAuthentication, rabbit *rabbit.RabbitMessageBroker) *Auth
NewAuth creates a new user handler with the specified dependencies.
func (*Auth) Login ¶
func (h *Auth) Login(rw http.ResponseWriter, r *http.Request)
Login authenticates the user and generates a cookie remember this . swagger:route POST /api/auth/login authentication loginUser
Login to a user account ¶
After matching credentials, this will generate a jwt and pass it on as a cookie
Consumes: - application/json - application/x-www-form-urlencoded Produces: - application/json Security: - api_key Schemes: http, https Responses: default: ErrorResponse 400: ErrorResponse 422: ValidationErrorResponse 404: ErrorResponse 401: ErrorResponse 403: ErrorResponse 500: ErrorResponse 200: UserResponse
func (*Auth) Logout ¶
func (h *Auth) Logout(rw http.ResponseWriter, r *http.Request)
Logout removes the cookie and therefore logs the user out swagger:route POST /account/logout account logoutUser
Logout of account ¶
This will remove the identity cookie
Consumes: Produces: - application/json Schemes: http, https Security: api_key: Responses: default: ErrorResponse 401: ErrorResponse 200: NoContentResponse
func (*Auth) Register ¶
func (h *Auth) Register(rw http.ResponseWriter, r *http.Request)
Register registers a new user swagger:route POST /account/register authentication registerUser
Register a new user
This will register a new user with the provided details
Consumes: - application/json Produces: - application/json Schemes: http, https Responses: default: ErrorResponse 400: ErrorResponse 403: ErrorResponse 422: ValidationErrorResponse 500: ErrorResponse 200: UserResponse
func (*Auth) Session ¶
func (h *Auth) Session(rw http.ResponseWriter, r *http.Request)
Session verifies the session and extends the jwt token if valid. swagger:route GET /api/auth/session session
Session verifies the session and extends the jwt token if valid. This does not perform a user lookup. GET /api/user does this if the session is correct.
After verification the extended jwt will be passed as a cookie and the user id and username will be returned
Consumes: Produces: - application/json Schemes: http, https Responses: default: ErrorResponse 401: ErrorResponse 200: UserResponse
func (*Auth) VerifyLoggedIn ¶
func (h *Auth) VerifyLoggedIn(rw http.ResponseWriter, r *http.Request)
VerifyLoggedIn verifies and validates the cookie and it's jwt token. returns 401 if you are not signed in and 200 if everything is valid- swagger:route GET /account/verify authentication account verifyLoggedIn
Verify that the user is logged in ¶
This will return either status code 401 Unauthorized if user is not signed in and 200 when the login token is valid
Consumes: Produces: - application/json Schemes: http, https Security: Responses: default: SessionInfo 200: NoContentResponse