aah Security Configuration
aah Security configuration is to configure Authentication, Authorization, Session Management, Secure Headers, Anti-CSRF, etc. The aah config syntax is very similar to HOCON. Learn configuration syntax.
Table of Contents
Section: security { … }
To configure application security configuration such as Auth schemes, Password Encoder, Session, Anti-CSRF, secure HTTP headers.
Section: session { … }
aah session management supports stateful and stateless.
session { ... }
configuration goes under the config section security { ... }
.
Section: http_header { … }
Since v0.8 aah provides response secure headers with many safe defaults. Typically non-empty
header values from configuration gets added into response header.
http_header { ... }
configuration goes under the config section security { ... }
.
Framework writes the secure response headers appropriately based on Content-Type.
Tip:
- Quick way to verify your application secure headers - https://securityheaders.io
- Exclude header from writing, just put
empty string
as a value.
Header: X-XSS-Protection
Designed to enable the cross-site scripting (XSS) filter built into modern web browsers. This is usually enabled by default, but using this header will enforce it.
Learn more:
- https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#xxxsp
- https://www.keycdn.com/blog/x-xss-protection/
Encouraged to make use of header Content-Security-Policy
with enhanced policy to reduce XSS risk along with header X-XSS-Protection
.
Default values is 1; mode=block
.
Header: X-Content-Type-Options
Prevents Content Sniffing or MIME sniffing.
Learn more:
- https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#xcto
- https://en.wikipedia.org/wiki/Content_sniffing
Default value is nosniff
.
Header: X-Frame-Options
Prevents Clickjacking.
Learn more:
- https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#xfo
- https://www.keycdn.com/blog/x-frame-options/
Default value is SAMEORIGIN
.
Header: Referrer-Policy
This header governs which referrer information, sent in the Referer header, should be included with requests made.
Referrer Policy has been a W3C Candidate Recommendation since 26 January 2017.
Learn more:
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
- https://scotthelme.co.uk/a-new-security-header-referrer-policy/
- https://www.w3.org/TR/referrer-policy/
Default value is no-referrer-when-downgrade
.
Header: Strict-Transport-Security (STS, aka HSTS)
STS header that lets a web site tell browsers that it should only be communicated with using HTTPS, instead of using HTTP.
Learn more:
- https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#hsts
- https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security
Note: Framework checks that application uses SSL on startup then applies this header. Otherwise it does not apply.
Header: Content-Security-Policy (CSP)
Provides a rich set of policy directives that enable fairly granular control over the resources that a page is allowed. Prevents XSS risks.
Learn more:
- https://content-security-policy.com/
- https://developers.google.com/web/fundamentals/security/csp/
- https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#csp
Read above references and define your policy.
Note:
- It is highly recommended to verify your policy directives in report only mode before enabling this header. Since its highly controls how your page is rendered.
- Only applied to
prod
environment profile.
No default values, you have to provide it.
Header: Public-Key-Pins (PKP, aka HPKP)
This header prevents the Man-in-the-Middle Attack (MITM) with forged certificates.
Learn more:
- https://scotthelme.co.uk/hpkp-http-public-key-pinning/
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning
Read above references and define your keys.
Note:
- HPKP has the potential to lock out site/users for a long time if used incorrectly! The use of backup certificates and/or pinning the CA certificate is recommended.
- It is highly recommended to verify your PKP in report only mode before enabling this header
- Framework checks that application uses SSL on startup then applies this header. Otherwise it does not apply
- Only applied to
prod
environment profile.
No default values, you have to provide it.
Header: X-Permitted-Cross-Domain-Policies
Restrict Adobe Flash Player’s or PDF documents access via crossdomain.xml, and this header.
Learn more:
- https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#xpcdp
- https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html
Default value is master-only
.