Files
archie/internal/webui/cookies.go
T

29 lines
966 B
Go

package webui
import "strings"
// cookieNames are the dashboard's cookie names. Browsers scope cookies by host
// and ignore the port, so each name carries the instance: two instances on
// one host would otherwise overwrite each other's sessions.
type cookieNames struct {
token, account, providerToken, loginState, loginVerifier, passkeyRegistration, passkeyLogin string
}
func newCookieNames(instance string) cookieNames {
prefix := strings.ReplaceAll(instance, "-", "_")
if prefix == "" {
prefix = "archie"
}
return cookieNames{
token: prefix + "_ui",
account: prefix + "_session",
providerToken: prefix + "_provider_token",
loginState: prefix + "_login_state",
loginVerifier: prefix + "_login_verifier",
passkeyRegistration: prefix + "_passkey_registration",
passkeyLogin: prefix + "_passkey_login",
}
}
func (s *Server) cookies() cookieNames { return newCookieNames(s.Instance) }