MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / BuildAdminCookie

Function BuildAdminCookie

internal/cookie/admin_cookie.go:24–36  ·  view source on GitHub ↗

BuildAdminCookie returns the admin session cookie to set on the response. Transport-agnostic so non-gin callers (the service layer, gRPC handlers) can produce it as a side-effect. Mirrors SetAdminCookie: host-scoped, HttpOnly, SameSite=Strict, 1-hour lifetime.

(hostname, token string, adminCookieSecure bool)

Source from the content-addressed store, hash-verified

22// produce it as a side-effect. Mirrors SetAdminCookie: host-scoped, HttpOnly,
23// SameSite=Strict, 1-hour lifetime.
24func BuildAdminCookie(hostname, token string, adminCookieSecure bool) *http.Cookie {
25 host, _ := parsers.GetHostParts(hostname)
26 return &http.Cookie{
27 Name: constants.AdminCookieName,
28 Value: token,
29 MaxAge: 3600,
30 Path: "/",
31 Domain: host,
32 Secure: adminCookieSecure,
33 HttpOnly: true,
34 SameSite: http.SameSiteStrictMode,
35 }
36}
37
38// GetAdminCookie gets the admin cookie from the request
39func GetAdminCookie(gc *gin.Context) (string, error) {

Callers 3

AdminLoginMethod · 0.92
AdminSessionMethod · 0.92
SetAdminCookieFunction · 0.85

Calls 1

GetHostPartsFunction · 0.92

Tested by

no test coverage detected