From fab14716e3c50497816972e4627c182e56e1aeca Mon Sep 17 00:00:00 2001 From: Chrisna Aing Date: Mon, 9 Apr 2018 21:00:18 -0700 Subject: [PATCH 1/2] Update README about middleware positioning. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5bd6efa..b4369a5 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ services.register(middlewareConfig) 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 `MiddlewareConfig` to make sure the headers get added to all responses +***Note:*** You should ensure you set the security headers as the last middleware in your `MiddlewareConfig` (i.e., the first middleware to be applied to responses) to make sure the headers get added to all responses. If you want to add your own values, it is easy to do using the factory. For instance, to add a content security policy configuration, just do: From 7d1edc628fc05dea0e62d3c3095e2243fe4a84cf Mon Sep 17 00:00:00 2001 From: Chrisna Aing Date: Mon, 9 Apr 2018 21:08:17 -0700 Subject: [PATCH 2/2] Tweak usage section of README. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b4369a5..f133173 100644 --- a/README.md +++ b/README.md @@ -35,15 +35,15 @@ These headers will *help* prevent cross-site scripting attacks, SSL downgrade at # Usage -To use Vapor Security Headers, just register the middleware with your services and add it to your `MiddlewareConfig`. Vapor Security Headers makes this easy to do with a `builder` function on the factory. In `configure.swift` add: +To use Vapor Security Headers, just register the middleware with your services and add it to your `MiddlewareConfig`. Vapor Security Headers makes this easy to do with a `build` function on the factory. In `configure.swift` add: ```swift -services.register(securityHeadersToAdd.build()) let securityHeadersFactory = SecurityHeadersFactory() +services.register(securityHeadersFactory.build()) var middlewareConfig = MiddlewareConfig() -middlewareConfig.use(SecurityHeaders.self) // ... +middlewareConfig.use(SecurityHeaders.self) services.register(middlewareConfig) ```