gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit774bf34b774bf34bnotes security: CSRF guard on /api/notes, new session at login, Secure cookie, uploadMax 0, login rate limit, nosniff, face payload check; tests/security.mjs; SN reportmre774bf34b/lib/ratelimit.hl

980 B

  1. // lib/ratelimit.hl — A SMALL RATE LIMIT for the login (notes mission SN): every login attempt asks ident over the network, so a
  2. // flood of wrong codes must be slowed down. Per client IP: the X-Client-IP header nginx sets on Byrodin (nginx overwrites what a
  3. // client sent; X-Forwarded-For & co. are never read, as in ident). No header (dev) = one shared bucket. In memory: a restart forgets it.
  4. import { now } from 'hl:time'
  5. static loginWindowMs = 600000
  6. static loginMax = 30
  7. static tries = {}
  8. // may the client `ip` try a login now? Counts the try. false = too many in the window.
  9. static loginAllowed = (ip) => {
  10. key = ip == null || hlTypeName(ip) != 'String' || ip.trim() == '' ? 'direct' : ip.trim().toLowerCase().slice(0, 64)
  11. t = now()
  12. kept = []
  13. old = tries[key]
  14. if (old != null) { for (x of old) { if (t - x < loginWindowMs) { kept.push(x) } } }
  15. if (kept.length >= loginMax) {
  16. tries[key] = kept
  17. return false
  18. }
  19. kept.push(t)
  20. tries[key] = kept
  21. return true
  22. }

Branches

Latest commits

  • 774bf34bnotes security: CSRF guard on /api/notes, new session at login, Secure cookie, uploadMax 0, login rate limit, nosniff, face payload check; tests/security.mjs; SN reportmre
  • ef18a68fsync components.hybriel 214c318: MdEditor on a phone, two even toolbar rows of 44 px targets, label 15 px, table head 16 px (E2)mre
  • c37488b1MN report: alignment updatemre
  • 4fb35a0enotes mobile: Delete note and the delete row exactly on the editor's edges; gate asserts 1 pxmre
  • 91736270MN report and logmre
  • 15667425notes: delete confirmation buttons at most 12rem wide on the desktopmre
  • 8f7a6a95gate: MN phone checks (list header gutter, back gap, delete question)mre
  • 90c73ed3notes mobile: back link gapmre
  • 72bd4f83notes mobile: list header on the gutter, delete confirmation as a question + two equal buttons, Delete note under the editor edgemre
  • ba1e73f8notes: a sent edit is done once the server's version is not older, so a second writer's text shows in the first tab; gate: two writers both waysmre
  • c69ef9ebsync components.hybriel 134b4e3: MdEditor builds an editor put into the page at once, redraws a surface put in anew (F5, hybriel#211)mre
  • 2eb783f5sync components 9a: shared Icon (icons/icons.hl), md-editor toolbar icons + single focus ring (components f4-icons ba96735)mre
  • 4dd46dadsync-components: copy icons/icons.hl + README (F4); testsmre
  • c92e4a0ftests/e2e-outside.mjs: real-Chrome E2E, a note pushed from another device while open, then typingmre
  • 0516b4ccmd-editor.hl: verbatim copy of components f3-mdvalue (an older text handed back is kept)mre
  • 38cc11ecmd-editor.hl: verbatim copy of components f3-mdvalue (an outside value change is shown by the editor)mre
  • 3e7e79f5reports/H1-hydrate.mdmre
  • d98775e8tests/browser.mjs: wait for hydration before the clicks after a goto('/') (tables new note, phone sidebar)mre
  • 1f3198b6tests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre
  • 39cf9fdfre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre