mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-24 06:28:42 +01:00
feat: supports auth ttl to override session with DOZZLE_AUTH_TTL env. (#3313)
This commit is contained in:
@@ -12,12 +12,18 @@ func (h *handler) createToken(w http.ResponseWriter, r *http.Request) {
|
||||
pass := r.PostFormValue("password")
|
||||
|
||||
if token, err := h.config.Authorization.Authorizer.CreateToken(user, pass); err == nil {
|
||||
expires := time.Time{}
|
||||
if h.config.Authorization.TTL > 0 {
|
||||
expires = time.Now().Add(h.config.Authorization.TTL)
|
||||
}
|
||||
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: "jwt",
|
||||
Value: token,
|
||||
HttpOnly: true,
|
||||
Path: "/",
|
||||
SameSite: http.SameSiteLaxMode,
|
||||
Expires: expires,
|
||||
})
|
||||
log.Info().Str("user", user).Msg("Token created")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
Reference in New Issue
Block a user