Replies: 3 comments
-
As a side note, I was able to call I think this will actually suffice for what I need, but would still be curious if there is a different way to just say |
Beta Was this translation helpful? Give feedback.
-
A followup here... if I allowAnonymous so that the interceptor fires, I can call If I do |
Beta Was this translation helpful? Give feedback.
-
Ok, I think I got it all figured out. Firstly, create authorization policy like so opts.AddPolicy("BasicAuth", builder =>
{
builder.AuthenticationSchemes.Add("BasicAuthentication");
builder.RequireAuthenticatedUser();
}); Then when calling app.MapGraphQL("/graphqlbasic").RequireAuthorization("BasicAuth"); Hotchocolate now enforces access to this endpoint as expected... and with the basic authentication provider. No need for an interceptor or anything afaik. |
Beta Was this translation helpful? Give feedback.
-
Greetings. We've currently got hotchocolate integrated with our application and things are generally working pretty great (version 13.3.3).
Our API has 2 authentication providers setup, a proprietary setup.. .and basic. I'd like to have the graphql endpoint be able to use a authentication scheme that is not the default. I've tried marking up the query with the
[Authorize(AuthenticationSchemes="BasicAuthentication")]
as well as going so far to create a custom interceptor and registering that.I registered this with
I'm not even seeing that
OnCreateAsync
fire, always just defaults to the default authentication scheme. Incidentally I do have endpoints and other frameworks that use theBasicAuthentication
scheme and work... but can't seem to get graphql endpoint to default to that (or maybe even just allow both?)The problem is by default the other auth provider is CAS, and requires hitting a central identity server, getting a cookie set, and redirecting back to our app. When I embed bananna cake pop into our .net app, that actually works great... but now we're going to need to remove that from being embedded directly in our app, and just run the standalone bannana cake pop. I'm assuming there is no way to handle redirect and perform the login to get appropriate cookies set.
I was going to conditionally allow this other authentication scheme to allow basic authentication so that we could very easily connect standalone bananna cake pop to our api.
Any ideas would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions