Skip to content

Commit 368ad3a

Browse files
authoredAug 13, 2020
Deprecate the PublicKey feature per latest security best practices. (#74)
Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes.
1 parent 556fb8f commit 368ad3a

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed
 

‎README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ func main() {
3333
ContentTypeNosniff: true,
3434
BrowserXssFilter: true,
3535
ContentSecurityPolicy: "script-src $NONCE",
36-
PublicKey: `pin-sha256="base64+primary=="; pin-sha256="base64+backup=="; max-age=5184000; includeSubdomains; report-uri="https://www.example.com/hpkp-report"`,
3736
})
3837

3938
app := secureMiddleware.Handler(myHandler)
@@ -51,7 +50,6 @@ X-Frame-Options: DENY
5150
X-Content-Type-Options: nosniff
5251
X-XSS-Protection: 1; mode=block
5352
Content-Security-Policy: script-src 'nonce-a2ZobGFoZg=='
54-
PublicKey: pin-sha256="base64+primary=="; pin-sha256="base64+backup=="; max-age=5184000; includeSubdomains; report-uri="https://www.example.com/hpkp-report"
5553
~~~
5654

5755
### Set the `IsDevelopment` option to `true` when developing!
@@ -81,7 +79,7 @@ s := secure.New(secure.Options{
8179
BrowserXssFilter: true, // If BrowserXssFilter is true, adds the X-XSS-Protection header with the value `1; mode=block`. Default is false.
8280
CustomBrowserXssValue: "1; report=https://example.com/xss-report", // CustomBrowserXssValue allows the X-XSS-Protection header value to be set with a custom value. This overrides the BrowserXssFilter option. Default is "".
8381
ContentSecurityPolicy: "default-src 'self'", // ContentSecurityPolicy allows the Content-Security-Policy header value to be set with a custom value. Default is "". Passing a template string will replace `$NONCE` with a dynamic nonce value of 16 bytes for each request which can be later retrieved using the Nonce function.
84-
PublicKey: `pin-sha256="base64+primary=="; pin-sha256="base64+backup=="; max-age=5184000; includeSubdomains; report-uri="https://www.example.com/hpkp-report"`, // PublicKey implements HPKP to prevent MITM attacks with forged certificates. Default is "".
82+
PublicKey: `pin-sha256="base64+primary=="; pin-sha256="base64+backup=="; max-age=5184000; includeSubdomains; report-uri="https://www.example.com/hpkp-report"`, // Deprecated: This feature is no longer recommended. PublicKey implements HPKP to prevent MITM attacks with forged certificates. Default is "".
8583
ReferrerPolicy: "same-origin", // ReferrerPolicy allows the Referrer-Policy header with the value to be set with a custom value. Default is "".
8684
FeaturePolicy: "vibrate 'none';", // FeaturePolicy allows the Feature-Policy header with the value to be set with a custom value. Default is "".
8785
ExpectCTHeader: `enforce, max-age=30, report-uri="https://www.example.com/ct-report"`,

‎secure.go

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type Options struct {
7474
// CustomFrameOptionsValue allows the X-Frame-Options header value to be set with a custom value. This overrides the FrameDeny option. Default is "".
7575
CustomFrameOptionsValue string
7676
// PublicKey implements HPKP to prevent MITM attacks with forged certificates. Default is "".
77+
// Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible.
7778
PublicKey string
7879
// ReferrerPolicy allows sites to control when browsers will pass the Referer header to other sites. Default is "".
7980
ReferrerPolicy string

0 commit comments

Comments
 (0)