From df601c07b7d643f1dd8fdc2615e795b3f3ea1b3b Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Fri, 2 Jul 2021 10:47:58 +0200 Subject: Set up content negociation To add support for new conversion strategies, edit serve.scm and fetch.scm. --- doc/webid-oidc.texi | 33 ++++ po/fr.po | 292 +++++++++++++++++---------------- po/webid-oidc.pot | 287 ++++++++++++++++---------------- src/scm/webid-oidc/Makefile.am | 2 + src/scm/webid-oidc/errors.scm | 21 +++ src/scm/webid-oidc/resource-server.scm | 145 +++++++++------- src/scm/webid-oidc/serve.scm | 73 +++++++++ 7 files changed, 510 insertions(+), 343 deletions(-) create mode 100644 src/scm/webid-oidc/serve.scm diff --git a/doc/webid-oidc.texi b/doc/webid-oidc.texi index ba23010..a6852a8 100644 --- a/doc/webid-oidc.texi +++ b/doc/webid-oidc.texi @@ -49,6 +49,7 @@ Free Documentation License'' * Decentralized Authentication on the Web:: * The Json Web Token:: * Caching on server side:: +* Content negociation:: * Running an Identity Provider:: * Running a Resource Server:: * Running a client:: @@ -369,6 +370,32 @@ The back-end function, @var{http-get}, defaults to that of @emph{(web client)}. @end deffn +@node Content negociation +@chapter Content negociation +There are a number of different available syntaxes for RDF, some being +simple and human readable like @emph{turtle}, and others more adapted +to the JavaScript ecosystem like @emph{json-ld}. To help clients both +from and outside of the JS ecosystem, the server needs to perform +@dfn{content negociation}, i.e. convert from one content-type to +another. + +@deffn {function from @code{(webid-oidc serve)}} convert @var{client-accepts} @var{server-name} @var{path} @var{content-type} @var{content} +Convert the resource representation under @var{path} on +@var{server-name}, which has a given @var{content-type} and +@var{content}, to a content-type that the @var{client accepts}. + +Return 2 values: +@enumerate +@item +the accepted content-type; +@item +the content in the given content-type. +@end enumerate + +Currently, the only conversions are from and to @emph{Turtle} and +@emph{N-Quads}. +@end deffn + @node Running an Identity Provider @chapter Running an Identity Provider @@ -1302,6 +1329,12 @@ If the resource does not exist, @var{real-etag} is set to @code{#f}. In this case, an exception of type @code{&path-not-found} is also thrown. @end deftp + +@deftp {exception type} ¬-acceptable @var{client-accepts} @var{path} @var{content-type} +The client wanted a response with a specific set of +@var{client-accept}ed content-types, but the real @var{content-type} +of the resource under @var{path} cannot be converted to one of them. +@end deftp @node GNU Free Documentation License @appendix GNU Free Documentation License diff --git a/po/fr.po b/po/fr.po index 2c28f4a..142caf2 100644 --- a/po/fr.po +++ b/po/fr.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: webid-oidc 0.0.0\n" "Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n" -"POT-Creation-Date: 2021-07-01 16:40+0200\n" -"PO-Revision-Date: 2021-07-01 16:40+0200\n" +"POT-Creation-Date: 2021-07-02 10:57+0200\n" +"PO-Revision-Date: 2021-07-02 10:59+0200\n" "Last-Translator: Vivien Kraus \n" "Language-Team: French \n" "Language: fr\n" @@ -126,101 +126,101 @@ msgstr "Utilisation : generate-random [NOMBRE D'OCTETS]\n" msgid "Usage: generate-key [NUMBER OF BITS | CURVE]\n" msgstr "Utilisation : generate-key [NOMBRE DE BITS | COURBE]\n" -#: src/scm/webid-oidc/errors.scm:1047 +#: src/scm/webid-oidc/errors.scm:1063 msgid "that’s how it is" msgstr "c’est comme ça" -#: src/scm/webid-oidc/errors.scm:1052 +#: src/scm/webid-oidc/errors.scm:1068 #, scheme-format msgid "the value ~s is not a base64 string (because ~a)" msgstr "la valeur ~s n’est pas une chaîne base64 (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1055 +#: src/scm/webid-oidc/errors.scm:1071 #, scheme-format msgid "the value ~s is not JSON (because ~a)" msgstr "la valeur ~s n’est pas du JSON (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1058 +#: src/scm/webid-oidc/errors.scm:1074 #, scheme-format msgid "the value ~s is not Turtle (because ~a)" msgstr "la valeur ~s n’est pas du Turtle (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1061 +#: src/scm/webid-oidc/errors.scm:1077 #, scheme-format msgid "the value ~s does not identify an elleptic curve" msgstr "la valeur ~s n’identifie pas une courbe elliptique" -#: src/scm/webid-oidc/errors.scm:1066 +#: src/scm/webid-oidc/errors.scm:1082 #, scheme-format msgid "the value ~s does not identify a JWK (because ~a)" msgstr "la valeur ~s n’identifie pas une JWK (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1068 +#: src/scm/webid-oidc/errors.scm:1084 #, scheme-format msgid "the value ~s does not identify a JWK" msgstr "la valeur ~s n’identifie pas une JWK" -#: src/scm/webid-oidc/errors.scm:1073 +#: src/scm/webid-oidc/errors.scm:1089 #, scheme-format msgid "the value ~s does not identify a public JWK (because ~a)" msgstr "la valeur ~s n’identifie pas une JWK publique (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1075 +#: src/scm/webid-oidc/errors.scm:1091 #, scheme-format msgid "the value ~s does not identify a public JWK" msgstr "la valeur ~s n’identifie pas une JWK publique" -#: src/scm/webid-oidc/errors.scm:1080 +#: src/scm/webid-oidc/errors.scm:1096 #, scheme-format msgid "the value ~s does not identify a private JWK (because ~a)" msgstr "la valeur ~s n’identifie pas une JWK privée (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1082 +#: src/scm/webid-oidc/errors.scm:1098 #, scheme-format msgid "the value ~s does not identify a private JWK" msgstr "la valeur ~s n’identifie pas une JWK privée" -#: src/scm/webid-oidc/errors.scm:1087 +#: src/scm/webid-oidc/errors.scm:1103 #, scheme-format msgid "the value ~s does not identify a JWKS (because ~a)" msgstr "la valeur ~s n’identifie pas un JWKS (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1089 +#: src/scm/webid-oidc/errors.scm:1105 #, scheme-format msgid "the value ~s does not identify a JWKS" msgstr "la valeur ~s n’identifie pas un JWKS" -#: src/scm/webid-oidc/errors.scm:1092 +#: src/scm/webid-oidc/errors.scm:1108 #, scheme-format msgid "the value ~s does not identify a hash algorithm" msgstr "la valeur ~s n’identifie pas un algorithme de hachage" -#: src/scm/webid-oidc/errors.scm:1095 +#: src/scm/webid-oidc/errors.scm:1111 #, scheme-format msgid "the value ~s is not an alist or misses key ~s" msgstr "la valeur ~s n’est pas une alist ou il manque la clé ~s" -#: src/scm/webid-oidc/errors.scm:1098 +#: src/scm/webid-oidc/errors.scm:1114 #, scheme-format msgid "the value ~s is not a JWS header (because ~a)" msgstr "la valeur ~s n’est pas un header JWS (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1101 +#: src/scm/webid-oidc/errors.scm:1117 #, scheme-format msgid "the value ~s is not a JWS payload (because ~a)" msgstr "la valeur ~s n’est pas un contenu JWS (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1104 +#: src/scm/webid-oidc/errors.scm:1120 #, scheme-format msgid "the value ~s is not a JWS (because ~a)" msgstr "la valeur ~s n’est pas un JWS (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1107 +#: src/scm/webid-oidc/errors.scm:1123 #, scheme-format msgid "the string ~s cannot be split in 3 parts with ~s" msgstr "la chaîne ~s ne peut pas être découpée en 3 parties avec ~s" -#: src/scm/webid-oidc/errors.scm:1110 +#: src/scm/webid-oidc/errors.scm:1126 #, scheme-format msgid "" "all key candidates failed to verify signature ~s with algorithm ~s and " @@ -229,17 +229,17 @@ msgstr "" "aucune clé candidate n’a pu vérifier la signature ~s avec l’algorithme ~s et " "le contenu ~a (il y en avait ~a : ~s)" -#: src/scm/webid-oidc/errors.scm:1113 +#: src/scm/webid-oidc/errors.scm:1129 #, scheme-format msgid "I cannot decode JWS ~a (because ~a)" msgstr "je n’ai pas pu décoder le JWS encodé par ~a (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1116 +#: src/scm/webid-oidc/errors.scm:1132 #, scheme-format msgid "I cannot encode JWS ~a (because ~a)" msgstr "je n’ai pas pu encoder le JWS ~a (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1119 +#: src/scm/webid-oidc/errors.scm:1135 #, scheme-format msgid "" "the server request unexpectedly failed with code ~a and reason phrase ~s" @@ -247,338 +247,338 @@ msgstr "" "la requête au serveur a échoué de façon inattendue avec un code ~a et une " "raison ~s" -#: src/scm/webid-oidc/errors.scm:1124 +#: src/scm/webid-oidc/errors.scm:1140 #, scheme-format msgid "the header ~a should not have the value ~s" msgstr "l’en-tête ~a ne devrait pas avoir la valeur ~s" -#: src/scm/webid-oidc/errors.scm:1126 +#: src/scm/webid-oidc/errors.scm:1142 #, scheme-format msgid "the header ~a should be present" msgstr "l’en-tête ~a devrait être présent" -#: src/scm/webid-oidc/errors.scm:1129 +#: src/scm/webid-oidc/errors.scm:1145 #, scheme-format msgid "the server response wasn't expected: ~s (because ~a)" msgstr "la réponse du serveur est inattendue : ~s (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1135 +#: src/scm/webid-oidc/errors.scm:1151 #, scheme-format msgid "the value ~s is not an OIDC configuration (because ~a)" msgstr "la valeur ~s n’est pas une configuration OIDC (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1140 +#: src/scm/webid-oidc/errors.scm:1156 #, scheme-format msgid "the webid field is incorrect: ~s" msgstr "le champ webid est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1141 +#: src/scm/webid-oidc/errors.scm:1157 msgid "the webid field is missing" msgstr "le champ webid est manquant" -#: src/scm/webid-oidc/errors.scm:1145 +#: src/scm/webid-oidc/errors.scm:1161 #, scheme-format msgid "the sub field is incorrect: ~s" msgstr "le champ sub est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1146 +#: src/scm/webid-oidc/errors.scm:1162 msgid "the sub field is missing" msgstr "le champ sub est manquant" -#: src/scm/webid-oidc/errors.scm:1150 +#: src/scm/webid-oidc/errors.scm:1166 #, scheme-format msgid "the iss field is incorrect: ~s" msgstr "le champ iss est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1151 +#: src/scm/webid-oidc/errors.scm:1167 msgid "the iss field is missing" msgstr "le champ iss est manquant" -#: src/scm/webid-oidc/errors.scm:1155 +#: src/scm/webid-oidc/errors.scm:1171 #, scheme-format msgid "the aud field is incorrect: ~s" msgstr "le champ aud est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1156 +#: src/scm/webid-oidc/errors.scm:1172 msgid "the aud field is missing" msgstr "le champ aud est manquant" -#: src/scm/webid-oidc/errors.scm:1160 +#: src/scm/webid-oidc/errors.scm:1176 #, scheme-format msgid "the iat field is incorrect: ~s" msgstr "le champ iat est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1161 +#: src/scm/webid-oidc/errors.scm:1177 msgid "the iat field is missing" msgstr "le champ iat est manquant" -#: src/scm/webid-oidc/errors.scm:1165 +#: src/scm/webid-oidc/errors.scm:1181 #, scheme-format msgid "the exp field is incorrect: ~s" msgstr "le champ exp est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1166 +#: src/scm/webid-oidc/errors.scm:1182 msgid "the exp field is missing" msgstr "le champ exp est manquant" -#: src/scm/webid-oidc/errors.scm:1170 +#: src/scm/webid-oidc/errors.scm:1186 #, scheme-format msgid "the cnf/jkt field is incorrect: ~s" msgstr "le champ cnf/jkt est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1171 +#: src/scm/webid-oidc/errors.scm:1187 msgid "the cnf/jkt field is missing" msgstr "le champ cnf/jkt est manquant" -#: src/scm/webid-oidc/errors.scm:1175 +#: src/scm/webid-oidc/errors.scm:1191 #, scheme-format msgid "the client-id field is incorrect: ~s" msgstr "le champ client-id est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1176 +#: src/scm/webid-oidc/errors.scm:1192 msgid "the client-id field is missing" msgstr "le champ client-id est manquant" -#: src/scm/webid-oidc/errors.scm:1180 +#: src/scm/webid-oidc/errors.scm:1196 #: src/scm/webid-oidc/authorization-page-unsafe.scm:149 #, scheme-format msgid "the redirect_uris field is incorrect: ~s" msgstr "le champ redirect_uris est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1181 +#: src/scm/webid-oidc/errors.scm:1197 #: src/scm/webid-oidc/authorization-page-unsafe.scm:150 msgid "the redirect_uris field is missing" msgstr "le champ redirect_uris est manquant" -#: src/scm/webid-oidc/errors.scm:1185 +#: src/scm/webid-oidc/errors.scm:1201 #, scheme-format msgid "the typ field is incorrect: ~s" msgstr "le champ typ est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1186 +#: src/scm/webid-oidc/errors.scm:1202 msgid "the typ field is missing" msgstr "le champ typ est manquant" -#: src/scm/webid-oidc/errors.scm:1190 +#: src/scm/webid-oidc/errors.scm:1206 #, scheme-format msgid "the jwk field is incorrect: ~s (because ~a)" msgstr "le champ jwk est incorrect : ~s (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1192 +#: src/scm/webid-oidc/errors.scm:1208 msgid "the jwk field is missing" msgstr "le champ jwk est manquant" -#: src/scm/webid-oidc/errors.scm:1196 +#: src/scm/webid-oidc/errors.scm:1212 #, scheme-format msgid "the jti field is incorrect: ~s" msgstr "le champ jti est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1197 +#: src/scm/webid-oidc/errors.scm:1213 msgid "the jti field is missing" msgstr "le champ jti est manquant" -#: src/scm/webid-oidc/errors.scm:1201 +#: src/scm/webid-oidc/errors.scm:1217 #, scheme-format msgid "the nonce field is incorrect: ~s" msgstr "le champ nonce est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1202 +#: src/scm/webid-oidc/errors.scm:1218 msgid "the nonce field is missing" msgstr "le champ nonce est manquant" -#: src/scm/webid-oidc/errors.scm:1206 +#: src/scm/webid-oidc/errors.scm:1222 #, scheme-format msgid "the htm field is incorrect: ~s" msgstr "le champ htm est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1207 +#: src/scm/webid-oidc/errors.scm:1223 msgid "the htm field is missing" msgstr "le champ htm est manquant" -#: src/scm/webid-oidc/errors.scm:1211 +#: src/scm/webid-oidc/errors.scm:1227 #, scheme-format msgid "the htu field is incorrect: ~s" msgstr "le champ htu est incorrect : ~s" -#: src/scm/webid-oidc/errors.scm:1212 +#: src/scm/webid-oidc/errors.scm:1228 msgid "the htu field is missing" msgstr "le champ htu est manquant" -#: src/scm/webid-oidc/errors.scm:1214 +#: src/scm/webid-oidc/errors.scm:1230 #, scheme-format msgid "~s is not an access token (because ~a)" msgstr "~s n’est pas un jeton d’accès (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1217 +#: src/scm/webid-oidc/errors.scm:1233 #, scheme-format msgid "~s is not an access token header (because ~a)" msgstr "~s n’est pas un en-tête de jeton d’accès (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1220 +#: src/scm/webid-oidc/errors.scm:1236 #, scheme-format msgid "~s is not an access token payload (because ~a)" msgstr "~s n’est pas un contenu de jeton d’accès (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1223 +#: src/scm/webid-oidc/errors.scm:1239 #, scheme-format msgid "~s is not a DPoP proof (because ~a)" msgstr "~s n’est pas une preuve DPoP (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1226 +#: src/scm/webid-oidc/errors.scm:1242 #, scheme-format msgid "~s is not a DPoP proof header (because ~a)" msgstr "~s n’est pas un en-tête de preuve DPoP (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1229 +#: src/scm/webid-oidc/errors.scm:1245 #, scheme-format msgid "~s is not a DPoP proof payload (because ~a)" msgstr "~s n’est pas un contenu de preuve DPoP (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1232 +#: src/scm/webid-oidc/errors.scm:1248 #, scheme-format msgid "I cannot fetch the issuer configuration of ~a (because ~a)" msgstr "" "je n’ai pas pu récupérer la configuration de l’émetteur ~a (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1239 +#: src/scm/webid-oidc/errors.scm:1255 #, scheme-format msgid "I cannot fetch the JWKS of ~a at ~a (because ~a)" msgstr "je n’ai pas pu récupérer le JWKS de ~a à ~a (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1250 +#: src/scm/webid-oidc/errors.scm:1266 #, scheme-format msgid "the HTTP method is signed for ~s, but ~s was requested" msgstr "la méthode HTTP a été signée pour ~s, mais ~s a été demandé" -#: src/scm/webid-oidc/errors.scm:1253 +#: src/scm/webid-oidc/errors.scm:1269 #, scheme-format msgid "the HTTP uri is signed for ~a, but ~a was requested" msgstr "l’uri HTTP a été signé pour ~a, mais ~a a été demandé" -#: src/scm/webid-oidc/errors.scm:1256 +#: src/scm/webid-oidc/errors.scm:1272 #, scheme-format msgid "the date is ~a, but the DPoP proof is signed in the future at ~a" msgstr "la date est ~a, mais la preuve DPoP a été signée dans le futur à ~a" -#: src/scm/webid-oidc/errors.scm:1260 +#: src/scm/webid-oidc/errors.scm:1276 #, scheme-format msgid "the date is ~a, but the DPoP proof was signed too long ago at ~a" msgstr "" "la date est ~a, mais la preuve DPoP a été signée il y a trop longtemps à ~a" -#: src/scm/webid-oidc/errors.scm:1269 +#: src/scm/webid-oidc/errors.scm:1285 #, scheme-format msgid "the key ~s does not hash to ~a" msgstr "la clé ~s ne donne pas un hash de ~a" -#: src/scm/webid-oidc/errors.scm:1271 +#: src/scm/webid-oidc/errors.scm:1287 #, scheme-format msgid "the key confirmation of ~s failed (because ~a)" msgstr "la confirmation de clé de ~s a échoué (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1273 +#: src/scm/webid-oidc/errors.scm:1289 #, scheme-format msgid "the key confirmation of ~s failed" msgstr "la confirmation de la clé ~s a échoué" -#: src/scm/webid-oidc/errors.scm:1275 +#: src/scm/webid-oidc/errors.scm:1291 #, scheme-format msgid "the jti ~s has already been found (because ~a)" msgstr "le jti ~s a déjà été trouvé (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1278 +#: src/scm/webid-oidc/errors.scm:1294 #, scheme-format msgid "I cannot decode ~s as an access token (because ~a)" msgstr "je n’ai pas pu décoder ~s comme jeton d’accès (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1281 +#: src/scm/webid-oidc/errors.scm:1297 #, scheme-format msgid "I cannot encode ~s as an access token with key ~s (because ~a)" msgstr "" "je n’ai pas pu encoder ~s comme un jeton d’accès avec la clé ~s (parce que " "~a)" -#: src/scm/webid-oidc/errors.scm:1284 +#: src/scm/webid-oidc/errors.scm:1300 #, scheme-format msgid "I cannot decode ~s as a DPoP proof (because ~a)" msgstr "je n’ai pas pu décoder ~s comme preuve DPoP (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1287 +#: src/scm/webid-oidc/errors.scm:1303 #, scheme-format msgid "I cannot encode ~s as a DPoP proof (because ~a)" msgstr "je n’ai pas pu encoder ~s comme une preuve DPoP (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1290 +#: src/scm/webid-oidc/errors.scm:1306 #, scheme-format msgid "I could not fetch a RDF graph at ~a (because ~a)" msgstr "je n’ai pas pu récupérer de graphe RDF à ~a (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1293 +#: src/scm/webid-oidc/errors.scm:1309 #, scheme-format msgid "~s is not a client manifest (because ~a)" msgstr "~s n’est pas un manifeste client (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1296 +#: src/scm/webid-oidc/errors.scm:1312 #, scheme-format msgid "~s does not authorize redirection URI ~a" msgstr "~s n’autorise pas l’URI de redirection ~a" -#: src/scm/webid-oidc/errors.scm:1299 +#: src/scm/webid-oidc/errors.scm:1315 msgid "I cannot serve a public manifest" msgstr "je ne peux pas servir un manifeste public" -#: src/scm/webid-oidc/errors.scm:1301 +#: src/scm/webid-oidc/errors.scm:1317 #, scheme-format msgid "~a does not have a client manifest registration triple" msgstr "~a n’a pas de triplet d’enregistrement de manifeste client" -#: src/scm/webid-oidc/errors.scm:1304 +#: src/scm/webid-oidc/errors.scm:1320 #, scheme-format msgid "the client manifest at ~a is advertised for ~a" msgstr "le manifeste client ~a est publié pour ~a" -#: src/scm/webid-oidc/errors.scm:1307 +#: src/scm/webid-oidc/errors.scm:1323 #, scheme-format msgid "I could not fetch the client manifest of ~a (because ~a)" msgstr "je n’ai pas pu récupérer le manifeste client de ~a (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1310 +#: src/scm/webid-oidc/errors.scm:1326 #, scheme-format msgid "~s is not an authorization code (because ~a)" msgstr "~s n’est pas un code d’autorisation (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1313 +#: src/scm/webid-oidc/errors.scm:1329 #, scheme-format msgid "~s is not an authorization code header (because ~a)" msgstr "~s n’est pas un en-tête de code d’autorisation (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1316 +#: src/scm/webid-oidc/errors.scm:1332 #, scheme-format msgid "~s is not an authorization code payload (because ~a)" msgstr "~s n’est pas un contenu de code d’autorisation (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1319 +#: src/scm/webid-oidc/errors.scm:1335 #, scheme-format msgid "the current time is ~a, and the authorization code expired at ~a" msgstr "" "la date est actuellement ~a, et le code d’autorisation a expiré à la date ~a" -#: src/scm/webid-oidc/errors.scm:1323 +#: src/scm/webid-oidc/errors.scm:1339 #, scheme-format msgid "I cannot decode ~s as an authorization code (because ~a)" msgstr "je n’ai pas pu décoder ~s comme un code d’autorisation (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1326 +#: src/scm/webid-oidc/errors.scm:1342 #, scheme-format msgid "I cannot encode ~s as an authorization code (because ~a)" msgstr "je n’ai pas pu encoder ~s comme un code d’autorisation (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1329 +#: src/scm/webid-oidc/errors.scm:1345 #, scheme-format msgid "there is no such refresh token as ~s" msgstr "il n’y a pas de jeton de rafraîchissement ~s" -#: src/scm/webid-oidc/errors.scm:1332 +#: src/scm/webid-oidc/errors.scm:1348 #, scheme-format msgid "" "the refresh token is bound to a key confirmed as ~s, but it is used with key " @@ -587,45 +587,45 @@ msgstr "" "Le jeton de rafraîchissement est lié à une clé confirmée par ~s, mais il est " "utilisé avec la clé ~s" -#: src/scm/webid-oidc/errors.scm:1335 +#: src/scm/webid-oidc/errors.scm:1351 #, scheme-format msgid "I cannot decode ~s as an ID token (because ~a)" msgstr "je n’ai pas pu décoder ~s comme jeton d’identité (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1338 +#: src/scm/webid-oidc/errors.scm:1354 #, scheme-format msgid "I cannot encode ~s as an ID token (because ~a)" msgstr "je n’ai pas pu encoder ~s comme un jeton d’identité (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1341 +#: src/scm/webid-oidc/errors.scm:1357 #, scheme-format msgid "the grant type ~s is not supported" msgstr "le type d’octroi ~s n’est pas supporté " -#: src/scm/webid-oidc/errors.scm:1344 +#: src/scm/webid-oidc/errors.scm:1360 msgid "there is no authorization code in the request" msgstr "il n’y a pas de code d’autorisation dans la requête" -#: src/scm/webid-oidc/errors.scm:1346 +#: src/scm/webid-oidc/errors.scm:1362 msgid "there is no refresh token in the request" msgstr "il n’y a pas de jeton de rafraîchissement dans la requête" -#: src/scm/webid-oidc/errors.scm:1348 +#: src/scm/webid-oidc/errors.scm:1364 #, scheme-format msgid "~s is not an ID token (because ~a)" msgstr "~s n’est pas un jeton d’identité (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1351 +#: src/scm/webid-oidc/errors.scm:1367 #, scheme-format msgid "~s is not an ID token header (because ~a)" msgstr "~s n’est pas un en-tête de jeton d’identité (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1354 +#: src/scm/webid-oidc/errors.scm:1370 #, scheme-format msgid "~s is not an ID token payload (because ~a)" msgstr "~s n’est pas un contenu de jeton d’identité (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1357 +#: src/scm/webid-oidc/errors.scm:1373 #, scheme-format msgid "" "I couldn’t set the locale to ~s as an approximation of the client locale ~s" @@ -633,12 +633,12 @@ msgstr "" "je n’ai pas pu définir la locale à ~s comme approximation de la locale du " "client ~s" -#: src/scm/webid-oidc/errors.scm:1360 +#: src/scm/webid-oidc/errors.scm:1376 #, scheme-format msgid "~s does not admit ~s as an identity provider" msgstr "~s n’admet pas ~s comme fournisseur d’identité" -#: src/scm/webid-oidc/errors.scm:1363 +#: src/scm/webid-oidc/errors.scm:1379 #, scheme-format msgid "" "~a is neither an identity provider (because ~a) nor a webid (because ~a)" @@ -646,76 +646,76 @@ msgstr "" "~a n’est ni un fournisseur d’identité (parce que ~a) ni un webid (parce que " "~a)" -#: src/scm/webid-oidc/errors.scm:1368 +#: src/scm/webid-oidc/errors.scm:1384 #, scheme-format msgid "the token request failed (because ~a)" msgstr "la requête de jeton a échoué (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1371 +#: src/scm/webid-oidc/errors.scm:1387 #, scheme-format msgid "you don’t have a refresh token for identity ~a certified by ~a in ~s" msgstr "" "vous n’avez pas de jeton de rafraîchissement pour l’identité ~a certifié par " "~a dans ~s" -#: src/scm/webid-oidc/errors.scm:1376 +#: src/scm/webid-oidc/errors.scm:1392 #, scheme-format msgid "all identity provider candidates for ~a failed: ~a" msgstr "tous les candidats de fournisseurs d’identité pour ~a ont échoué : ~a" -#: src/scm/webid-oidc/errors.scm:1380 +#: src/scm/webid-oidc/errors.scm:1396 #, scheme-format msgid "~s failed (because ~a)" msgstr "~s a échoué (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1383 +#: src/scm/webid-oidc/errors.scm:1399 msgid ", " msgstr ", " -#: src/scm/webid-oidc/errors.scm:1385 +#: src/scm/webid-oidc/errors.scm:1401 #, scheme-format msgid "no resource has been found to serve URI path ~s" msgstr "aucune ressource n’a été trouvée pour servir le chemin d’URI ~s" -#: src/scm/webid-oidc/errors.scm:1388 +#: src/scm/webid-oidc/errors.scm:1404 #, scheme-format msgid "the resource kind ~s is absent for the resource at ~s" msgstr "le type de ressource ~s est absent pour la ressource ~s" -#: src/scm/webid-oidc/errors.scm:1391 +#: src/scm/webid-oidc/errors.scm:1407 #, scheme-format msgid "no resource has been found to serve URI path ~s, but ~s exists" msgstr "" "aucune ressource n’a été trouvée pour servir le chemin d’URI ~s, mais ~s " "existe" -#: src/scm/webid-oidc/errors.scm:1394 +#: src/scm/webid-oidc/errors.scm:1410 msgid "the root storage cannot be deleted" msgstr "le stockage racine ne peut pas être détruit" -#: src/scm/webid-oidc/errors.scm:1396 +#: src/scm/webid-oidc/errors.scm:1412 #, scheme-format msgid "the container ~s should be emptied before being deleted" msgstr "le conteneur ~s doit être vidé avant d’être détruit" -#: src/scm/webid-oidc/errors.scm:1399 +#: src/scm/webid-oidc/errors.scm:1415 #, scheme-format msgid "the group ~s cannot be fetched (because ~a)" msgstr "le groupe ~s n’a pas pu être récupéré (parce que ~a)" -#: src/scm/webid-oidc/errors.scm:1403 +#: src/scm/webid-oidc/errors.scm:1419 #, scheme-format msgid "the containment triples in the request to update ~s are not up to date" msgstr "" "les triplets de contention dans la requête pour changer ~s ne sont pas à jour" -#: src/scm/webid-oidc/errors.scm:1406 +#: src/scm/webid-oidc/errors.scm:1422 #, scheme-format msgid "the server cannot process resources with the ~s content-type" msgstr "" "le serveur ne peut pas traiter des ressources avec le type de contenu ~s" -#: src/scm/webid-oidc/errors.scm:1409 +#: src/scm/webid-oidc/errors.scm:1425 #, scheme-format msgid "" "the client wants to create a resource at ~s, which is reserved for an " @@ -724,7 +724,7 @@ msgstr "" "le client veut créer une ressource en tant que ~s, qui est réservé pour une " "ressource auxiliare" -#: src/scm/webid-oidc/errors.scm:1412 +#: src/scm/webid-oidc/errors.scm:1428 #, scheme-format msgid "" "the operation on ~s by ~a is refused, because it’s not by ~s and the access " @@ -733,11 +733,11 @@ msgstr "" "l’opération sur ~s par ~a est refusée, parce que ce n’est pas ~s et le " "contrôle d’accès refuse le mode d’opération suivant : ~s" -#: src/scm/webid-oidc/errors.scm:1416 +#: src/scm/webid-oidc/errors.scm:1432 msgid "an anonymous user" msgstr "un utilisateur anonyme" -#: src/scm/webid-oidc/errors.scm:1421 +#: src/scm/webid-oidc/errors.scm:1437 #, scheme-format msgid "" "the client precondition failed for ~s: it allows for ~s, forbids ~s, but the " @@ -746,7 +746,7 @@ msgstr "" "la précondition du client a échoué pour ~s : elle autorise ~s, interdit ~s, " "mais la ressource a une représentation ~s" -#: src/scm/webid-oidc/errors.scm:1423 +#: src/scm/webid-oidc/errors.scm:1439 #, scheme-format msgid "" "the client precondition failed for ~s: it allows for ~s, forbids ~s, but the " @@ -755,71 +755,81 @@ msgstr "" "la précondition du client a échoué pour ~s : elle autorise ~s, interdit ~s, " "mais la ressource n’a pas de représentation" -#: src/scm/webid-oidc/errors.scm:1428 +#: src/scm/webid-oidc/errors.scm:1442 +#, scheme-format +msgid "" +"the client wanted a response with a content type among ~s, but the resource " +"at ~s has content-type ~s which cannot be converted to one of them" +msgstr "" +"le client voulait une réponse avec un type de contenu parmi ~s, mais la " +"ressource ~s a un type de contenu ~s qui ne peut pas être converti vers l’un " +"d’eux" + +#: src/scm/webid-oidc/errors.scm:1449 msgid "that’s it" msgstr "c’est tout" -#: src/scm/webid-oidc/errors.scm:1432 +#: src/scm/webid-oidc/errors.scm:1453 #, scheme-format msgid "~a and ~a" msgstr "~a et ~a" -#: src/scm/webid-oidc/errors.scm:1435 +#: src/scm/webid-oidc/errors.scm:1456 #, scheme-format msgid "~a, ~a" msgstr "~a, ~a" -#: src/scm/webid-oidc/errors.scm:1439 +#: src/scm/webid-oidc/errors.scm:1460 #, scheme-format msgid "the signature ~a does not match key ~s with payload ~a" msgstr "la signature ~a ne correspond pas à la clé ~s avec le contenu ~a" -#: src/scm/webid-oidc/errors.scm:1442 +#: src/scm/webid-oidc/errors.scm:1463 msgid "there is an undefined variable" msgstr "il y a une variable non définie" -#: src/scm/webid-oidc/errors.scm:1444 +#: src/scm/webid-oidc/errors.scm:1465 #, scheme-format msgid "the origin is ~a" msgstr "l’origine est ~a" -#: src/scm/webid-oidc/errors.scm:1447 +#: src/scm/webid-oidc/errors.scm:1468 #, scheme-format msgid "a message is attached: ~a" msgstr "un message est attaché : ~a" -#: src/scm/webid-oidc/errors.scm:1450 +#: src/scm/webid-oidc/errors.scm:1471 #, scheme-format msgid "the values ~s are problematic" msgstr "les valeurs ~s sont problématiques" -#: src/scm/webid-oidc/errors.scm:1453 +#: src/scm/webid-oidc/errors.scm:1474 #, scheme-format msgid "there is a kind (~s) and args ~s" msgstr "il y a un type (~s) et des arguments ~s" -#: src/scm/webid-oidc/errors.scm:1456 +#: src/scm/webid-oidc/errors.scm:1477 msgid "there is an assertion failure" msgstr "il y a un échec d’assertion" -#: src/scm/webid-oidc/errors.scm:1458 +#: src/scm/webid-oidc/errors.scm:1479 #, scheme-format msgid "the program quits with code ~a" msgstr "le programme quitte avec le code ~a" -#: src/scm/webid-oidc/errors.scm:1461 +#: src/scm/webid-oidc/errors.scm:1482 msgid "the program cannot recover from this exception" msgstr "le programme ne peut pas récupérer après cette exception" -#: src/scm/webid-oidc/errors.scm:1463 +#: src/scm/webid-oidc/errors.scm:1484 msgid "there is an external error" msgstr "il y a une erreur externe" -#: src/scm/webid-oidc/errors.scm:1465 +#: src/scm/webid-oidc/errors.scm:1486 msgid "there is an error" msgstr "il y a une erreur" -#: src/scm/webid-oidc/errors.scm:1467 +#: src/scm/webid-oidc/errors.scm:1488 #, scheme-format msgid "Unhandled exception type ~a." msgstr "Type d’exception non pris en charge ~a." @@ -966,17 +976,17 @@ msgstr "" "~a peut maintenant s'identifier en votre nom. Vous devez " "toujours ajuster ses permissions." -#: src/scm/webid-oidc/resource-server.scm:91 +#: src/scm/webid-oidc/resource-server.scm:92 #, scheme-format msgid "~a: authentication failure: ~a\n" msgstr "~a : échec d’authentificationn : ~a\n" -#: src/scm/webid-oidc/resource-server.scm:220 +#: src/scm/webid-oidc/resource-server.scm:237 #, scheme-format msgid "Warning: ~a\n" msgstr "Avertissement : ~a\n" -#: src/scm/webid-oidc/resource-server.scm:223 +#: src/scm/webid-oidc/resource-server.scm:240 #, scheme-format msgid "Error: ~a\n" msgstr "Erreur : ~a\n" diff --git a/po/webid-oidc.pot b/po/webid-oidc.pot index 89b625c..985c688 100644 --- a/po/webid-oidc.pot +++ b/po/webid-oidc.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: webid-oidc SNAPSHOT\n" "Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n" -"POT-Creation-Date: 2021-07-01 16:40+0200\n" +"POT-Creation-Date: 2021-07-02 10:57+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -122,671 +122,678 @@ msgstr "" msgid "Usage: generate-key [NUMBER OF BITS | CURVE]\n" msgstr "" -#: src/scm/webid-oidc/errors.scm:1047 +#: src/scm/webid-oidc/errors.scm:1063 msgid "that’s how it is" msgstr "" -#: src/scm/webid-oidc/errors.scm:1052 +#: src/scm/webid-oidc/errors.scm:1068 #, scheme-format msgid "the value ~s is not a base64 string (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1055 +#: src/scm/webid-oidc/errors.scm:1071 #, scheme-format msgid "the value ~s is not JSON (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1058 +#: src/scm/webid-oidc/errors.scm:1074 #, scheme-format msgid "the value ~s is not Turtle (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1061 +#: src/scm/webid-oidc/errors.scm:1077 #, scheme-format msgid "the value ~s does not identify an elleptic curve" msgstr "" -#: src/scm/webid-oidc/errors.scm:1066 +#: src/scm/webid-oidc/errors.scm:1082 #, scheme-format msgid "the value ~s does not identify a JWK (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1068 +#: src/scm/webid-oidc/errors.scm:1084 #, scheme-format msgid "the value ~s does not identify a JWK" msgstr "" -#: src/scm/webid-oidc/errors.scm:1073 +#: src/scm/webid-oidc/errors.scm:1089 #, scheme-format msgid "the value ~s does not identify a public JWK (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1075 +#: src/scm/webid-oidc/errors.scm:1091 #, scheme-format msgid "the value ~s does not identify a public JWK" msgstr "" -#: src/scm/webid-oidc/errors.scm:1080 +#: src/scm/webid-oidc/errors.scm:1096 #, scheme-format msgid "the value ~s does not identify a private JWK (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1082 +#: src/scm/webid-oidc/errors.scm:1098 #, scheme-format msgid "the value ~s does not identify a private JWK" msgstr "" -#: src/scm/webid-oidc/errors.scm:1087 +#: src/scm/webid-oidc/errors.scm:1103 #, scheme-format msgid "the value ~s does not identify a JWKS (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1089 +#: src/scm/webid-oidc/errors.scm:1105 #, scheme-format msgid "the value ~s does not identify a JWKS" msgstr "" -#: src/scm/webid-oidc/errors.scm:1092 +#: src/scm/webid-oidc/errors.scm:1108 #, scheme-format msgid "the value ~s does not identify a hash algorithm" msgstr "" -#: src/scm/webid-oidc/errors.scm:1095 +#: src/scm/webid-oidc/errors.scm:1111 #, scheme-format msgid "the value ~s is not an alist or misses key ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1098 +#: src/scm/webid-oidc/errors.scm:1114 #, scheme-format msgid "the value ~s is not a JWS header (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1101 +#: src/scm/webid-oidc/errors.scm:1117 #, scheme-format msgid "the value ~s is not a JWS payload (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1104 +#: src/scm/webid-oidc/errors.scm:1120 #, scheme-format msgid "the value ~s is not a JWS (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1107 +#: src/scm/webid-oidc/errors.scm:1123 #, scheme-format msgid "the string ~s cannot be split in 3 parts with ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1110 +#: src/scm/webid-oidc/errors.scm:1126 #, scheme-format msgid "" "all key candidates failed to verify signature ~s with algorithm ~s and " "payload ~a (there were ~a: ~s)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1113 +#: src/scm/webid-oidc/errors.scm:1129 #, scheme-format msgid "I cannot decode JWS ~a (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1116 +#: src/scm/webid-oidc/errors.scm:1132 #, scheme-format msgid "I cannot encode JWS ~a (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1119 +#: src/scm/webid-oidc/errors.scm:1135 #, scheme-format msgid "" "the server request unexpectedly failed with code ~a and reason phrase ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1124 +#: src/scm/webid-oidc/errors.scm:1140 #, scheme-format msgid "the header ~a should not have the value ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1126 +#: src/scm/webid-oidc/errors.scm:1142 #, scheme-format msgid "the header ~a should be present" msgstr "" -#: src/scm/webid-oidc/errors.scm:1129 +#: src/scm/webid-oidc/errors.scm:1145 #, scheme-format msgid "the server response wasn't expected: ~s (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1135 +#: src/scm/webid-oidc/errors.scm:1151 #, scheme-format msgid "the value ~s is not an OIDC configuration (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1140 +#: src/scm/webid-oidc/errors.scm:1156 #, scheme-format msgid "the webid field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1141 +#: src/scm/webid-oidc/errors.scm:1157 msgid "the webid field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1145 +#: src/scm/webid-oidc/errors.scm:1161 #, scheme-format msgid "the sub field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1146 +#: src/scm/webid-oidc/errors.scm:1162 msgid "the sub field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1150 +#: src/scm/webid-oidc/errors.scm:1166 #, scheme-format msgid "the iss field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1151 +#: src/scm/webid-oidc/errors.scm:1167 msgid "the iss field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1155 +#: src/scm/webid-oidc/errors.scm:1171 #, scheme-format msgid "the aud field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1156 +#: src/scm/webid-oidc/errors.scm:1172 msgid "the aud field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1160 +#: src/scm/webid-oidc/errors.scm:1176 #, scheme-format msgid "the iat field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1161 +#: src/scm/webid-oidc/errors.scm:1177 msgid "the iat field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1165 +#: src/scm/webid-oidc/errors.scm:1181 #, scheme-format msgid "the exp field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1166 +#: src/scm/webid-oidc/errors.scm:1182 msgid "the exp field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1170 +#: src/scm/webid-oidc/errors.scm:1186 #, scheme-format msgid "the cnf/jkt field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1171 +#: src/scm/webid-oidc/errors.scm:1187 msgid "the cnf/jkt field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1175 +#: src/scm/webid-oidc/errors.scm:1191 #, scheme-format msgid "the client-id field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1176 +#: src/scm/webid-oidc/errors.scm:1192 msgid "the client-id field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1180 +#: src/scm/webid-oidc/errors.scm:1196 #: src/scm/webid-oidc/authorization-page-unsafe.scm:149 #, scheme-format msgid "the redirect_uris field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1181 +#: src/scm/webid-oidc/errors.scm:1197 #: src/scm/webid-oidc/authorization-page-unsafe.scm:150 msgid "the redirect_uris field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1185 +#: src/scm/webid-oidc/errors.scm:1201 #, scheme-format msgid "the typ field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1186 +#: src/scm/webid-oidc/errors.scm:1202 msgid "the typ field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1190 +#: src/scm/webid-oidc/errors.scm:1206 #, scheme-format msgid "the jwk field is incorrect: ~s (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1192 +#: src/scm/webid-oidc/errors.scm:1208 msgid "the jwk field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1196 +#: src/scm/webid-oidc/errors.scm:1212 #, scheme-format msgid "the jti field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1197 +#: src/scm/webid-oidc/errors.scm:1213 msgid "the jti field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1201 +#: src/scm/webid-oidc/errors.scm:1217 #, scheme-format msgid "the nonce field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1202 +#: src/scm/webid-oidc/errors.scm:1218 msgid "the nonce field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1206 +#: src/scm/webid-oidc/errors.scm:1222 #, scheme-format msgid "the htm field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1207 +#: src/scm/webid-oidc/errors.scm:1223 msgid "the htm field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1211 +#: src/scm/webid-oidc/errors.scm:1227 #, scheme-format msgid "the htu field is incorrect: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1212 +#: src/scm/webid-oidc/errors.scm:1228 msgid "the htu field is missing" msgstr "" -#: src/scm/webid-oidc/errors.scm:1214 +#: src/scm/webid-oidc/errors.scm:1230 #, scheme-format msgid "~s is not an access token (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1217 +#: src/scm/webid-oidc/errors.scm:1233 #, scheme-format msgid "~s is not an access token header (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1220 +#: src/scm/webid-oidc/errors.scm:1236 #, scheme-format msgid "~s is not an access token payload (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1223 +#: src/scm/webid-oidc/errors.scm:1239 #, scheme-format msgid "~s is not a DPoP proof (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1226 +#: src/scm/webid-oidc/errors.scm:1242 #, scheme-format msgid "~s is not a DPoP proof header (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1229 +#: src/scm/webid-oidc/errors.scm:1245 #, scheme-format msgid "~s is not a DPoP proof payload (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1232 +#: src/scm/webid-oidc/errors.scm:1248 #, scheme-format msgid "I cannot fetch the issuer configuration of ~a (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1239 +#: src/scm/webid-oidc/errors.scm:1255 #, scheme-format msgid "I cannot fetch the JWKS of ~a at ~a (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1250 +#: src/scm/webid-oidc/errors.scm:1266 #, scheme-format msgid "the HTTP method is signed for ~s, but ~s was requested" msgstr "" -#: src/scm/webid-oidc/errors.scm:1253 +#: src/scm/webid-oidc/errors.scm:1269 #, scheme-format msgid "the HTTP uri is signed for ~a, but ~a was requested" msgstr "" -#: src/scm/webid-oidc/errors.scm:1256 +#: src/scm/webid-oidc/errors.scm:1272 #, scheme-format msgid "the date is ~a, but the DPoP proof is signed in the future at ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1260 +#: src/scm/webid-oidc/errors.scm:1276 #, scheme-format msgid "the date is ~a, but the DPoP proof was signed too long ago at ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1269 +#: src/scm/webid-oidc/errors.scm:1285 #, scheme-format msgid "the key ~s does not hash to ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1271 +#: src/scm/webid-oidc/errors.scm:1287 #, scheme-format msgid "the key confirmation of ~s failed (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1273 +#: src/scm/webid-oidc/errors.scm:1289 #, scheme-format msgid "the key confirmation of ~s failed" msgstr "" -#: src/scm/webid-oidc/errors.scm:1275 +#: src/scm/webid-oidc/errors.scm:1291 #, scheme-format msgid "the jti ~s has already been found (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1278 +#: src/scm/webid-oidc/errors.scm:1294 #, scheme-format msgid "I cannot decode ~s as an access token (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1281 +#: src/scm/webid-oidc/errors.scm:1297 #, scheme-format msgid "I cannot encode ~s as an access token with key ~s (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1284 +#: src/scm/webid-oidc/errors.scm:1300 #, scheme-format msgid "I cannot decode ~s as a DPoP proof (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1287 +#: src/scm/webid-oidc/errors.scm:1303 #, scheme-format msgid "I cannot encode ~s as a DPoP proof (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1290 +#: src/scm/webid-oidc/errors.scm:1306 #, scheme-format msgid "I could not fetch a RDF graph at ~a (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1293 +#: src/scm/webid-oidc/errors.scm:1309 #, scheme-format msgid "~s is not a client manifest (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1296 +#: src/scm/webid-oidc/errors.scm:1312 #, scheme-format msgid "~s does not authorize redirection URI ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1299 +#: src/scm/webid-oidc/errors.scm:1315 msgid "I cannot serve a public manifest" msgstr "" -#: src/scm/webid-oidc/errors.scm:1301 +#: src/scm/webid-oidc/errors.scm:1317 #, scheme-format msgid "~a does not have a client manifest registration triple" msgstr "" -#: src/scm/webid-oidc/errors.scm:1304 +#: src/scm/webid-oidc/errors.scm:1320 #, scheme-format msgid "the client manifest at ~a is advertised for ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1307 +#: src/scm/webid-oidc/errors.scm:1323 #, scheme-format msgid "I could not fetch the client manifest of ~a (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1310 +#: src/scm/webid-oidc/errors.scm:1326 #, scheme-format msgid "~s is not an authorization code (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1313 +#: src/scm/webid-oidc/errors.scm:1329 #, scheme-format msgid "~s is not an authorization code header (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1316 +#: src/scm/webid-oidc/errors.scm:1332 #, scheme-format msgid "~s is not an authorization code payload (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1319 +#: src/scm/webid-oidc/errors.scm:1335 #, scheme-format msgid "the current time is ~a, and the authorization code expired at ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1323 +#: src/scm/webid-oidc/errors.scm:1339 #, scheme-format msgid "I cannot decode ~s as an authorization code (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1326 +#: src/scm/webid-oidc/errors.scm:1342 #, scheme-format msgid "I cannot encode ~s as an authorization code (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1329 +#: src/scm/webid-oidc/errors.scm:1345 #, scheme-format msgid "there is no such refresh token as ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1332 +#: src/scm/webid-oidc/errors.scm:1348 #, scheme-format msgid "" "the refresh token is bound to a key confirmed as ~s, but it is used with key " "~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1335 +#: src/scm/webid-oidc/errors.scm:1351 #, scheme-format msgid "I cannot decode ~s as an ID token (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1338 +#: src/scm/webid-oidc/errors.scm:1354 #, scheme-format msgid "I cannot encode ~s as an ID token (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1341 +#: src/scm/webid-oidc/errors.scm:1357 #, scheme-format msgid "the grant type ~s is not supported" msgstr "" -#: src/scm/webid-oidc/errors.scm:1344 +#: src/scm/webid-oidc/errors.scm:1360 msgid "there is no authorization code in the request" msgstr "" -#: src/scm/webid-oidc/errors.scm:1346 +#: src/scm/webid-oidc/errors.scm:1362 msgid "there is no refresh token in the request" msgstr "" -#: src/scm/webid-oidc/errors.scm:1348 +#: src/scm/webid-oidc/errors.scm:1364 #, scheme-format msgid "~s is not an ID token (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1351 +#: src/scm/webid-oidc/errors.scm:1367 #, scheme-format msgid "~s is not an ID token header (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1354 +#: src/scm/webid-oidc/errors.scm:1370 #, scheme-format msgid "~s is not an ID token payload (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1357 +#: src/scm/webid-oidc/errors.scm:1373 #, scheme-format msgid "" "I couldn’t set the locale to ~s as an approximation of the client locale ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1360 +#: src/scm/webid-oidc/errors.scm:1376 #, scheme-format msgid "~s does not admit ~s as an identity provider" msgstr "" -#: src/scm/webid-oidc/errors.scm:1363 +#: src/scm/webid-oidc/errors.scm:1379 #, scheme-format msgid "" "~a is neither an identity provider (because ~a) nor a webid (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1368 +#: src/scm/webid-oidc/errors.scm:1384 #, scheme-format msgid "the token request failed (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1371 +#: src/scm/webid-oidc/errors.scm:1387 #, scheme-format msgid "you don’t have a refresh token for identity ~a certified by ~a in ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1376 +#: src/scm/webid-oidc/errors.scm:1392 #, scheme-format msgid "all identity provider candidates for ~a failed: ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1380 +#: src/scm/webid-oidc/errors.scm:1396 #, scheme-format msgid "~s failed (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1383 +#: src/scm/webid-oidc/errors.scm:1399 msgid ", " msgstr "" -#: src/scm/webid-oidc/errors.scm:1385 +#: src/scm/webid-oidc/errors.scm:1401 #, scheme-format msgid "no resource has been found to serve URI path ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1388 +#: src/scm/webid-oidc/errors.scm:1404 #, scheme-format msgid "the resource kind ~s is absent for the resource at ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1391 +#: src/scm/webid-oidc/errors.scm:1407 #, scheme-format msgid "no resource has been found to serve URI path ~s, but ~s exists" msgstr "" -#: src/scm/webid-oidc/errors.scm:1394 +#: src/scm/webid-oidc/errors.scm:1410 msgid "the root storage cannot be deleted" msgstr "" -#: src/scm/webid-oidc/errors.scm:1396 +#: src/scm/webid-oidc/errors.scm:1412 #, scheme-format msgid "the container ~s should be emptied before being deleted" msgstr "" -#: src/scm/webid-oidc/errors.scm:1399 +#: src/scm/webid-oidc/errors.scm:1415 #, scheme-format msgid "the group ~s cannot be fetched (because ~a)" msgstr "" -#: src/scm/webid-oidc/errors.scm:1403 +#: src/scm/webid-oidc/errors.scm:1419 #, scheme-format msgid "the containment triples in the request to update ~s are not up to date" msgstr "" -#: src/scm/webid-oidc/errors.scm:1406 +#: src/scm/webid-oidc/errors.scm:1422 #, scheme-format msgid "the server cannot process resources with the ~s content-type" msgstr "" -#: src/scm/webid-oidc/errors.scm:1409 +#: src/scm/webid-oidc/errors.scm:1425 #, scheme-format msgid "" "the client wants to create a resource at ~s, which is reserved for an " "auxiliary resource" msgstr "" -#: src/scm/webid-oidc/errors.scm:1412 +#: src/scm/webid-oidc/errors.scm:1428 #, scheme-format msgid "" "the operation on ~s by ~a is refused, because it’s not by ~s and the access " "control forbids the following mode of operation: ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1416 +#: src/scm/webid-oidc/errors.scm:1432 msgid "an anonymous user" msgstr "" -#: src/scm/webid-oidc/errors.scm:1421 +#: src/scm/webid-oidc/errors.scm:1437 #, scheme-format msgid "" "the client precondition failed for ~s: it allows for ~s, forbids ~s, but the " "resource has a representation of ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1423 +#: src/scm/webid-oidc/errors.scm:1439 #, scheme-format msgid "" "the client precondition failed for ~s: it allows for ~s, forbids ~s, but the " "resource has no representation" msgstr "" -#: src/scm/webid-oidc/errors.scm:1428 +#: src/scm/webid-oidc/errors.scm:1442 +#, scheme-format +msgid "" +"the client wanted a response with a content type among ~s, but the resource " +"at ~s has content-type ~s which cannot be converted to one of them" +msgstr "" + +#: src/scm/webid-oidc/errors.scm:1449 msgid "that’s it" msgstr "" -#: src/scm/webid-oidc/errors.scm:1432 +#: src/scm/webid-oidc/errors.scm:1453 #, scheme-format msgid "~a and ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1435 +#: src/scm/webid-oidc/errors.scm:1456 #, scheme-format msgid "~a, ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1439 +#: src/scm/webid-oidc/errors.scm:1460 #, scheme-format msgid "the signature ~a does not match key ~s with payload ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1442 +#: src/scm/webid-oidc/errors.scm:1463 msgid "there is an undefined variable" msgstr "" -#: src/scm/webid-oidc/errors.scm:1444 +#: src/scm/webid-oidc/errors.scm:1465 #, scheme-format msgid "the origin is ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1447 +#: src/scm/webid-oidc/errors.scm:1468 #, scheme-format msgid "a message is attached: ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1450 +#: src/scm/webid-oidc/errors.scm:1471 #, scheme-format msgid "the values ~s are problematic" msgstr "" -#: src/scm/webid-oidc/errors.scm:1453 +#: src/scm/webid-oidc/errors.scm:1474 #, scheme-format msgid "there is a kind (~s) and args ~s" msgstr "" -#: src/scm/webid-oidc/errors.scm:1456 +#: src/scm/webid-oidc/errors.scm:1477 msgid "there is an assertion failure" msgstr "" -#: src/scm/webid-oidc/errors.scm:1458 +#: src/scm/webid-oidc/errors.scm:1479 #, scheme-format msgid "the program quits with code ~a" msgstr "" -#: src/scm/webid-oidc/errors.scm:1461 +#: src/scm/webid-oidc/errors.scm:1482 msgid "the program cannot recover from this exception" msgstr "" -#: src/scm/webid-oidc/errors.scm:1463 +#: src/scm/webid-oidc/errors.scm:1484 msgid "there is an external error" msgstr "" -#: src/scm/webid-oidc/errors.scm:1465 +#: src/scm/webid-oidc/errors.scm:1486 msgid "there is an error" msgstr "" -#: src/scm/webid-oidc/errors.scm:1467 +#: src/scm/webid-oidc/errors.scm:1488 #, scheme-format msgid "Unhandled exception type ~a." msgstr "" @@ -927,17 +934,17 @@ msgid "" "permissions." msgstr "" -#: src/scm/webid-oidc/resource-server.scm:91 +#: src/scm/webid-oidc/resource-server.scm:92 #, scheme-format msgid "~a: authentication failure: ~a\n" msgstr "" -#: src/scm/webid-oidc/resource-server.scm:220 +#: src/scm/webid-oidc/resource-server.scm:237 #, scheme-format msgid "Warning: ~a\n" msgstr "" -#: src/scm/webid-oidc/resource-server.scm:223 +#: src/scm/webid-oidc/resource-server.scm:240 #, scheme-format msgid "Error: ~a\n" msgstr "" diff --git a/src/scm/webid-oidc/Makefile.am b/src/scm/webid-oidc/Makefile.am index 867d2ee..bdb3af8 100644 --- a/src/scm/webid-oidc/Makefile.am +++ b/src/scm/webid-oidc/Makefile.am @@ -26,6 +26,7 @@ dist_webidoidcmod_DATA += \ %reldir%/jti.scm \ %reldir%/dpop-proof.scm \ %reldir%/fetch.scm \ + %reldir%/serve.scm \ %reldir%/client-manifest.scm \ %reldir%/authorization-code.scm \ %reldir%/refresh-token.scm \ @@ -57,6 +58,7 @@ webidoidcgo_DATA += \ %reldir%/jti.go \ %reldir%/dpop-proof.go \ %reldir%/fetch.go \ + %reldir%/serve.go \ %reldir%/client-manifest.go \ %reldir%/authorization-code.go \ %reldir%/refresh-token.go \ diff --git a/src/scm/webid-oidc/errors.scm b/src/scm/webid-oidc/errors.scm index c969a40..522e563 100644 --- a/src/scm/webid-oidc/errors.scm +++ b/src/scm/webid-oidc/errors.scm @@ -1036,6 +1036,22 @@ precondition-failed-if-none-match precondition-failed-real-etag) +(define-exception-type + ¬-acceptable + &external-error + make-not-acceptable + not-acceptable? + (client-accepts not-acceptable-client-accepts) + (path not-acceptable-path) + (content-type not-acceptable-content-type)) + +(export ¬-acceptable + make-not-acceptable + not-acceptable? + not-acceptable-client-accepts + not-acceptable-path + not-acceptable-content-type) + (define*-public (error->str err #:key (max-depth #f)) (if (record? err) (let* ((type (record-type-descriptor err)) @@ -1422,6 +1438,11 @@ (get 'path) (get 'if-match) (get 'if-none-match) (get 'real-etag)) (format #f (G_ "the client precondition failed for ~s: it allows for ~s, forbids ~s, but the resource has no representation") (get 'path) (get 'if-match) (get 'if-none-match)))) + ((¬-acceptable) + (format #f (G_ "the client wanted a response with a content type among ~s, but the resource at ~s has content-type ~s which cannot be converted to one of them") + (get 'client-accepts) + (get 'path) + (get 'content-type))) ((&compound-exception) (let ((components (get 'components))) (if (null? components) diff --git a/src/scm/webid-oidc/resource-server.scm b/src/scm/webid-oidc/resource-server.scm index 9988cba..7f9c8f9 100644 --- a/src/scm/webid-oidc/resource-server.scm +++ b/src/scm/webid-oidc/resource-server.scm @@ -20,6 +20,7 @@ #:use-module (webid-oidc provider-confirmation) #:use-module (webid-oidc jwk) #:use-module (webid-oidc dpop-proof) + #:use-module (webid-oidc serve) #:use-module (webid-oidc server create) #:use-module (webid-oidc server read) #:use-module (webid-oidc server update) @@ -148,12 +149,27 @@ #:http-get http-get) (with-exception-handler (lambda (error) - (return - (build-response - #:headers headers) - (if (eq? method 'GET) - content - ""))) + (let ((true-content-type + (car (assq-ref headers 'content-type))) + (other-headers + (filter + (lambda (h) + (not (eq? (car h) 'content-type))) + headers))) + (receive (negociated-content-type + negociated-content) + (convert (request-accept request #f) + server-uri + (uri-path (request-uri request)) + true-content-type + content) + (return + (build-response + #:headers (cons `(content-type ,negociated-content-type) + other-headers)) + (if (eq? method 'GET) + negociated-content + ""))))) (lambda () (unless (or (request-if-match request) (request-if-none-match request)) @@ -220,59 +236,64 @@ (if (cannot-fetch-group? error) (format (current-error-port) (G_ "Warning: ~a\n") (error->str error)) - (begin - (format (current-error-port) (G_ "Error: ~a\n") - (error->str error)) - (cond - ((uri-slash-semantics-error? error) - (return - (build-response - #:code 301 - #:reason-phrase "Found" - #:headers - `((location - . ,(build-uri - (uri-scheme server-uri) - #:userinfo (uri-userinfo server-uri) - #:host (uri-host server-uri) - #:port (uri-port server-uri) - #:path (uri-slash-semantics-error-expected-path error))))) - "")) - ((or (path-not-found? error) - (auxiliary-resource-absent? error) - (forbidden? error)) - (if user - ;; That’s a forbidden - (return - (build-response #:code 403 #:reason-phrase "Forbidden") - "") - (return - (build-response #:code 401 #:reason-phrase "Unauthorized" - #:headers `((www-authenticate . ((DPoP))))) - ""))) - ((or (cannot-delete-root? error)) - (return - (build-response - #:code 405 - #:reason-phrase "Method Not Allowed") - "")) - ((or (container-not-empty? error) - (incorrect-containment-triples? error) - (path-is-auxiliary? error)) - (return - (build-response - #:code 409 - #:reason-phrase "Conflict") - "")) - ((unsupported-media-type? error) - (return - (build-response - #:code 415 - #:reason-phrase "Unsupported Media Type") - "")) - ((precondition-failed? error) - (return - (build-response - #:code 412 - #:reason-phrase "Precondition Failed") - "")))))))))) + (cond + ((uri-slash-semantics-error? error) + (return + (build-response + #:code 301 + #:reason-phrase "Found" + #:headers + `((location + . ,(build-uri + (uri-scheme server-uri) + #:userinfo (uri-userinfo server-uri) + #:host (uri-host server-uri) + #:port (uri-port server-uri) + #:path (uri-slash-semantics-error-expected-path error))))) + #f)) + ((or (path-not-found? error) + (auxiliary-resource-absent? error) + (forbidden? error)) + (if user + ;; That’s a forbidden + (return + (build-response #:code 403 #:reason-phrase "Forbidden") + #f) + (return + (build-response #:code 401 #:reason-phrase "Unauthorized" + #:headers `((www-authenticate . ((DPoP))))) + #f))) + ((or (cannot-delete-root? error)) + (return + (build-response + #:code 405 + #:reason-phrase "Method Not Allowed") + #f)) + ((or (container-not-empty? error) + (incorrect-containment-triples? error) + (path-is-auxiliary? error)) + (return + (build-response + #:code 409 + #:reason-phrase "Conflict") + #f)) + ((unsupported-media-type? error) + (return + (build-response + #:code 415 + #:reason-phrase "Unsupported Media Type") + #f)) + ((precondition-failed? error) + (return + (build-response + #:code 412 + #:reason-phrase "Precondition Failed") + #f)) + ((not-acceptable? error) + (return + (build-response + #:code 406 + #:reason-phrase "Not Acceptable") + #f)) + (else + (raise-exception error))))))))) diff --git a/src/scm/webid-oidc/serve.scm b/src/scm/webid-oidc/serve.scm new file mode 100644 index 0000000..4f54495 --- /dev/null +++ b/src/scm/webid-oidc/serve.scm @@ -0,0 +1,73 @@ +;; webid-oidc, implementation of the Solid specification +;; Copyright (C) 2021 Vivien Kraus + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU Affero General Public License as +;; published by the Free Software Foundation, either version 3 of the +;; License, or (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU Affero General Public License for more details. + +;; You should have received a copy of the GNU Affero General Public License +;; along with this program. If not, see . + +(define-module (webid-oidc serve) + #:use-module (webid-oidc errors) + #:use-module (webid-oidc fetch) + #:use-module (ice-9 optargs) + #:use-module (ice-9 receive) + #:use-module (ice-9 exceptions) + #:use-module (rnrs bytevectors) + #:use-module (web client) + #:use-module (web request) + #:use-module (web response) + #:use-module (web uri) + #:use-module (rdf rdf) + #:use-module (turtle fromrdf) + #:use-module (nquads fromrdf) + #:export + ( + convert + )) + +(define (convert client-accepts server-name path content-type content) + (let ((data-as-rdf + (false-if-exception + (fetch + (build-uri (uri-scheme server-name) + #:userinfo (uri-userinfo server-name) + #:host (uri-host server-name) + #:port (uri-port server-name) + #:path path) + #:http-get + (lambda args + (values (build-response + #:headers `((content-type ,content-type))) + content)))))) + (if client-accepts + ;; Content negociation is asked + (let try-satisfy ((accepts client-accepts)) + (if (null? accepts) + (raise-exception (make-not-acceptable client-accepts path content-type)) + (let ((request (caar accepts))) + (cond + ((or (eq? request content-type) + (eq? request '*/*)) + (values content-type content)) + ((and (eq? request 'text/turtle) data-as-rdf) + (values 'text/turtle + (rdf->turtle data-as-rdf))) + ((and (or (eq? request 'application/n-quads) + (eq? request 'text/x-nquads)) + data-as-rdf) + (values request + (rdf->nquads + (make-rdf-dataset data-as-rdf '())))) + ;; Add other conversion strategies here + (else + (try-satisfy (cdr accepts))))))) + ;; Content negociation is unwanted + (values content-type content)))) -- cgit v1.2.3