From 74421c10a2e6f8a4a02d2a0c03e593c295ed9c10 Mon Sep 17 00:00:00 2001 From: JP Date: Wed, 9 Oct 2024 20:33:54 +0200 Subject: [PATCH] clean up --- auth/cookies/cookie.go | 11 ++++++++--- auth/gin_oidc.go | 3 --- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/auth/cookies/cookie.go b/auth/cookies/cookie.go index d379eec..e680d32 100644 --- a/auth/cookies/cookie.go +++ b/auth/cookies/cookie.go @@ -53,7 +53,10 @@ func (cj *CookieJar) GetUserToken(context *gin.Context) (value string, isNew boo } func (cj *CookieJar) SetUserToken(context *gin.Context, token string) error { - session, _ := cj.store.Get(context.Request, USER_TOKEN) + session, err := cj.store.Get(context.Request, USER_TOKEN) + if err != nil { + return err + } session.Values["token"] = token session.Options.MaxAge = 60 * 60 * 8 @@ -72,8 +75,10 @@ func (cj *CookieJar) DeleteNonceSession(context *gin.Context) error { } func (cj *CookieJar) setCallBackSession(context *gin.Context, name string, stateValue string) error { - session, _ := cj.store.Get(context.Request, name) - + session, err := cj.store.Get(context.Request, name) + if err != nil { + return err + } session.Values["state"] = stateValue session.Options.MaxAge = 60 * 5 session.Options.Path = "/" diff --git a/auth/gin_oidc.go b/auth/gin_oidc.go index da1cc8d..92f3192 100644 --- a/auth/gin_oidc.go +++ b/auth/gin_oidc.go @@ -4,7 +4,6 @@ import ( "context" "crypto/tls" "errors" - "fmt" "net/http" "soarca-gui/auth/api" @@ -25,7 +24,6 @@ func (auth *Authenticator) OIDCRedirectToLogin(gc *gin.Context) { return } err = auth.Cookiejar.SetCallBackNonce(gc, nonce) - fmt.Println(err) if err != nil { api.JSONErrorStatus(gc, http.StatusInternalServerError, errors.New("failed to set nonce")) return @@ -40,7 +38,6 @@ func (auth *Authenticator) OIDCRedirectToLogin(gc *gin.Context) { func (auth *Authenticator) OIDCCallBack(gc *gin.Context) { state, isNew := auth.Cookiejar.GetStateSession(gc) - fmt.Println("state is new ", isNew) if isNew || state == "" { api.JSONErrorStatus(gc, http.StatusBadRequest, errors.New("state missing")) return