gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitc50d17efc50d17efKeep function-route not-found style in shared stylesheetmrec50d17ef/components/sshkeys.hl

4.8 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. }
  107. Style {
  108. sshKeys {
  109. display = 'grid'
  110. gap = '.75rem'
  111. minWidth = '0'
  112. '> *' {
  113. margin = '0'
  114. }
  115. }
  116. #keyform {
  117. display = 'grid'
  118. gap = '.75rem'
  119. padding = '1rem'
  120. background = 'var(--color-surface)'
  121. borderRadius = 'var(--radius-large)'
  122. '> *' {
  123. margin = '0'
  124. }
  125. }
  126. #keylist {
  127. display = 'grid'
  128. gap = '.5rem'
  129. margin = '0'
  130. padding = '0'
  131. listStyle = 'none'
  132. li {
  133. display = 'flex'
  134. flexWrap = 'wrap'
  135. alignItems = 'center'
  136. gap = '.2rem 1rem'
  137. margin = '0'
  138. padding = '.4rem .5rem .4rem 1rem'
  139. background = 'var(--color-surface)'
  140. borderRadius = 'var(--radius-large)'
  141. }
  142. '.slug' {
  143. fontWeight = '700'
  144. marginRight = 'auto'
  145. overflowWrap = 'anywhere'
  146. }
  147. '.fingerprint' {
  148. overflowWrap = 'anywhere'
  149. color = 'var(--color-text-muted)'
  150. }
  151. }
  152. #keytext {
  153. font = '1rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace'
  154. }
  155. }

Branches

Latest commits

  • c50d17efKeep function-route not-found style in shared stylesheetmre
  • e42d78d3Preserve ticket state CSS and document function-route style gapmre
  • c6b7154eWIP gitoria#26: move styles into nested component blocksmre
  • 77a2c31cgitoria#31: plain declarations instead of needless let in lib/ and tools/ (103 let removed, 137 kept because reassigned); no other changemre
  • 4b98ab62gitoria: an ident access key (idt_) works as the git password; read key clones only, bad key 401, ident down 503 (ident#27); gate tests/ident-access-gitoria.mjs in deploy.shmre
  • 1185f686gitoria#36: a failed return from tickets shows a note on the settings page and leaves one log line per outcome; no code is exchangedmre
  • 5d2c385agitoria: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 71+5 failing → 76 passed; deploy.sh runs tests/private.mjs toomre
  • 241ef3f9deploy.sh: rebuild the sshd image before up -d (GO34c)mre
  • 821cdbb1gitoria#34b: styles, create-repo tool, docs, push/ssh gates sign in through the selector, shots scriptmre
  • a81abdc9gitoria#34: org page via function route, member-reachable orgs, selects, reportmre
  • 17f031f0gitoria#34: private repos, organizations, members, move tool, gatemre
  • 71b69343gitoria#23: the sidebar's Repositories link was a 404 after any in-page navigation (static menu re-evaluated publicUrl in the browser); the menu is an instance property now; gate taps it after a tab, folder, filemre
  • 90b4f728gitoria#25: restore the homepage cache and the parsed-blocks cache (they store data under immutable keys, no HTML); the page key, the framework readme key and the textHash key stay removedmre
  • a487248cgitoria#25: remove every cache that hid the page build (page key, Markdown render key, homepage cache, parsed-blocks cache) and the gate that only tested themmre
  • 12f2f4fegitoria: re-vendor Hybriel set-day27b, a startup fault in on Error exits 1mre
  • c21c084egitoria: write the standby service out in full so the boot gate can read the main servicemre
  • e307d69agitoria: say what is per process during the hand-overmre
  • 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