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

Commit f05a055

Browse files
Merge pull request #8 from nodes-vapor/feature/remove-ssl-functionality
Feature/remove ssl functionality
2 parents d3f8221 + e43bde9 commit f05a055

File tree

3 files changed

+2
-103
lines changed

3 files changed

+2
-103
lines changed

README.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![Readme Score](http://readme-score-api.herokuapp.com/score.svg?url=https://github.com/nodes-vapor/gatekeeper)](http://clayallsopp.github.io/readme-score?url=https://github.com/nodes-vapor/gatekeeper)
99
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nodes-vapor/gatekeeper/master/LICENSE)
1010

11-
Rate Limiter and SSL enforcing middleware.
11+
Rate Limiter middleware.
1212

1313

1414
## 📦 Installation
@@ -21,33 +21,6 @@ Update your `Package.swift` file.
2121

2222
## Getting started 🚀
2323

24-
Both the rate limiter and SSL-enforcing middleware are easy to configure and get running.
25-
26-
27-
## SSLEnforcer 🔒
28-
29-
`SSLEnforcer` has three configurable fields: the error to be thrown, your `Droplet` and the environments you wish to enforce on. The environments defaults to `[.production]`.
30-
```swift
31-
let drop = Droplet()
32-
// this will only enforce if running in `production` mode.
33-
let enforcer = SSLEnforcer(error: Abort.notFound, drop: drop)
34-
```
35-
36-
If you wish to secure your endpoints during development you can do the following:
37-
```swift
38-
let enforcer = SSLEnforcer(
39-
error: Abort.notFound,
40-
drop: drop,
41-
environments: [
42-
.production,
43-
.development
44-
]
45-
)
46-
```
47-
48-
49-
## RateLimiter ⏱
50-
5124
`RateLimiter` has two configurable fields: the maximum rate and the cache to use. If you don't supply your own cache the limiter will create its own, in-memory cache.
5225

5326
```swift
@@ -64,7 +37,6 @@ case .hour
6437
case .day
6538
```
6639

67-
6840
## Credits 🏆
6941

7042
This package is developed and maintained by the Vapor team at [Nodes](https://www.nodes.dk).

Sources/SSLEnforcer.swift

Lines changed: 0 additions & 28 deletions
This file was deleted.

Tests/GatekeeperTests/GatekeeperTests.swift

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ class GatekeeperTests: XCTestCase {
1212
("testRateLimiter", testRateLimiter),
1313
("testRateLimiterNoPeer", testRateLimiterNoPeer),
1414
("testRateLimiterCountRefresh", testRateLimiterCountRefresh),
15-
("testSSLEnforcerBasic", testSSLEnforcerBasic),
16-
("testSSLEnforcerDenied", testSSLEnforcerDenied),
17-
("testSSLEnforcerDoNotEnforce", testSSLEnforcerDoNotEnforce),
1815
("testRefreshIntervalValues", testRefreshIntervalValues),
1916
]
2017

@@ -86,49 +83,7 @@ class GatekeeperTests: XCTestCase {
8683
requestsLeft = try! middleware.cache.get("192.168.1.2")?["requestsLeft"]?.int
8784
XCTAssertEqual(requestsLeft, 99, "Requests left should've reset")
8885
}
89-
90-
func testSSLEnforcerBasic() {
91-
let middleware = SSLEnforcer(error: Abort.badRequest, drop: productionDrop)
92-
let request = getHTTPSRequest()
93-
94-
do {
95-
_ = try middleware.respond(to: request, chainingTo: MockResponder())
96-
} catch {
97-
XCTFail("Request failed: \(error)")
98-
}
99-
}
100-
101-
func testSSLEnforcerDenied() {
102-
let middleware = SSLEnforcer(error: Abort.badRequest, drop: productionDrop)
103-
let request = getHTTPRequest()
104-
105-
do {
106-
_ = try middleware.respond(to: request, chainingTo: MockResponder())
107-
XCTFail("Should've been rejected")
108-
} catch let error as Abort {
109-
switch error.status {
110-
case .badRequest:
111-
// success
112-
break
113-
default:
114-
XCTFail("Expected bad request")
115-
}
116-
} catch {
117-
XCTFail("Request failed: \(error)")
118-
}
119-
}
120-
121-
func testSSLEnforcerDoNotEnforce() {
122-
let middleware = SSLEnforcer(error: Abort.badRequest, drop: developmentDrop)
123-
let request = getHTTPSRequest()
124-
125-
do {
126-
_ = try middleware.respond(to: request, chainingTo: MockResponder())
127-
} catch {
128-
XCTFail("SSL should not have been enforced for development.")
129-
}
130-
}
131-
86+
13287
func testRefreshIntervalValues() {
13388
let expected: [(Rate.Interval, Double)] = [
13489
(.second, 1),

0 commit comments

Comments
 (0)