feat(handler): set legacy cookie for sso server

This commit is contained in:
Trong Huu Nguyen
2023-05-11 20:28:21 +02:00
parent ae9448bf52
commit 390cd78e9f
2 changed files with 13 additions and 0 deletions

View File

@@ -148,6 +148,14 @@ func EncryptAndSet(w http.ResponseWriter, key, value string, opts Options, crypt
return nil
}
func SetLegacyCookie(w http.ResponseWriter, value string, opts Options) {
c := Make(loginservice, value, opts.
WithSameSite(http.SameSiteNoneMode).
WithPath("/"))
c.UnsetExpiry()
Set(w, c)
}
func ClearLegacyCookies(w http.ResponseWriter, opts Options) {
// TODO - remove when legacy services are sunset and shut down
Clear(w, loginservice, opts.

View File

@@ -210,6 +210,11 @@ func (s *Standalone) LoginCallback(w http.ResponseWriter, r *http.Request) {
"jti": tokens.IDToken.GetJwtID(),
}
// TODO - remove when legacy services are sunset and shut down
if s.Config.SSO.IsServer() && s.Config.OpenID.Provider == config.ProviderIDPorten {
cookie.SetLegacyCookie(w, tokens.AccessToken, opts)
}
mw.LogEntryFrom(r).WithFields(fields).Info("callback: successful login")
metrics.ObserveLogin(tokens.IDToken.GetAmrClaim(), redirect)
cookie.Clear(w, cookie.Retry, s.GetCookieOptions(r))