aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/client-communication.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2021-02-28 18:41:07 +0000
committerChristopher Baines <mail@cbaines.net>2021-02-28 18:41:07 +0000
commit1f79fc38a17ceda30f378efd4e7f80f252c99b4d (patch)
treee5cf6166d69b3f7249d4006846751bf1fb6e5720 /guix-build-coordinator/client-communication.scm
parentcaf63dce0ea29a07c5205a69ff6f60b7c6b60084 (diff)
downloadbuild-coordinator-1f79fc38a17ceda30f378efd4e7f80f252c99b4d.tar
build-coordinator-1f79fc38a17ceda30f378efd4e7f80f252c99b4d.tar.gz
Add a new dynamic authentication approach
This avoids the need to create agents upfront, which could be useful when creating many childhurd VMs or using scheduling tools to dynamically run agents.
Diffstat (limited to 'guix-build-coordinator/client-communication.scm')
-rw-r--r--guix-build-coordinator/client-communication.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/guix-build-coordinator/client-communication.scm b/guix-build-coordinator/client-communication.scm
index 550b054..664b9aa 100644
--- a/guix-build-coordinator/client-communication.scm
+++ b/guix-build-coordinator/client-communication.scm
@@ -29,6 +29,7 @@
#:use-module (rnrs bytevectors)
#:use-module (json)
#:use-module (logging logger)
+ #:use-module (gcrypt random)
#:use-module (web uri)
#:use-module (web client)
#:use-module (web request)
@@ -52,6 +53,7 @@
request-failed-builds-with-blocking-count-list
send-create-agent-request
send-create-agent-password-request
+ send-create-dynamic-auth-token-request
send-replace-agent-tags-request))
(define (start-client-request-server secret-key-base
@@ -217,6 +219,11 @@
#:description (assoc-ref body "description"))))
(render-json
`((agent-id . ,uuid)))))
+ (('POST "dynamic-auth-tokens")
+ (let ((token (random-token)))
+ (datastore-insert-dynamic-auth-token datastore token)
+ (render-json
+ `((token . ,token)))))
(('GET "agent" agent-id)
(let ((agent-details (datastore-find-agent datastore agent-id)))
(render-json
@@ -631,6 +638,11 @@
'POST
(string-append "/agent/" agent-id "/passwords")))
+(define (send-create-dynamic-auth-token-request coordinator-uri)
+ (send-request coordinator-uri
+ 'POST
+ "/dynamic-auth-tokens"))
+
(define (send-replace-agent-tags-request coordinator-uri
agent-id
tags)