Should JwtBearerHandler implement SignInAuthenticationHandler? #24158
Unanswered
yorickdewid
asked this question in
General
Replies: 1 comment 3 replies
-
We've avoided that in the past because there's no standard way to deliver the generated token to the client. The response is app specific. I'd expect most apps to communicate this in a Json body. The Authorization header is for requests, www-authenticate is for responses but it's only supposed to describe auth schemes, not deliver credentials. What you can do is resolve the JwtBearer options from DI into your API controller and use those to generate a Jwt. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently ASP.NET Core
JwtBearer
does not offer sign in support, but only Authentication and Challenge handlers. When building an API there is really no way to generate JWT tokens except when using an identity server. Simple APIs often do not require an entire identity server setup with full OAuth 2.0 and an OIDC provider.A quick search around the internet learns that there is many (sometimes disastrous) tutorials showing how to write a simple JWT token generator. Putting security concepts to a large developer base may not yield great results, especially in an otherwise secure framework.
Is there any specific reason why the JWT bearer handler cannot sign in principals, and creates a basic JWT token for local authentication?
The implementation would be most trivial, in fact I've a proof of concept ready. The interface would be much like how cookie authentication is done for local principals.
The code stub above would attach a
Bearer
token to theAuthorization
HTTP header. There is little to no configuration required to generate JWT tokens.Beta Was this translation helpful? Give feedback.
All reactions