Skip to content

Commit

Permalink
Tidy up the README for release
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTim committed May 18, 2017
1 parent d7376b9 commit c79a967
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ To use Vapor Security Headers, just add the middleware to your `Config` and then

```swift
let config = Config()
let securityHeadersFactory = SecurityHeadersFactory()
config.addConfigurable(middleware: securityHeadersFactory.builder(), name: "security-headers"))
let drop = Droplet(config)
```

The default factory will add default values to your site for Content-Security-Policy, X-XSS-Protection, X-Frame-Options and X-Content-Type-Options.

***Note:*** You should ensure you set the security headers as the first middleware in your `droplet.json` to make sure the headers get added to all responses:

```json
Expand All @@ -53,8 +56,6 @@ let cspConfig = ContentSecurityPolicyConfiguration(value: cspValue)
let securityHeadersMiddlewareFactory = SecurityHeadersFactory().with(contentSecurityPolicy: cspConfig)
```

***Note: The `SecurityHeaders` middleware should be the first item in the `droplet.json` middleware array so that the headers are added to every response.***

You will need to add it as a dependency in your `Package.swift` file:

```swift
Expand All @@ -64,16 +65,18 @@ dependencies: [
]
```

This will add default values to your site for Content-Security-Policy, X-XSS-Protection, X-Frame-Options and X-Content-Type-Options. If you are running an API you can choose a default configuration for that by creating it with:
Each different header has its own configuration and options, details of which can be found below.

You can test your site by visiting the awesome [Security Headers](https://securityheaders.io) (no affiliation) websites

## API Headers

If you are running an API you can choose a default configuration for that by creating it with:

```swift
let securityHeaders = SecurityHeadersFactory.api()
```

Each different header has its own configuration and options, details of which can be found below.

You can test your site by visiting the awesome [Security Headers](https://securityheaders.io) (no affiliation) websites

## Manual Initialisation

You can also build the middleware manually like so:
Expand All @@ -95,9 +98,9 @@ The following features are on the roadmap to be implemented:

If you are running Vapor on it's own (i.e. not as a CGI application or behind and reverse proxy) then you do not need to do anything more to get it running!

## Nginx and Apache
## Nginx, Apache and 3rd Party Services

Both web servers should pass on the response headers from Vapor without issue when running as a reverse proxy.
Both web servers should pass on the response headers from Vapor without issue when running as a reverse proxy. Some servers and providers (such as Heroku) will inject their own headers or block certain headers (such as HSTS to stop you locking out their whole site). You will need to check with your provider to see what is enabled and allowed.

# Security Header Information

Expand Down

0 comments on commit c79a967

Please sign in to comment.