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

Authorization annotations #458

Open
bkostrowiecki opened this issue Jul 24, 2024 · 0 comments
Open

Authorization annotations #458

bkostrowiecki opened this issue Jul 24, 2024 · 0 comments
Labels
community Something initiated by the community enhancement New feature or request

Comments

@bkostrowiecki
Copy link

bkostrowiecki commented Jul 24, 2024

Is your feature request related to a problem? Please describe.
I would like to generate resolvers with @Authorized decorators so generated API is protected by unauthorized access.

Describe the solution you'd like
I would like to have annotaions that add @Authorized decorator to resolvers. For example:

/// @TypeGraphQL.Authorized(create:'admin,editor', read:null, update:'admin,editor', delete:'admin')
model Post {
/* ... */
}

Given example should result in:

  • create resolver accepts admin and editor role
  • read resolver accepts all users, even unauthorized
  • update resolve accepts admin and editor role
  • delete accepts only admin role.

Describe alternatives you've considered

  • using 3rd party library to add authorization for resolvers as middleware.
  • adding @Authorized decorator manually to generated resolvers. All of them are lost after regenerating the code, so it's the worst solution.
@MichalLytek MichalLytek added enhancement New feature or request community Something initiated by the community labels Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Something initiated by the community enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants