rapi-doc / RapiDoc

RapiDoc -WebComponent for OpenAPI Spec
https://rapidocweb.com
MIT License
1.71k stars 285 forks source link

Would it be possible to reload the spec after authentication status changes? #179

Closed bytedreamer closed 4 years ago

bytedreamer commented 4 years ago

The goal is to only show the API endpoints that are authorized. A call to retrieve the spec should include the authorization header so that endpoints could be filtered.

mrin9 commented 4 years ago

we have a similar task on our todo, but thats to annotate (may be disable) the try button. We try not to do any validations, to keep the API testable, for instance

Is there a use-case that you are after ?

bytedreamer commented 4 years ago

Certain calls are restricted based on the user's permissions. We want the user to be able to view only the calls for which they have access.

The workflow for an user accessing the API Documentation:

  1. Page shows no calls, only the OAuth2 section
  2. User logs in using our OAuth2 login page
  3. Successful login will only show the calls that the user has permission

One way to accomplish this is to dynamically create JSON spec file based on user permissions. For this to work, the JSON spec file needs to be reloaded anytime the login status changes. The JSON retrieval also needs to include the OAuth2 bearer token after login.

mrin9 commented 4 years ago

I dont think at present we will be taking that route. but keep an eye on this space, we plan to programmatically allow hide certain paths. once we provide that feature you can do it at your end. I will provide an event when a auth-key is applied, that will help you do what you exactly want.