Skip to content

Commit 081f53d

Browse files
committed
explain CORS and OWASP usage
1 parent aa9c37c commit 081f53d

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ Options:
6161
#### Model Details
6262
* [Models](#models)
6363
* [Notes on Schemas](#notes-on-schemas)
64+
#### Response Headers
65+
* [CORS](#cors)
66+
* [OWASP Secure Headers](#owasp)
6467

6568
### OpenAPI Mapping
6669

@@ -729,6 +732,80 @@ You can automatically generate CORS response headers by setting `cors` at the fu
729732

730733
The generator will interpret your settings for CORS and automatically add the response headers. If for whatever reason you wish to override these, you can set them via the above `responseHeaders` setting and it'll apply your overrides.
731734

735+
##### OWASP
736+
737+
You can make use of the [OWASP Secure Headers](https://owasp.org/www-project-secure-headers/#x-permitted-cross-domain-policies) to generate response headers. These are a selection of response headers with default values that OWASP recommends returning with your response to help secure your application.
738+
739+
The OWASP Secure Headers Project contains a set of recommended headers to return with recommended values, when generating the documentation, the generator will attempt to get the latest version of this document and apply the latest recommendations. If you do not allow outside connections, it will default to a version of recommendations from **2023-05-26 12:22:30 UTC**.
740+
741+
Like CORS, if you have already set any of the OWASP Secure headers via `responseHeaders`, it will not overwrite them.
742+
743+
To make use of OWASP Secure Headers, you can use the following:
744+
745+
###### All OWASP Secure Headers
746+
747+
```yml
748+
methodResponse:
749+
- statusCode: 200
750+
responseBody:
751+
description: Success
752+
responseModels:
753+
application/json: "CreateResponse"
754+
owasp: true
755+
```
756+
757+
This will use the full set of OWASP Secure Headers and their recommended values. Some of these might not be appropriate for your application.
758+
759+
###### Subset of OWASP Secure Headers
760+
761+
```yml
762+
methodResponse:
763+
- statusCode: 200
764+
responseBody:
765+
description: Success
766+
responseModels:
767+
application/json: "CreateResponse"
768+
owasp:
769+
cacheControl: true
770+
referrerPolicy: true
771+
```
772+
773+
This will set only the `cacheControl` and `referrerPolicy` response header with the default recommendations.
774+
775+
The full list of OWASP Secure Headers you can set are:
776+
777+
* cacheControl - Cache-Control,
778+
* clearSiteData - Clear-Site-Data,
779+
* contentSecurityPolicy - Content-Security-Policy,
780+
* crossOriginEmbedderPolicy - Cross-Origin-Embedder-Policy,
781+
* crossOriginOpenerPolicy - Cross-Origin-Opener-Policy,
782+
* crossOriginResourcePolicy - Cross-Origin-Resource-Policy,
783+
* permissionsPolicy - Permissions-Policy,
784+
* pragma - Pragma,
785+
* referrerPolicy - Referrer-Policy,
786+
* strictTransportSecurity - Strict-Transport-Security,
787+
* xContentTypeOptions - X-Content-Type-Options,
788+
* xFrameOptions - X-Frame-Options,
789+
* xPermittedCrossDomainPolicies - X-Permitted-Cross-Domain-Policies
790+
791+
###### Subset of OWASP Secure Headers with user defined values
792+
793+
If you wish to override the OWASP Secure Headers, you can write your `methodResponse` like:
794+
795+
```yml
796+
methodResponse:
797+
- statusCode: 200
798+
responseBody:
799+
description: Success
800+
responseModels:
801+
application/json: "CreateResponse"
802+
owasp:
803+
cacheControl:
804+
value: no-store
805+
```
806+
807+
This will set the `Cache-Control` Response Header to have a value of "no-store" rather than any value the OWASP Secure Headers Project recommends.
808+
732809
## Example configuration
733810

734811
Please view the example [serverless.yml](test/serverless-tests/serverless%202/serverless.yml).

0 commit comments

Comments
 (0)