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

hide route based on user scope ? #631

Open
2 tasks done
x-077 opened this issue Jul 6, 2022 · 3 comments
Open
2 tasks done

hide route based on user scope ? #631

x-077 opened this issue Jul 6, 2022 · 3 comments

Comments

@x-077
Copy link

x-077 commented Jul 6, 2022

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Hello,

Let say an app have 3 scope of permission ( user / moderator / admin ) . Is there a way to hide the route that a user is not supposed to use ?

For example, someone with admin scope could see all the routes while someone with moderator or user would have a limited view ?

Thanks

@mcollina
Copy link
Member

mcollina commented Jul 6, 2022

I don't think this is possible at the moment. However, it would be a good feature to add some hooks for customizing the definition on the fly.

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@x-077
Copy link
Author

x-077 commented Jul 7, 2022

hello @mcollina ,

I can try but I'm not really familiar with this plugin or swagger/openapi in general.

Looking at the code, I was wondering if it could not be possible to do it in the shouldRouteHide method.

I did not spend enough time yet reading the code, so Im not sure if that method is call at runtime/fly or prior fastify start ( like a plugin would do
when calling register(....) ).

@mcollina
Copy link
Member

mcollina commented Jul 7, 2022

That'd be where I would put this logic. However it requires some refactoring to get this implemented.

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