Remove authentication Cookies from Backend

This commit is contained in:
Jan Bader 2022-01-23 21:35:23 +00:00
parent 4f72751ed6
commit 3da2e0f2f8
2 changed files with 0 additions and 16 deletions

View File

@ -23,7 +23,6 @@ type Handler struct {
const ( const (
expiration = 72 expiration = 72
authCookie = "authentication"
) )
// Serve starts the HTTP Server // Serve starts the HTTP Server
@ -76,9 +75,6 @@ func (h *Handler) Serve() {
authenticated.Use(h.verifyLoginWithForbidden) authenticated.Use(h.verifyLoginWithForbidden)
authenticated.GET("/dashboard", h.dashboard) authenticated.GET("/dashboard", h.dashboard)
user := authenticated.Group("/user")
user.GET("/logout", logout)
budget := authenticated.Group("/budget") budget := authenticated.Group("/budget")
budget.POST("/new", h.newBudget) budget.POST("/new", h.newBudget)

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"net/http" "net/http"
"time"
"git.javil.eu/jacob1123/budgeteer" "git.javil.eu/jacob1123/budgeteer"
"git.javil.eu/jacob1123/budgeteer/postgres" "git.javil.eu/jacob1123/budgeteer/postgres"
@ -16,7 +15,6 @@ func (h *Handler) verifyLogin(c *gin.Context) (budgeteer.Token, error) {
tokenString = tokenString[7:] tokenString = tokenString[7:]
token, err := h.TokenVerifier.VerifyToken(tokenString) token, err := h.TokenVerifier.VerifyToken(tokenString)
if err != nil { if err != nil {
c.SetCookie(authCookie, "", -1, "", "", false, false)
return nil, fmt.Errorf("verify token '%s': %w", tokenString, err) return nil, fmt.Errorf("verify token '%s': %w", tokenString, err)
} }
@ -65,14 +63,6 @@ func (h *Handler) register(c *gin.Context) {
c.HTML(http.StatusOK, "register.html", nil) c.HTML(http.StatusOK, "register.html", nil)
} }
func logout(c *gin.Context) {
clearLogin(c)
}
func clearLogin(c *gin.Context) {
c.SetCookie(authCookie, "", -1, "", "", false, true)
}
type loginInformation struct { type loginInformation struct {
Password string `json:"password"` Password string `json:"password"`
User string `json:"user"` User string `json:"user"`
@ -103,8 +93,6 @@ func (h *Handler) loginPost(c *gin.Context) {
go h.Service.UpdateLastLogin(context.Background(), user.ID) go h.Service.UpdateLastLogin(context.Background(), user.ID)
maxAge := (int)((expiration * time.Hour).Seconds())
c.SetCookie(authCookie, t, maxAge, "", "", false, true)
c.JSON(http.StatusOK, map[string]string{ c.JSON(http.StatusOK, map[string]string{
"token": t, "token": t,
}) })