-
-
Notifications
You must be signed in to change notification settings - Fork 158
Question: How to stay compliant with the specification using a custom AuthenticationHandler #950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @VincentVrijburg, I don't think we've had this question before. So to answer it, we'll need to prototype an auth handler and analyze in what order things execute. I assume you mean something along the lines of https://joonasw.net/view/creating-auth-scheme-in-aspnet-core-2, right? It would help greatly if you can provide a minimal demo project that we can debug. |
Hi @bart-degreed, I know that before aspnet core 2 you could create a middleware that returned the custom authentication handler. Meaning that, in theory, you could register it after a library like JADNC. However, they changed that approach to a single-middleware setup. The current approach is adding the custom authentication handler as a scheme (just like that article you shared) and register it with the default Anyway, I think I'll be able to set up a quick demo project later today. I'll let you know once I have something ready! |
Hi @bart-degreed, I've managed to set up a demo project using JADNC in combination with a custom authentication handler: https://github.com/VincentVrijburg/JsonApiDotNetCore.Demo.Auth See the readme for more information about how to set it up and use it. Note: I have used the same versions as described in the issue above I will do some minor debugging myself out of curiosity and I'll let you know if I have something interesting to share! |
Thanks for the helpful demo project! I've tried to answer your question at VincentVrijburg/JsonApiDotNetCore.Demo.Auth#1. Hope this helps. |
Simple yet effective, love it! I wasn't sure how to tap into existing JADNC serializers and handlers but the proposed solution works for me. I've added some additional code to my demo project in order to use the same JSON serializer settings ( |
DESCRIPTION
I'm implementing a custom AuthenticationHandler to support API Key based authentication. However, I cannot find how to stay compliant with the JSON:API specification since I don't have access to the services from JADNC at the authentication stage, within the middleware pipeline.
My question is how I should handle the authentication (error) responses through JADNC in order to stay compliant with the specification.
STEPS TO REPRODUCE
Startup.cs:
I had a look at the source code and found two "problems" related to my issue:
EXPECTED BEHAVIOR
Being able to handle responses, outside of regular resource controllers, through JADNC.
ACTUAL BEHAVIOR
Responses (outside of regular resource controllers) being unhandled resulting in responses which aren't compliant with the JSON:API specification.
VERSIONS USED
The text was updated successfully, but these errors were encountered: