summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2021-07-27 20:30:37 +0200
committerVivien Kraus <vivien@planete-kraus.eu>2021-07-29 18:43:54 +0200
commitabd22d93f6e61e0d62d340def3526931f042c910 (patch)
tree82153810936409f8e51ae722d96d0e845b2974d4 /src
parent8c89e88577dd2da79559f03a901339013da1e162 (diff)
The client manifest spec changed: now it’s a plain OIDC registration token.
Diffstat (limited to 'src')
-rw-r--r--src/scm/webid-oidc/client-manifest.scm62
-rw-r--r--src/scm/webid-oidc/client.scm12
2 files changed, 24 insertions, 50 deletions
diff --git a/src/scm/webid-oidc/client-manifest.scm b/src/scm/webid-oidc/client-manifest.scm
index 0515fdd..c4b49f0 100644
--- a/src/scm/webid-oidc/client-manifest.scm
+++ b/src/scm/webid-oidc/client-manifest.scm
@@ -82,54 +82,21 @@
(vector->list redirect-uris)
(uri->string redir)))))
-(define (turtle-escape str)
- (define (folder c other)
- (if (or (eq? c #\\) (eq? c #\"))
- (cons* c #\\ other)
- (cons c other)))
- (list->string (reverse (string-fold folder '() str))))
-
(define-public (serve-client-manifest expiration-date mf)
(when (eq? mf public-oidc-client)
(raise-cannot-serve-public-manifest))
- (let ((json-object (stubs:scm->json-string (the-client-manifest mf)))
- (id (uri->string (client-manifest-client-id (the-client-manifest mf)))))
- (let ((resource (string-append "
-@prefix solid: <http://www.w3.org/ns/solid/terms#> .
-
-<" id "> solid:oidcRegistration \"\"\"
-" (turtle-escape json-object) "
-\"\"\" .
-")))
- (values (build-response #:headers `((content-type text/turtle)
- (expires . ,expiration-date)))
- resource))))
-
-(define (find-registration id graph)
- (cond ((null? graph)
- (raise-no-client-manifest-registration (string->uri id)))
- ((and (string=? (rdf-triple-predicate (car graph))
- "http://www.w3.org/ns/solid/terms#oidcRegistration")
- (string? (rdf-triple-subject (car graph)))
- (string=? (rdf-triple-subject (car graph)) id)
- (rdf-literal? (rdf-triple-object (car graph)))
- (string=? (rdf-literal-type (rdf-triple-object (car graph)))
- "http://www.w3.org/2001/XMLSchema#string"))
- (let ((object (rdf-triple-object (car graph))))
- (let ((ret (stubs:json-string->scm (rdf-literal-lexical-form object))))
- (if (client-manifest? ret)
- (begin
- (unless (equal? (uri->string (client-manifest-client-id ret))
- id)
- (raise-inconsistent-client-manifest-id (string->uri id)
- (client-manifest-client-id ret)))
- ret)
- (find-registration id (cdr graph))))))
- (else (find-registration id (cdr graph)))))
+ (let ((json-object (stubs:scm->json-string
+ `((@context . "https://www.w3.org/ns/solid/oidc-context.jsonld")
+ ,@(the-client-manifest mf)))))
+ (values (build-response #:headers `((content-type application/ld+json)
+ (expires . ,expiration-date)))
+ json-object)))
(define*-public (get-client-manifest id
#:key
(http-get http-get))
+ (unless (uri? id)
+ (set! id (string->uri id)))
(with-exception-handler
(lambda (error)
(raise-cannot-fetch-client-manifest id error))
@@ -138,5 +105,14 @@
(string->uri
"http://www.w3.org/ns/solid/terms#PublicOidcClient"))
public-oidc-client
- (let ((graph (fetch id #:http-get http-get)))
- (find-registration (uri->string id) graph))))))
+ (receive (response response-body)
+ (http-get id)
+ (when (bytevector? response-body)
+ (set! response-body (utf8->string response-body)))
+ (let ((mf (the-client-manifest (stubs:json-string->scm response-body))))
+ (unless (equal? (uri->string (client-manifest-client-id mf))
+ (uri->string id))
+ (raise-inconsistent-client-manifest-id
+ id
+ (client-manifest-client-id mf)))
+ mf))))))
diff --git a/src/scm/webid-oidc/client.scm b/src/scm/webid-oidc/client.scm
index 30cbc75..83bca37 100644
--- a/src/scm/webid-oidc/client.scm
+++ b/src/scm/webid-oidc/client.scm
@@ -522,19 +522,17 @@
(set! client-uri (string->uri client-uri)))
(let* ((manifest
(format #f
- "@prefix solid: <http://www.w3.org/ns/solid/terms#> .
-
-<~a> solid:oidcRegistration \"\"\"{
+ "{
+ \"@context\": \"https://www.w3.org/ns/solid/oidc-context.jsonld\",
\"client_id\" : \"~a\",
\"redirect_uris\" : [\"~a\"],
\"client_name\" : \"~a\",
\"client_uri\" : \"~a\",
\"grant_types\" : [\"refresh_token\", \"authorization_code\"],
\"response_types\" : [\"code\"]
-}\"\"\" .
+}
"
(uri->string id)
- (uri->string id)
(uri->string redirect-uri)
client-name
(uri->string id)))
@@ -551,12 +549,12 @@
(build-response
#:code 304
#:reason-phrase "Not Modified"
- #:headers `((content-type text/turtle)
+ #:headers `((content-type application/ld+json)
(etag . (,manifest-etag . #t))))
#f)
(values
(build-response
- #:headers `((content-type text/turtle)
+ #:headers `((content-type application/ld+json)
(etag . (,manifest-etag . #t))
(cache-control public must-revalidate)))
manifest))))