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

Schema details page: embed Swagger-UI #118

Closed
ronytw opened this issue Dec 23, 2021 · 5 comments
Closed

Schema details page: embed Swagger-UI #118

ronytw opened this issue Dec 23, 2021 · 5 comments
Assignees

Comments

@ronytw
Copy link
Contributor

ronytw commented Dec 23, 2021

Expected behaviour

In the Schema details page, we'd like to see the content rendered in a dedicated swagger-ui section. The OAS3 specification to be rendered comes from the downloadUrl of the distribution associated with the Schema.

Current behaviour

No swagger-ui component is embedded. This is an enhancement.

Proposed solution

Context

For who has access to the "NDC_mvp" Zeplin project, this is the link to the mock-up.

@ronytw
Copy link
Contributor Author

ronytw commented Dec 29, 2021

We're encountering an issue with CORS: the Swagger-UI component is meant to retrieve the yaml or json specification content from a different server than the one which served the original Javascript.
The following are the next steps:

  1. Understand whether it is possible to restrict the Cross Origin requests to Content-Type for JSON (and YAML). Apparently github returns text/plain for the sample yaml file.
  2. Understand whether this is a security issue: downloading arbitrary application/json and text/plain content from other websites. Regardless of the content-type being returned, we're potentially causing server side logic to execute for our request.
  3. If we're happy with the previous steps, understand how to configure this both on NGINX (for the container) and for the local server (Node.js based) used for development.

@ioggstream

@ioggstream
Copy link
Contributor

CC: @bfabio @berez23 for security considerations and solutions related to node/js.

  1. if the current use cases works, it's ok. Consider that yaml has not a standardized media-type yet;

2a. Currently developers.italia.it/it/api uses swagger-ui, where files are only processed on browsers and not on servers.
Using "safe" parsers (eg. that do not instatiate classes ... ) and OAS validators should provide basic guarantees that OAS/schema files are not going to execute arbitrary code.
2b. In general, I do not expect js to be able to be executed server-side: all the schema rendering process should happen in browsers;
2c. It could happen that, if there's a bug somewhere, an attacker capable of injecting a file into an administration repository could trigger the client to make requests to NDC: those requests should always be unauthenticated and public.

  1. I think REST APIs should have CORS enabled (eg. see the playground api ). Should the rest of the website allow CORS instead?

@ronytw
Copy link
Contributor Author

ronytw commented Dec 30, 2021

@ronytw
Copy link
Contributor Author

ronytw commented Dec 30, 2021

Please @spuliz @ioggstream , can you review the linked page and, once the security questions have been answered, this issue can be closed.

@ioggstream
Copy link
Contributor

fixed. See #127 for further improvements.

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

3 participants