-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from brokenhandsio/ReferrerPolicy
Referrer policy
- Loading branch information
Showing
5 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Sources/VaporSecurityHeaders/Configurations/ReferrerPolicyConfiguration.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import HTTP | ||
|
||
public struct ReferrerPolicyConfiguration: SecurityHeaderConfiguration { | ||
|
||
public enum Options: String { | ||
case empty = "" | ||
case noReferrer = "no-referrer" | ||
case noReferrerWhenDowngrade = "no-referrer-when-downgrade" | ||
case sameOrigin = "same-origin" | ||
case origin = "origin" | ||
case strictOrigin = "strict-origin" | ||
case originWhenCrossOrigin = "origin-when-cross-origin" | ||
case strictOriginWhenCrossOrigin = "strict-origin-when-cross-origin" | ||
case unsafeUrl = "unsafe-url" | ||
} | ||
|
||
private let option: Options | ||
|
||
public init(_ option: Options) { | ||
self.option = option | ||
} | ||
|
||
func setHeader(on response: Response) { | ||
response.headers[HeaderKey.referrerPolicy] = option.rawValue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters