aerogear / keycloak-connect-graphql

Add Keyloak Authentication and Authorization to your GraphQL server.
Apache License 2.0
157 stars 23 forks source link

No error codes #100

Closed dakkafex closed 4 years ago

dakkafex commented 4 years ago

No error codes are being sent on auth error, this is all im getting

{
  "data": null,
  "errors": [
    {
      "message": "User not Authenticated",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "me"
      ]
    }
  ]
}
wtrocki commented 4 years ago

Hm.. all depends how your server handles errors..It might be that you have some global error handler that eats errors some specific way. Docs assumes that you do not have any handler and this usually means than any throw will produce 500 and print error object including status value we attach to it.

Also it might be some regression issue, but after quick check on example in the repo I see errors comming back.

To help I will need to reproduce this I will need to know:

wtrocki commented 4 years ago

Hi @dakkafex

I managed to replicate problem by adding error middleware to express that suppresses errors. Please review your middleware

dakkafex commented 4 years ago

keycloak is the only middleware im using. server.express.use(keycloak.middleware())

wtrocki commented 4 years ago

I will need to know: version of the lib you are using keycloak version

You are getting the right message but code added to error is being removed/ignored.

https://github.com/aerogear/keycloak-connect-graphql/blob/master/src/directives/directiveResolvers.ts#L100-L101

Codes were added in 0.4.0

dakkafex commented 4 years ago

0.5.0 and 10.0.2

wtrocki commented 4 years ago

Ok. I cannot reproduce this issue. Automatic tests and example app returns right data. That is version 0.6.0

dakkafex commented 4 years ago

updated it to 0.6.0 and still not getting any error codes

wtrocki commented 4 years ago

@dakkafex would you be able to reproduce this in the example app in repository? I would love to help and there must be something missing on my side that I simply cannot see.

Or would you be able to put console log in this method and also log error

https://github.com/aerogear/keycloak-connect-graphql/blob/master/src/directives/directiveResolvers.ts#L100-L101

wtrocki commented 4 years ago

I have tried to replicate this again today.

We are missing info - I suspect this is due to using a different version of the Apollo/GraphQL-tools but could not replicate this problem