From 366cc89e8ccaf519d973c507b8534f5527141d84 Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Tue, 6 Jul 2021 13:11:14 +0200 Subject: Make sure that all dates in errors are actually dates and not timestamps --- src/scm/webid-oidc/errors.scm | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/scm/webid-oidc/errors.scm b/src/scm/webid-oidc/errors.scm index 1eb5a78..6cd337a 100644 --- a/src/scm/webid-oidc/errors.scm +++ b/src/scm/webid-oidc/errors.scm @@ -512,9 +512,16 @@ &external-error '(signed requested))) +(define (the-date object) + (when (integer? object) + (set! object (make-time time-utc 0 object))) + (when (time? object) + (set! object (time-utc->date object))) + object) + (define-public (raise-dpop-signed-in-future signed requested) (raise-exception - ((record-constructor &dpop-signed-in-future) signed requested))) + ((record-constructor &dpop-signed-in-future) (the-date signed) (the-date requested)))) (define-public &dpop-too-old (make-exception-type @@ -524,7 +531,7 @@ (define-public (raise-dpop-too-old signed requested) (raise-exception - ((record-constructor &dpop-too-old) signed requested))) + ((record-constructor &dpop-too-old) (the-date signed) (the-date requested)))) (define-public &dpop-unconfirmed-key (make-exception-type @@ -693,16 +700,10 @@ '(exp current-time))) (define-public (raise-authorization-code-expired exp current-time) - (when (integer? exp) - (set! exp (make-time time-utc 0 exp))) - (when (time? exp) - (set! exp (time-utc->date exp))) - (when (integer? current-time) - (set! current-time (make-time time-utc 0 current-time))) - (when (time? current-time) - (set! current-time (time-utc->date current-time))) - (raise-exception - ((record-constructor &authorization-code-expired) exp current-time))) + (raise-exception + ((record-constructor &authorization-code-expired) + (the-date exp) + (the-date current-time)))) (define-public &cannot-decode-authorization-code (make-exception-type -- cgit v1.2.3