Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 165ac94

Browse files
authored
Merge pull request #8064 from magento/db_swagger_docs
Adds information about securing the Swagger endpoint
2 parents fb2c541 + 3b62b34 commit 165ac94

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

src/guides/v2.3/rest/generate-local.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ To view the Swagger documentation for a specific store view, use this URL:
2121

2222
The value of `store_code` must be one of the following:
2323

24-
* `default`
25-
* The assigned store code
26-
* `all`. This value only applies to the [CMS](https://glossary.magento.com/cms) and Product modules. If this value is specified, the API call affects all the merchant's stores.
24+
- `default`
25+
- The assigned store code
26+
- `all`. This value only applies to the [CMS](https://glossary.magento.com/cms) and Product modules. If this value is specified, the API call affects all the merchant's stores.
2727

2828
By default, Magento returns documentation for resources available to anonymous users across all stores. If you specify a valid value in the `api_key` text box in the upper right corner, Swagger returns documentation for all the endpoints the user has access to. To generate an API key, call the `POST /V1/integration/customer/token` or `POST /V1/integration/admin/token` as directed in [Token-based authentication]({{ page.baseurl }}/get-started/authentication/gs-authentication-token.html).
2929

@@ -63,7 +63,25 @@ To return the complete JSON schema, specify the `?services=all` parameter in the
6363

6464
The base URL for returning the asynchronous schema is `http://<magento_host>/rest/<store_code>/async/schema`.
6565

66+
## Security
67+
68+
By default, the `/swagger` endpoint is open on Magento instances. Leaving it open on a public instance could potentially expose system information that should not be readable.
69+
70+
To close off the `/swagger` endpoint, disable the following modules:
71+
72+
- Swagger
73+
- SwaggerWebapi
74+
- SwaggerWebapiAsync
75+
76+
To ensure proper functionality, always test Magento instances after disabling modules.
77+
78+
You may also use web server rewrite rules to redirect users trying to access the endpoint:
79+
80+
- [nginx rewrite module](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite)
81+
- [apache mod_rewrite](https://httpd.apache.org/docs/2.4/rewrite/)
82+
6683
{:.ref-header}
6784
Related topics
6885

86+
[Restricting access to anonymous web APIs]({{ page.baseurl }}/rest/anonymous-api-security.html)
6987
[Token-based authentication]({{ page.baseurl }}/get-started/authentication/gs-authentication-token.html)

src/guides/v2.4/rest/generate-local.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ To view the Swagger documentation for a specific store view, use this URL:
2121

2222
The value of `store_code` must be one of the following:
2323

24-
* `default`
25-
* The assigned store code
26-
* `all`. This value only applies to the [CMS](https://glossary.magento.com/cms) and Product modules. If this value is specified, the API call affects all the merchant's stores.
24+
- `default`
25+
- The assigned store code
26+
- `all`. This value only applies to the [CMS](https://glossary.magento.com/cms) and Product modules. If this value is specified, the API call affects all the merchant's stores.
2727

2828
By default, Magento returns documentation for resources available to anonymous users across all stores. If you specify a valid customer or admin token in the `api_key` text box in the upper right corner, Swagger returns documentation for all the endpoints the user has access to. To generate an API key, call the `POST /V1/integration/customer/token` endpoint or a 2FA endpoint such as `POST /V1/tfa/provider/google/authenticate` with the appropriate payload, as directed in [Token-based authentication]({{ page.baseurl }}/get-started/authentication/gs-authentication-token.html).
2929

@@ -60,7 +60,25 @@ To return the complete JSON schema, specify the `?services=all` parameter in the
6060

6161
The base URL for returning the asynchronous schema is `http://<magento_host>/rest/<store_code>/async/schema`.
6262

63+
## Security
64+
65+
By default, the `/swagger` endpoint is open on Magento instances. Leaving it open on a public instance could potentially expose system information that should not be readable.
66+
67+
To close off the `/swagger` endpoint, disable the following modules:
68+
69+
- Swagger
70+
- SwaggerWebapi
71+
- SwaggerWebapiAsync
72+
73+
To ensure proper functionality, always test Magento instances after disabling modules.
74+
75+
You may also use web server rewrite rules to redirect users trying to access the endpoint:
76+
77+
- [nginx rewrite module](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite)
78+
- [apache mod_rewrite](https://httpd.apache.org/docs/2.4/rewrite/)
79+
6380
{:.ref-header}
6481
Related topics
6582

83+
[Restricting access to anonymous web APIs]({{ page.baseurl }}/rest/anonymous-api-security.html)
6684
[Token-based authentication]({{ page.baseurl }}/get-started/authentication/gs-authentication-token.html)

0 commit comments

Comments
 (0)