feat(auth): renew sessions with 30-day idle and 90-day absolute limits
This commit is contained in:
@@ -69,7 +69,7 @@ func (s *service) protected(callbacks map[string]string, handle endpoint) http.H
|
||||
return
|
||||
}
|
||||
w.Header().Set("Access-Control-Allow-Origin", origin)
|
||||
w.Header().Set("Access-Control-Expose-Headers", "ETag")
|
||||
w.Header().Set("Access-Control-Expose-Headers", "ETag, "+auth.SessionExpiryHeader)
|
||||
}
|
||||
if r.Method == http.MethodOptions {
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PATCH, DELETE, OPTIONS")
|
||||
@@ -77,11 +77,15 @@ func (s *service) protected(callbacks map[string]string, handle endpoint) http.H
|
||||
reply(w, 204, nil)
|
||||
return
|
||||
}
|
||||
account, err := auth.Authenticate(r.Context(), s.db, project, r.Header.Get("Authorization"))
|
||||
session, err := auth.AuthenticateSession(r.Context(), s.db, project, r.Header.Get("Authorization"))
|
||||
if errors.Is(err, auth.ErrInvalidSession) {
|
||||
reject(w, 401, "invalid_session")
|
||||
return
|
||||
}
|
||||
account := session.AccountID
|
||||
if err == nil {
|
||||
auth.WriteSessionHeaders(w, session)
|
||||
}
|
||||
if err == nil && r.PathValue("workspace") != "" {
|
||||
var id string
|
||||
err = s.db.QueryRowContext(r.Context(), "SELECT id::text FROM workspaces WHERE project=$1 AND (id::text=$2 OR slug=$2)", project, r.PathValue("workspace")).Scan(&id)
|
||||
|
||||
Reference in New Issue
Block a user