mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
publish: Provide server's signing key.
* guix/scripts/publish.scm (render-signing-key): New procedure. (render-home-page): Add link to it. (make-request-handler): Handle it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
b35550c3d8
commit
6955cff962
2 changed files with 22 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2015 David Thompson <davet@gnu.org>
|
||||
;;; Copyright © 2020 by Amar M. Singh <nly@disroot.org>
|
||||
;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
|
@ -686,6 +687,13 @@ (define (response-headers file)
|
|||
(values (response-headers log) log)
|
||||
(not-found request))))
|
||||
|
||||
(define (render-signing-key)
|
||||
"Render signing key."
|
||||
(let ((file %public-key-file))
|
||||
(values `((content-type . (text/plain (charset . "UTF-8")))
|
||||
(x-raw-file . ,file))
|
||||
file)))
|
||||
|
||||
(define (render-home-page request)
|
||||
"Render the home page."
|
||||
(values `((content-type . (text/html (charset . "UTF-8"))))
|
||||
|
@ -699,7 +707,12 @@ (define (render-home-page request)
|
|||
(a (@ (href
|
||||
"https://guix.gnu.org/manual/en/html_node/Invoking-guix-publish.html"))
|
||||
(tt "guix publish"))
|
||||
" speaking. Welcome!")))
|
||||
" speaking. Welcome!")
|
||||
(p "Here is the "
|
||||
(a (@ (href
|
||||
"signing-key.pub"))
|
||||
(tt "signing key"))
|
||||
" for this server. Knock yourselves out!")))
|
||||
port)))))
|
||||
|
||||
(define (extract-narinfo-hash str)
|
||||
|
@ -918,6 +931,9 @@ (define nar-path?
|
|||
;; /
|
||||
((or () ("index.html"))
|
||||
(render-home-page request))
|
||||
;; guix signing-key
|
||||
(("signing-key.pub")
|
||||
(render-signing-key))
|
||||
;; /<hash>.narinfo
|
||||
(((= extract-narinfo-hash (? string? hash)))
|
||||
(if cache
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2015 David Thompson <davet@gnu.org>
|
||||
;;; Copyright © 2020 by Amar M. Singh <nly@disroot.org>
|
||||
;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
|
@ -613,6 +614,10 @@ (define %gzip-magic-bytes
|
|||
(let ((uri (publish-uri "/log/does-not-exist")))
|
||||
(response-code (http-get uri))))
|
||||
|
||||
(test-equal "/signing-key.pub"
|
||||
200
|
||||
(response-code (http-get (publish-uri "/signing-key.pub"))))
|
||||
|
||||
(test-equal "non-GET query"
|
||||
'(200 404)
|
||||
(let ((path (string-append "/" (store-path-hash-part %item)
|
||||
|
|
Loading…
Reference in a new issue