graphql-platform
graphql-platform copied to clipboard
WIP: Translate `Microsoft.AspNetCore.Authorization.AuthorizeAttribute` to `@authorize` directive
Adds a new TypeInterceptor that is automatically registered when calling AddAuthorize
to translate the Microsoft.AspNetCore.Authorization.AuthorizeAttribute
to the @authorize
directive.
This could be a breaking change for existing schemas, if Microsoft's AuthorizeAttribute
was used by accident instead of Hot Chocolate's AuthorizeAttribute
. But it will also prevent these accidental mixups in the future, by just providing the same functionality consistently. I thought about making the Hot Chocolate AuthorizeAttribute
obsolete, but there are still valid use cases like AFTER_RESOLVER
and also the limitation of not being able to specify the Microsoft attribute on properties.
Closes #3847
Todos
- Infer attribute from type extensions
Outlook
I would like to add AuthenticationSchemes
to the @authorize
directive (and all APIs around it) to allow the use of multiple authentication schemes.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@tobias-tengler how far was this PR ? :)
@tobias-tengler how far was this PR ? :)
I think it was almost done, except for some todos in the code and the missing ability to convert the Microsoft attribute, when it was applied on a type extension. I think it was tricky, because the type interceptor could not see the original CLR types where the extended field was coming from, so the attribute on the type can not be read. I think there should be a failing test.