Skip to content

Commit

Permalink
fix(backend): fix go dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Urban committed Oct 11, 2023
1 parent 32bcbfe commit c850422
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/cmd/kubevoyage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func setupServer(handle *handlers.Handler) http.Handler {
handle.HandleAuthenticate(w, r)
})
mux.HandleFunc("/api/request", func(w http.ResponseWriter, r *http.Request) {
handlers.HandleRequestSite(w, r, db)
handle.HandleRequestSite(w, r, db)
})

return handler
Expand Down
2 changes: 1 addition & 1 deletion backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/B-Urb/KubeVoyage
go 1.21

require (
github.com/golang-jwt/jwt/v5 v5.0.0
github.com/rs/cors v1.10.0
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.13.0
Expand All @@ -15,7 +16,6 @@ require (
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.3.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE=
Expand Down
6 changes: 3 additions & 3 deletions backend/internal/handlers/middleware.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package handlers

import (
"github.com/dgrijalva/jwt-go"
"github.com/golang-jwt/jwt/v5"
"net/http"
"net/url"
)
Expand All @@ -16,7 +16,7 @@ func handleUnauthenticated(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, url.QueryEscape(redirectURL), http.StatusSeeOther)
}

func authenticate(next http.HandlerFunc) http.HandlerFunc {
func (h *Handler) authenticate(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
cookie, err := r.Cookie("auth_token")
if err != nil {
Expand All @@ -28,7 +28,7 @@ func authenticate(next http.HandlerFunc) http.HandlerFunc {
claims := &jwt.MapClaims{}

token, err := jwt.ParseWithClaims(tokenStr, claims, func(token *jwt.Token) (interface{}, error) {
return jwtKey, nil
return h.JWTKey, nil
})

if err != nil || !token.Valid {
Expand Down
4 changes: 2 additions & 2 deletions backend/internal/handlers/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func HandleRequests(w http.ResponseWriter, r *http.Request, db *gorm.DB) {

}

func HandleRequestSite(w http.ResponseWriter, r *http.Request, db *gorm.DB) {
userEmail, err := getUserEmailFromToken(r)
func (h *Handler) HandleRequestSite(w http.ResponseWriter, r *http.Request, db *gorm.DB) {
userEmail, err := h.getUserEmailFromToken(r)
if err != nil {
http.Error(w, err.Error(), http.StatusUnauthorized)
return
Expand Down

0 comments on commit c850422

Please sign in to comment.