-
Notifications
You must be signed in to change notification settings - Fork 164
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
I'm attempting to implement a dual authentication scheme and I'm wondering whether it's feasible. If it is possible, could you assist me by pointing out any mistakes I might be making? #1113
Comments
Where does the |
Have you tried the following? app.UseGraphQLUpload<Schema>().UseGraphQL("/graphql", opts =>
{
opts.AuthenticationSchemes = ["Bearer", "ApiKey"];
}); |
For reference, see this: |
I'll move this issue to the server repo. |
Adding the schemes to the UseGraphQL call is needed because the authorization rule is based solely on the data within |
Thanks for the guidance! I'll give that method a shot and see how it goes. |
They come from GraphQL.Upload.AspNetCore. I'm using it to upload files to graphql |
I just try
I've just tried this and it worked perfectly, thank you so much! Is there any way I can support your project? |
You can support the team by contributing via OpenCollective here: https://opencollective.com/graphql-net Any contributions will be greatly appreciated! You should be aware that while that solution fixed the issue for regular queries, it's not going to work for multipart requests, as the options set in that sample don't apply to requests handled by UseGraphQLUpload. You'd need to either (a) rewrite the upload middleware to support multiple authentication schemes, or (b) write some ASP.NET Core middleware to rewrite the HttpContext.User value before it hits either middleware. Option B is easier... |
Here's a PR to update the library to support setting supported authentication schemes: |
Here's an update within this PR to support file uploading: |
Update has been released in 7.7.0. You should not need the GraphQL Upload middleware anymore. |
Hello, the logic I'm using works fine in my API, but when I attempt to implement it in my GraphQL project, it fails to function. Here is the code from my Program.cs:
I am attempting to implement the apiKey Policy in this manner:
I have applied this policy in a controller, and it works as expected. The setup in my API's program is quite similar, especially the
.AddAuthentication()
part, which uses the same code.Below is the code for my ApiKeyHandler:
Sorry for the inconvenience, the truth is I've been stuck on this for a couple of days, thank you!
The text was updated successfully, but these errors were encountered: