Skip to content
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

Let .AddAuthorization work with PolicyProviders #297

Open
Shentoza opened this issue Nov 6, 2024 · 3 comments
Open

Let .AddAuthorization work with PolicyProviders #297

Shentoza opened this issue Nov 6, 2024 · 3 comments

Comments

@Shentoza
Copy link

Shentoza commented Nov 6, 2024

When using .AddAuthorization it would be great that it would be able to access IAuthorizationPolicyProvider instead of having to add every Policy manually. Currently I don't think that's really possible , which makes it hard to dynamically set some new policies without registering them all beforehand.

or is that one of the limitations mentioned that it doesn't properly use the "Microsoft.AspNetCore.Authorization" features?

@Shane32
Copy link
Member

Shane32 commented Nov 6, 2024

Yeah it’s supposed to be independent. Why don’t you try the authorization library included in GraphQL.Server.Transports.AspNetCore instead? It uses policies defined by ASP.Net Core and has a fuller feature set within GraphQL as well. Plus it’s pretty customizable if you need special behavior.

@Shentoza
Copy link
Author

Shentoza commented Nov 6, 2024

I looked into that and that's what im doing now. I wasn't quite sure where the boundaries of the Asp .NET auth features and GraphQL .NET were, but that makes sense. e.g. The "AuthorizationAttribute" is simply not a from the auth package but rather a GraphQL Attribute, which is what I got wrong, but hoped to extend easily

@Shane32
Copy link
Member

Shane32 commented Nov 6, 2024

Sounds good. Check the docs at https://github.com/graphql-dotnet/server?tab=readme-ov-file#authorization-configuration for details on:

  • configuration
  • transport-level rules
  • schema/type/field-level rules
  • websocket auth
  • auth schemes
  • different auth for get vs post
  • allowing anonymous auth for introspection or other fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants