gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf0cbe6a6f0cbe6a6gitoria: standby service on port 45014 and a deploy that hands over through it without a gapmref0cbe6a6/components/sshkeys.hl

3.9 KB

  1. // components/sshkeys.hl — SSH KEYS (gitoria#7): what a developer's git uses to push over SSH (docker/sshd asks sshkeys.hl). On the
  2. // main address, for a logged-in user: paste a PUBLIC key with a name, list the own keys (name, fingerprint), remove one. Only shown
  3. // when the sshd container is set up (GITORIA_SSH_SECRET). Composed into list.hl (`#sshkeys`).
  4. import { infoOfSession, userOfSession, userIdOfSession } from '../lib/users.hl'
  5. import { sshEnabled, keyRows, addKey, revokeKey } from '../lib/sshkeys.hl'
  6. session = null
  7. me = infoOfSession(session)
  8. enabled = sshEnabled
  9. shown = enabled && me != null
  10. myUserId = userIdOfSession(session)
  11. keyItems = myUserId != null && enabled ? keyRows(myUserId) : []
  12. showHead = shown
  13. showForm = shown
  14. showNone = shown && keyItems.length == 0
  15. keyError = ''
  16. keyNameText = ''
  17. keyText = ''
  18. View {
  19. sshKeys { id = "sshkeys"
  20. if (showHead) { h2 { "SSH keys" } }
  21. if (showHead) { p { class = "muted" "To push with git over SSH, add your public key (the .pub file, for example ~/.ssh/id_ed25519.pub). Reading a repository needs no key." } }
  22. if (showForm) {
  23. form { id = "keyform"
  24. on submit(e) {
  25. e.preventDefault()
  26. emit makeKey(e)
  27. }
  28. label { "Name (for example the computer it is for)"
  29. input { id = "keyname" name = "keyname" required = "required" maxlength = "60" autocomplete = "off" value = keyNameText on input(e) { emit setKeyName(e.target.value) } }
  30. }
  31. label { "Public key"
  32. textarea { id = "keytext" name = "keytext" required = "required" rows = "3" spellcheck = "false" autocomplete = "off" placeholder = "ssh-ed25519 AAAA… you@computer" on input(e) { emit setKeyText(e.target.value) } keyText }
  33. }
  34. button { id = "keysave" type = "submit" "Add key" }
  35. p { id = "keyerror" class = "message" keyError }
  36. }
  37. }
  38. if (showNone) { p { id = "nokeys" class = "muted" "You have no SSH keys yet." } }
  39. ol { id = "keylist"
  40. for (k of keyItems) {
  41. li {
  42. span { class = "slug" k.name }
  43. code { class = "fingerprint" k.fingerprint }
  44. time { k.created }
  45. button { class = "quiet removekey" type = "button" value = k.id "Remove" on click(e) { emit removeKey(e.target.value) } }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. // one `if` per element, none inside another (a nested `if` broke the client's repaint on logout)
  52. on setKeyName(v) { keyNameText = v }
  53. on setKeyText(v) { keyText = v }
  54. on makeKey(e) {
  55. r = emit server gitoriaAddKey(keyNameText, keyText)
  56. if (r == null || r.error != null) {
  57. keyError = r != null ? r.error : 'could not add the key'
  58. return null
  59. }
  60. keyError = ''
  61. keyNameText = ''
  62. keyText = ''
  63. // the face's answer can bring `keyItems` fresh from the server already (hl:web ships a member derived from
  64. // `session` in the ack's sync, hybriel 64527baa) — so the new row is put on top ONCE, never twice
  65. next = [r.row]
  66. for (x of keyItems) { if (x.id != r.row.id) { next.push(x) } }
  67. keyItems = next
  68. showNone = shown && keyItems.length == 0
  69. }
  70. on removeKey(id) {
  71. r = emit server gitoriaRemoveKey(id)
  72. if (r == null || r.error != null) {
  73. keyError = r != null ? r.error : 'could not remove the key'
  74. return null
  75. }
  76. keyError = ''
  77. next = []
  78. for (x of keyItems) { if (x.id != id) { next.push(x) } }
  79. keyItems = next
  80. showNone = shown && keyItems.length == 0
  81. }
  82. // a login / logout (the shell's faces push them) shows or hides the section
  83. on client gitoriaSignedIn(tag, info) {
  84. shown = enabled
  85. showHead = shown
  86. showForm = shown
  87. showNone = shown && keyItems.length == 0
  88. }
  89. on client gitoriaSignedOut(tag) {
  90. shown = false
  91. keyItems = []
  92. showHead = false
  93. showForm = false
  94. showNone = false
  95. }
  96. on server gitoriaAddKey(name, text, session) {
  97. if (!sshEnabled) { return { error = 'SSH is not set up on this server' } }
  98. u = userOfSession(session)
  99. if (u == null) { return { error = 'log in with ident (top right) first' } }
  100. return addKey(u.id, name, text)
  101. }
  102. on server gitoriaRemoveKey(id, session) {
  103. u = userOfSession(session)
  104. if (u == null) { return { error = 'log in with ident (top right) first' } }
  105. return revokeKey(u.id, id)
  106. }

Branches

Latest commits

  • f0cbe6a6gitoria: standby service on port 45014 and a deploy that hands over through it without a gapmre
  • 727cd083gitoria#25: README: vendor notes for Hybriel c1b1010f and the page cachemre
  • 61b72dedgitoria#25: re-vendor Hybriel master c1b1010f (W149 page cache), key the repo Readme page by slug and main commit, extend the readme-cache gatemre
  • 5b0b4b9ereadme-cache gate: use the security gate's ports when no own ports are givenmre
  • bc8f20d9gitoria#25: re-vendor Hybriel c09538bb with the W141 render cache, cache the homepage per commit, add the readme-cache gatemre
  • 9feebbd3Re-vendor Hybriel to ded47c13 (W145: Firefox start script fix)mre
  • 28ed41e5gitoria#24: one sign-in comes from hl:web batch 20, the /session/share workaround is gonemre
  • 3b2669e4gs: drop the unbuildable legacy check, fix pwa fetchmre
  • 2a2fdd77gs: C2 check before cookie experimentsmre
  • 76e0587aWIP gs 2mre
  • a80da7bdWIP gs: security gate for lazy sessions, g24 browser checksmre
  • 23fb05d8re-vendor Hybriel aaa39e69 (hl:web batch 20: login emit and Sessions.mint, tab follows a login, signed-in session cookie wins among duplicates and is re-issued with the Domain, W85 faster render, lazy sessions)mre
  • a0727ca3ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
  • a06975f9gitoria: a gap between your name and Log out in the phone header (they touched); gate checks itmre
  • 32ba9d59gitoria: leave the host-only cookie experiment out of the browser gate (gitoria#24 is a separate mission)mre
  • 43ad2bcfgitoria header: the selector alone plus your name and Log out as before the theme missions; tests follow (WIP: host-only cookie experiment fails)mre
  • ac2c4e3fident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
  • b279f536theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 2b01515ctests/ticketskit: a failed start kills the tickets server (own process group); stop() kills the groupmre
  • 109cfc5ctests/ticketskit: keep the rotated session cookie of the tickets login (tickets ST2 session rotation)mre