You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's an increasing number of questions on the solid project forum about problems with client authentication or rejected authentication requests. These are (deliberately) hard to debug on the client side, but CSS provides an ideal platform to help debug on the server side, i.e. we could encourage users to install CSS and look at the debug messages.
As mentioned in another issue (#909 (comment)) reporting of IDP errors is currently minimal.
I've personally taken to including console.log statements in the relevant files for node_modules for oidc-provider. That's obviously not the right approach.
Any thoughts on how a proper error reporting set up should be structured?
Reacted by Ruben Verborgh, Randy Le and Justin Bingham
Adding logging in our IDP classes can help, but if I understand @josephguillaume correctly, it is actually logging from the OIDC library itself that is required. I have also already added console.log statements to the source of that library at some point to debug some issues. So that's not perfect.
Thanks!
I was particularly thinking of logging the messages for client authentication errors that oidc-provider throws and that currently seem to be swallowed somewhere.
I'll have to do some more digging to see where they are meant to show up.
It sounds like questions about reporting of these errors are probably worth addressing case-by-case. Let me know if you'd like me to submit separate issues, or whether discussing them here is the better option.
Yes, I was using -l debug, but I should also have double-checked the situation rather than answering from memory, sorry. The error is indeed not swallowed. The problem is rather that the description provided was too terse.
2021-11-12T21:04:49.189Z [WebIdAdapter] debug: Looking for payload data at https://CLIENT.PATH/webid.jsonld#this
2021-11-12T21:04:49.196Z [IfNeededConverter] debug: Conversion needed for b0 from internal/error to satisfy text/plain;q=1
2021-11-12T21:04:49.197Z [IfNeededConverter] debug: Conversion needed for b0 from internal/error to satisfy text/plain;q=1
2021-11-12T21:04:49.200Z [ChainedConverter] warn: No conversion path could be made from internal/error to text/plain,internal/*.
2021-11-12T21:04:49.201Z [SafeErrorHandler] debug: Recovering from error handler failure: No conversion path could be made from internal/error to text/plain,internal/*.
2021-11-12T21:04:49.202Z [LinkRelMetadataWriter] debug: Available link relations: 3
2021-11-12T21:04:49.203Z [ParsingHttpHandler] verbose: Parsed GET operation on https://IDP.PATH/idp/auth
But the server obviously still returns the error: InvalidClientMetadata: invalid_client_metadata
The issue here is that this is a very common error and we actually want to report the error_description.
Here's the full error trace:
InvalidClientMetadata: invalid_client_metadataatSchema.invalidate(/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/helpers/client_schema.js:373:13)at/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/helpers/client_schema.js:644:18atSet.forEach(<anonymous>)
at Schema.scopes (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/helpers/client_schema.js:642:16)
at new Schema (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/helpers/client_schema.js:266:12)
at new Client (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/models/client.js:423:22)
at add (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/models/client.js:400:20)
at Function.find (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/models/client.js:599:24)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async checkClient (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/actions/authorization/check_client.js:78:18)
at async parseBodyIfPost (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/shared/conditional_body.js:7:5)
at async sessionHandler (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/shared/session.js:29:5)
at async noCache (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/shared/no_cache.js:4:3)
at async authorizationErrorHandler (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/shared/authorization_error_handler.js:55:7)
at async ensureSessionSave (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/helpers/initialize_app.js:51:7)
at async contextEnsureOidc (/home/josephguillaume/solid-server/community-server-recipes/mashlib/node_modules/oidc-provider/lib/shared/context_ensure_oidc.js:4:5) {error: 'invalid_client_metadata',status: 400,statusCode: 400,expose: true,error_description: 'scope must only contain supported scopes'}
So I think the questions in this specific case are:
Should the requested conversion to "text/plain" be changed to something else, e.g. "application/json", which then uses the ErrorToJsonConverter?
Would it be ok for the error_description to be returned to the client, or should this detail only be reported in the server logs? The use of the errorHandler suggests it would be ok, and the error does have expose: true set.
Is the correct solution here to modify the structure of the error from oidc-provider so that it matches what e.g. ErrorToJsonConverter expects?
This fix:
configureErrors(config){config.renderError=async(ctx,out,error)=>{if(error.error_description)error.details=error.error_description;// This allows us to stream directly to to the response object, see https://github.com/koajs/koa/issues/944ctx.respond=false;constresult=awaitthis.errorHandler.handleSafe({ error,preferences: {type: {'application/json': 1}}});awaitthis.responseWriter.handleSafe({response: ctx.res, result });};}
Would result in this report:
{"name":"InvalidClientMetadata","message":"invalid_client_metadata","statusCode":400,"details":"scope must only contain supported scopes"}
Should the requested conversion to "text/plain" be changed to something else, e.g. "application/json", which then uses the ErrorToJsonConverter?
We should parse the accept header and use that. Open issues for that are #1033 and #810.
Would it be ok for the error_description to be returned to the client, or should this detail only be reported in the server logs? The use of the errorHandler suggests it would be ok, and the error does have expose: true set.
Depends a bit on how much information is provided by that. We could make it an option as we currently do for stack trace: the server wil output the stack trace of errors if you start it with the -t flag.
Is the correct solution here to modify the structure of the error from oidc-provider so that it matches what e.g. ErrorToJsonConverter expects?
We could also create a new ErrorHandler specifically for IDP errors, but I think just modifying the error object is fine in this specific case.
Hi all - I was pointed to this open issue and I would like also to see if possible more verbose output from the Community Solid Server (CSS) in the case of errors.
I also have been trying to run CSS in verbose logging mode as a teaching tool for myself to get used to Solid. When troubleshooting an "invalid_grant" response (which I understand to be specific to OpenID, not CSS) it would be helpful if I had specific details about what was wrong, even when debugging the outgoing HTTP POST. I'm following the primer here and I am on step 12 to 14.
I understand per here that an invalid_grant can mean:
The provided authorization grant (e.g., authorization
code, resource owner credentials) or refresh token is
invalid, expired, revoked, does not match the redirection
URI used in the authorization request, or was issued to
another client.
After a lot of time troubleshooting, I finally was able to resolve my issue to myself incorrectly caching the code_verifier value and sending the wrong value. However, I was hopeful that perhaps if CSS had a verbose or developer mode, that it could've told me specifically what I was sending over incorrectly. Specifically, it would be helpful as a learning tool if it told me if the Json Web Token I created (JWT) was malformed, etc.
Activity
RubenVerborgh commentedon Nov 11, 2021
@josephguillaume thanks for taking this up!
Rather than
console.log, we suggest you use our logging system. Here is a good example.Basically, you import the logger:
https://github.com/solid/community-server/blob/c13456c2259538e502a59ce73a226bab2c99c395/src/authentication/BearerWebIdExtractor.ts#L3
and create a local instance in your class:
https://github.com/solid/community-server/blob/c13456c2259538e502a59ce73a226bab2c99c395/src/authentication/BearerWebIdExtractor.ts#L11-L12
and whenever you want to report something, you call a method with the appropriate logging level:
https://github.com/solid/community-server/blob/c13456c2259538e502a59ce73a226bab2c99c395/src/authentication/BearerWebIdExtractor.ts#L32
It would be awesome if you could share your logging code with us when it's ready; we would be very happy to accept a PR.
jvherweg commentedon Nov 12, 2021
Adding logging in our IDP classes can help, but if I understand @josephguillaume correctly, it is actually logging from the OIDC library itself that is required. I have also already added
console.logstatements to the source of that library at some point to debug some issues. So that's not perfect.It depends a bit on what kind of logging you need specifically. It might be interesting to define which logging would be expected and helpful to debug issues. One thing that might already be useful is that it is possible to log the response object that is being sent out by OIDC library: https://github.com/panva/node-oidc-provider/blob/v6.x/docs/README.md#pre--and-post-middlewares , although it is a bit awkward that the logging has to happen after the
nextcall, I have already used this many times to see which access tokens are being sent out.josephguillaume commentedon Nov 12, 2021
Thanks!
I was particularly thinking of logging the messages for client authentication errors that oidc-provider throws and that currently seem to be swallowed somewhere.
I'll have to do some more digging to see where they are meant to show up.
RubenVerborgh commentedon Nov 12, 2021
I'd be surprised is that was the case; have you started CSS with
-l debugto increase the log level?josephguillaume commentedon Nov 12, 2021
It sounds like questions about reporting of these errors are probably worth addressing case-by-case. Let me know if you'd like me to submit separate issues, or whether discussing them here is the better option.
Yes, I was using
-l debug, but I should also have double-checked the situation rather than answering from memory, sorry. The error is indeed not swallowed. The problem is rather that the description provided was too terse.If I put an error in the client id document, it is handled by :
https://github.com/solid/community-server/blob/c13456c2259538e502a59ce73a226bab2c99c395/src/identity/configuration/IdentityProviderFactory.ts#L254
This actually results in a conversion warning
But the server obviously still returns the error:
InvalidClientMetadata: invalid_client_metadataThe issue here is that this is a very common error and we actually want to report the error_description.
Here's the full error trace:
So I think the questions in this specific case are:
expose: trueset.This fix:
Would result in this report:
Edit: it looks a proper solution would also need to expose error_detail in some cases: https://github.com/panva/node-oidc-provider/blob/main/lib/helpers/errors.js
jvherweg commentedon Nov 15, 2021
We should parse the accept header and use that. Open issues for that are #1033 and #810.
Depends a bit on how much information is provided by that. We could make it an option as we currently do for stack trace: the server wil output the stack trace of errors if you start it with the
-tflag.We could also create a new ErrorHandler specifically for IDP errors, but I think just modifying the error object is fine in this specific case.
dynamoRando commentedon Jan 18, 2022
Hi all - I was pointed to this open issue and I would like also to see if possible more verbose output from the Community Solid Server (CSS) in the case of errors.
I also have been trying to run CSS in verbose logging mode as a teaching tool for myself to get used to Solid. When troubleshooting an "invalid_grant" response (which I understand to be specific to OpenID, not CSS) it would be helpful if I had specific details about what was wrong, even when debugging the outgoing HTTP POST. I'm following the primer here and I am on step 12 to 14.
I understand per here that an
invalid_grantcan mean:After a lot of time troubleshooting, I finally was able to resolve my issue to myself incorrectly caching the
code_verifiervalue and sending the wrong value. However, I was hopeful that perhaps if CSS had a verbose or developer mode, that it could've told me specifically what I was sending over incorrectly. Specifically, it would be helpful as a learning tool if it told me if the Json Web Token I created (JWT) was malformed, etc.Just a suggestion. Thanks!
jvherweg commentedon Feb 21, 2022
I have updated the returned errors in #1166 so they include the information in the
error_description. Feel free to reopen if more logging is required.