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
I need to add authentication to a subset of my resolvers, so I've created a decorator function that will look for a JWT token in the Authorization header and validate it.
However, I'm not sure what the appropriate behavior is in the case where the request is not properly authenticated. (Meaning they didn't include the header, or the token is invalid, or the user is deleted, etc.)
Should I raise an exception in the decorator? Which exception? graphql.GraphQLError? ariadne.exceptions.HttpBadRequestError?
If you're curious about the current state of my code...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I need to add authentication to a subset of my resolvers, so I've created a decorator function that will look for a JWT token in the Authorization header and validate it.
However, I'm not sure what the appropriate behavior is in the case where the request is not properly authenticated. (Meaning they didn't include the header, or the token is invalid, or the user is deleted, etc.)
Should I raise an exception in the decorator? Which exception?
graphql.GraphQLError
?ariadne.exceptions.HttpBadRequestError
?If you're curious about the current state of my code...
Beta Was this translation helpful? Give feedback.
All reactions