Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
RabbITCybErSeC committed Oct 9, 2024
1 parent 7496e99 commit 74421c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 8 additions & 3 deletions auth/cookies/cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = "/"
Expand Down
3 changes: 0 additions & 3 deletions auth/gin_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"crypto/tls"
"errors"
"fmt"
"net/http"
"soarca-gui/auth/api"

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 74421c1

Please sign in to comment.