When i used Web API , i used the attribute [Authorize] above the controller
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
i have installed the Authorization package of hotchocolate.
I wonder how i can reach the same approach with
descriptor.Authorize();
in my overrided configuration method
how i can pass "AuthenticationSchemes " to the Authorize() method
I have another small question:
how i can fetch the Context ?
Hot Chocolate provides directives for authorization but does not do authentication. The bearer schema has to be configured with authentication.
For authentication refer to the ASP.NET documentation.
Once you have setup authentication you can use use policies, roles or just the authenticated check provided by the authorize directives.
how i can fetch the Context ?
If you mean the HttpContext then register the IHttpContextAccessor and use dependency injection.
how i can fetch the Context ?
If you mean the HttpContext then register the
IHttpContextAccessorand use dependency injection.
Thanks a lot for the help.
But, i have tried fetching the context with IHttpContextAccessor before i created this issue. unfortunately, not all properties are fetched !
for example the body stream, is not fetched !
What do you actually want to do?
well, i tried to catch the body as a stream
the body, i mean, the query itself
You cannot do that since the middleware has already consumed the body. You can however access the parsed body through the IResolverContext.