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)
| 22 | // produce it as a side-effect. Mirrors SetAdminCookie: host-scoped, HttpOnly, |
| 23 | // SameSite=Strict, 1-hour lifetime. |
| 24 | func 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 |
| 39 | func GetAdminCookie(gc *gin.Context) (string, error) { |
no test coverage detected