fix: IDEAS.md quickfixes — idle-timeout app config, id_token out of Claims, FormEvent import
session.idle_timeout (minutes, default 15) joins the app-config registry and drives the onboarding Garmin session eviction, distinct from session.duration (the login cookie lifetime in hours). The raw Keycloak ID token no longer rides in auth.Claims through every request context: it's minted into the session cookie separately and read back only by the logout handler via IDTokenFromSessionCookie. OnboardingWizard uses the type-imported FormEvent<HTMLFormElement> instead of the React.FormEvent namespace alias. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -82,7 +82,7 @@ func (s *Server) handleSessionCallback(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sessionCookie, err := auth.MintSessionCookie(result.Claims, s.SessionConfig.Secret, s.SessionConfig.Duration, s.SessionConfig.Secure)
|
||||
sessionCookie, err := auth.MintSessionCookie(result.Claims, result.IDToken, s.SessionConfig.Secret, s.SessionConfig.Duration, s.SessionConfig.Secure)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
@@ -93,15 +93,23 @@ func (s *Server) handleSessionCallback(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// handleSessionLogout clears geniusrun's own session cookie and redirects
|
||||
// through Keycloak's end-session endpoint, passing the session's ID token
|
||||
// as id_token_hint (see auth.Claims.IDToken) so Keycloak can skip its own
|
||||
// logout-confirmation prompt -- otherwise a user could cancel out of it and
|
||||
// land back on the app with a Keycloak SSO session but no geniusrun profile
|
||||
// (already deleted, in the profile-deletion case this exists for).
|
||||
// as id_token_hint (read back from the cookie via
|
||||
// auth.IDTokenFromSessionCookie -- it deliberately doesn't ride in Claims)
|
||||
// so Keycloak can skip its own logout-confirmation prompt -- otherwise a
|
||||
// user could cancel out of it and land back on the app with a Keycloak SSO
|
||||
// session but no geniusrun profile (already deleted, in the
|
||||
// profile-deletion case this exists for).
|
||||
func (s *Server) handleSessionLogout(w http.ResponseWriter, r *http.Request) {
|
||||
claims, _ := auth.ClaimsFromContext(r.Context())
|
||||
s.removeSetupSession(claims.Sub)
|
||||
// Best-effort: an unreadable cookie just means logging out without the
|
||||
// hint, at worst showing Keycloak's own confirmation screen.
|
||||
var idToken string
|
||||
if cookie, err := r.Cookie(auth.SessionCookieName); err == nil {
|
||||
idToken, _ = auth.IDTokenFromSessionCookie(cookie, s.SessionConfig.Secret)
|
||||
}
|
||||
http.SetCookie(w, auth.ClearCookie(auth.SessionCookieName, s.SessionConfig.Secure))
|
||||
http.Redirect(w, r, s.Auth.EndSessionURL(s.SessionConfig.FrontendURL+"/", claims.IDToken), http.StatusFound)
|
||||
http.Redirect(w, r, s.Auth.EndSessionURL(s.SessionConfig.FrontendURL+"/", idToken), http.StatusFound)
|
||||
}
|
||||
|
||||
func (s *Server) handleSessionMe(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user