-
Notifications
You must be signed in to change notification settings - Fork 6.4k
fix: reset token-cookie on logout (oidc) #7092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jimtoniq ! added one minor comment
server/logout/logout.go
Outdated
@@ -85,11 +87,18 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||
if !strings.HasPrefix(cookie.Name, common.AuthCookieName) { | |||
continue | |||
} | |||
|
|||
argocdCookiePath := h.rootPath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to always use baseHRef
for cookie path. Server ensures that both --rootPath
and baseHRef
are in sync durign start:
argo-cd/cmd/argocd-server/commands/argocd_server.go
Lines 119 to 124 in 44520ea
if rootPath != "" { | |
if baseHRef != "" && baseHRef != rootPath { | |
log.Warnf("--basehref and --rootpath had conflict: basehref: %s rootpath: %s", baseHRef, rootPath) | |
} | |
baseHRef = rootPath | |
} |
So it is safe to assume that is rootPath is set then baseHRef is set as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks @alexmt!
So I would assume it would be better to change it here to a.ArgoCDServerOpts.baseHRef
as well? Then all token-cookies would be issued on the base-path.
Lines 634 to 639 in abba8dd
func (a *ArgoCDServer) setTokenCookie(token string, w http.ResponseWriter) error { | |
cookiePath := fmt.Sprintf("path=/%s", strings.TrimRight(strings.TrimLeft(a.ArgoCDServerOpts.RootPath, "/"), "/")) | |
flags := []string{cookiePath, "SameSite=lax", "httpOnly"} | |
if !a.Insecure { | |
flags = append(flags, "Secure") | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right. Current behavior looks like a bug. Just in case - let address it in a separate PR please.
Codecov Report
@@ Coverage Diff @@
## master #7092 +/- ##
=======================================
Coverage 41.08% 41.09%
=======================================
Files 158 158
Lines 21349 21350 +1
=======================================
+ Hits 8772 8773 +1
Misses 11311 11311
Partials 1266 1266
Continue to review full report at Codecov.
|
Signed-off-by: jimtoniq <thomasmuenzl@icloud.com>
Signed-off-by: jimtoniq <thomasmuenzl@icloud.com>
Signed-off-by: jimtoniq <thomasmuenzl@icloud.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
fix: reset token-cookie on logout (oidc) (argoproj#7092) Signed-off-by: jimtoniq <thomasmuenzl@icloud.com> Signed-off-by: viktorplakida <plakyda1@gmail.com>
Situation
We are running ArgoCD on a subpath (
/argo-cd
) and connected to OIDC.--basehref
is therefore set to/argo-cd
,--rootpath
is not set.When logging out via UI, it's impossible to login again.
Problem
On Logout, an empty-value cookie is sent, but the
path
does not match theargocd.token
cookie that was saved on login. Therefore the saved token is not overwritten. Login is not possible anymore because the token from the cookie would be used and is already revoked.Solution
With OIDC-Logins, the
basehref
is used as cookie-path (https://github.com/argoproj/argo-cd/blob/master/util/oidc/oidc.go#L313).With non-OIDC logins, the value of
--rootpath
is used as cookie-path (https://github.com/argoproj/argo-cd/blob/master/server/server.go#L635).Therefore I added a check when sending the empty-value cookie, if it is oidc-login.
An option would be to set the cookie-paths from direct-logins to the
basehref
as well, but I'm not sure about that.Note on DCO:
If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.
Checklist: