Skip to content

Commit

Permalink
fix(authn): create sessions only if UI header value is supplied
Browse files Browse the repository at this point in the history
Signed-off-by: Petu Eusebiu <[email protected]>
  • Loading branch information
eusebiu-constantin-petu-dbk committed Oct 12, 2023
1 parent ab45356 commit 079dbaf
Show file tree
Hide file tree
Showing 2 changed files with 279 additions and 197 deletions.
15 changes: 10 additions & 5 deletions pkg/api/authn.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ func (amw *AuthnMiddleware) basicAuthn(ctlr *Controller, userAc *reqCtx.UserAcce
userAc.AddGroups(groups)
userAc.SaveOnRequest(request)

// saved logged session
if err := saveUserLoggedSession(cookieStore, response, request, identity, ctlr.Log); err != nil {
return false, err
// saved logged session only if the request comes from web (has UI session header value)
if hasSessionHeader(request) {
if err := saveUserLoggedSession(cookieStore, response, request, identity, ctlr.Log); err != nil {
return false, err
}
}

// we have already populated the request context with userAc
Expand Down Expand Up @@ -163,8 +165,11 @@ func (amw *AuthnMiddleware) basicAuthn(ctlr *Controller, userAc *reqCtx.UserAcce
userAc.AddGroups(groups)
userAc.SaveOnRequest(request)

if err := saveUserLoggedSession(cookieStore, response, request, identity, ctlr.Log); err != nil {
return false, err
// saved logged session only if the request comes from web (has UI session header value)
if hasSessionHeader(request) {
if err := saveUserLoggedSession(cookieStore, response, request, identity, ctlr.Log); err != nil {
return false, err
}
}

// we have already populated the request context with userAc
Expand Down
Loading

0 comments on commit 079dbaf

Please sign in to comment.