diff options
author | Vivien Kraus <vivien@planete-kraus.eu> | 2021-09-22 13:11:21 +0200 |
---|---|---|
committer | Vivien Kraus <vivien@planete-kraus.eu> | 2021-09-22 18:08:47 +0200 |
commit | 555e59deba33284067298ce6130c379c75e3d2a3 (patch) | |
tree | c15c823913e917bc474f1cf163caf65a117ee9c3 /src/scm/webid-oidc/client | |
parent | 0d74f8c1ca9c1e9bf9a04b85f598ba7a175d1d86 (diff) |
Use anonymous-http-request from (webid-oidc parameters) everywhere
Diffstat (limited to 'src/scm/webid-oidc/client')
-rw-r--r-- | src/scm/webid-oidc/client/accounts.scm | 15 | ||||
-rw-r--r-- | src/scm/webid-oidc/client/application.scm | 55 | ||||
-rw-r--r-- | src/scm/webid-oidc/client/client.scm | 1 | ||||
-rw-r--r-- | src/scm/webid-oidc/client/gui.scm | 1 |
4 files changed, 21 insertions, 51 deletions
diff --git a/src/scm/webid-oidc/client/accounts.scm b/src/scm/webid-oidc/client/accounts.scm index 7e14000..31d105d 100644 --- a/src/scm/webid-oidc/client/accounts.scm +++ b/src/scm/webid-oidc/client/accounts.scm @@ -37,14 +37,9 @@ #:use-module ((webid-oidc client client) #:prefix client:) #:use-module (web uri) #:use-module (web response) - #:use-module (web client) #:use-module (rnrs bytevectors) #:use-module (oop goops) #:declarative? #t - #:re-export - ( - (p:anonymous-http-request . anonymous-http-request) - ) #:export ( <account> @@ -132,13 +127,6 @@ (define authorization-state (make-parameter #f)) -(define (http-request->http-get http-request) - (lambda* (uri . all-args) - (apply http-request uri #:method 'GET all-args))) - -(define (http-get-implementation) - (http-request->http-get (p:anonymous-http-request))) - (define-class <account> () (subject #:init-keyword #:subject #:getter subject) (issuer #:init-keyword #:issuer #:getter issuer) @@ -371,8 +359,7 @@ decoding-error)))) (lambda () (set! id-token - (decode <id:id-token> id-token - #:http-request (p:anonymous-http-request))))) + (decode <id:id-token> id-token)))) ;; We are not interested in the ID token ;; signature anymore, because it won’t be ;; transmitted to other parties and we know that diff --git a/src/scm/webid-oidc/client/application.scm b/src/scm/webid-oidc/client/application.scm index 5839195..d448976 100644 --- a/src/scm/webid-oidc/client/application.scm +++ b/src/scm/webid-oidc/client/application.scm @@ -39,7 +39,6 @@ #:use-module (webid-oidc web-i18n) #:use-module (web uri) #:use-module (web response) - #:use-module (web client) #:use-module (rnrs bytevectors) #:use-module (oop goops) #:declarative? #t @@ -155,21 +154,6 @@ ((hd tl ...) (apply-finished-jobs (hd state) tl))))))) -(define http-request-with-cache - (let ((default-http-get-with-cache (cache:with-cache))) - (lambda* (uri . all-args) - (let try-get-with-cache ((args all-args) - (args-for-get '())) - (match args - (() - (apply default-http-get-with-cache uri (reverse args-for-get))) - ((#:headers arg other-args ...) - (try-get-with-cache other-args `(,arg #:headers ,@args-for-get))) - ((#:method 'GET other-args ...) - (try-get-with-cache other-args args-for-get)) - (else - (apply http-request uri all-args))))))) - (define-method (add-job (state <application-state>) (description <string>) f) (let ((job (make <job> #:description description))) (call-with-new-thread @@ -197,25 +181,26 @@ (slot-set! ret 'authorization-prompts `((,uri . ,continue) ,@(authorization-prompts previous-state))) - ret)))))) - (account:anonymous-http-request http-request-with-cache)) - (with-exception-handler - (lambda (exn) - (let ((msg (if (exception-with-message? exn) - (exception-message exn) - (format #f "~s" exn)))) - (abort-to-prompt - tag - (lambda (_) - ;; We won’t continue, but we will show the error message - (lambda (previous-state) - (let ((ret (shallow-clone previous-state))) - (slot-set! ret 'error-messages - `(,msg ,@(error-messages previous-state))) - ret)))))) - (lambda () - (let ((updater (f))) - (atomic-box-set! (result-box job) updater)))))) + ret))))))) + (cache:use-cache + (lambda () + (with-exception-handler + (lambda (exn) + (let ((msg (if (exception-with-message? exn) + (exception-message exn) + (format #f "~s" exn)))) + (abort-to-prompt + tag + (lambda (_) + ;; We won’t continue, but we will show the error message + (lambda (previous-state) + (let ((ret (shallow-clone previous-state))) + (slot-set! ret 'error-messages + `(,msg ,@(error-messages previous-state))) + ret)))))) + (lambda () + (let ((updater (f))) + (atomic-box-set! (result-box job) updater)))))))) (lambda (continuation get-updater) (atomic-box-set! (result-box job) (get-updater continuation))))))) (let ((ret (shallow-clone state))) diff --git a/src/scm/webid-oidc/client/client.scm b/src/scm/webid-oidc/client/client.scm index 01f8da1..3d02630 100644 --- a/src/scm/webid-oidc/client/client.scm +++ b/src/scm/webid-oidc/client/client.scm @@ -26,7 +26,6 @@ #:use-module ((webid-oidc config) #:prefix cfg:) #:use-module ((webid-oidc client accounts) #:prefix client:) #:use-module (web uri) - #:use-module (web client) #:use-module (web request) #:use-module (web response) #:use-module (web server) diff --git a/src/scm/webid-oidc/client/gui.scm b/src/scm/webid-oidc/client/gui.scm index c0d0767..97e9d0e 100644 --- a/src/scm/webid-oidc/client/gui.scm +++ b/src/scm/webid-oidc/client/gui.scm @@ -36,7 +36,6 @@ #:use-module ((webid-oidc client client) #:prefix client:) #:use-module (web uri) #:use-module (web response) - #:use-module (web client) #:use-module (rnrs bytevectors) #:use-module (oop goops) #:declarative? #t |