Skip to content

Commit

Permalink
feat(headers): Add strict-origin and strict-origin-when-cross-origin …
Browse files Browse the repository at this point in the history
…referer policy

Support for strict-origin and strict-origin-when-cross-origin in referer
policy required for imporving network security. This commit will attempt
to add missing pieces of referrer policy.
  • Loading branch information
nmvk authored and seanmonstar committed Oct 31, 2016
1 parent dc47665 commit 1be4e76
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/header/common/referrer_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ pub enum ReferrerPolicy {
OriginWhenCrossOrigin,
/// `unsafe-url`
UnsafeUrl,
/// `strict-origin`
StrictOrigin,
///`strict-origin-when-cross-origin`
StrictOriginWhenCrossOrigin,
}

impl Header for ReferrerPolicy {
Expand All @@ -65,6 +69,8 @@ impl Header for ReferrerPolicy {
"same-origin" => return Ok(SameOrigin),
"origin" => return Ok(Origin),
"origin-when-cross-origin" => return Ok(OriginWhenCrossOrigin),
"strict-origin" => return Ok(StrictOrigin),
"strict-origin-when-cross-origin" => return Ok(StrictOriginWhenCrossOrigin),
"unsafe-url" | "always" => return Ok(UnsafeUrl),
_ => continue,
}
Expand All @@ -83,6 +89,8 @@ impl HeaderFormat for ReferrerPolicy {
SameOrigin => "same-origin",
Origin => "origin",
OriginWhenCrossOrigin => "origin-when-cross-origin",
StrictOrigin => "strict-origin",
StrictOriginWhenCrossOrigin => "strict-origin-when-cross-origin",
UnsafeUrl => "unsafe-url",
})
}
Expand Down

0 comments on commit 1be4e76

Please sign in to comment.