WORKERS AHEAD!
You are viewing the development documentation for the Apereo CAS server. The functionality presented here is not officially released yet. This is a work in progress and will be continually updated as development moves forward. You are most encouraged to test the changes presented.
Service HTTP Security Headers
CAS has ability to control, on a per-service basis, whether certain security-related HTTP headers should be injected into the response. While headers are typically enabled and defined globally as part of the CAS Security Filter, the strategy described here allows one to disable/enable the injection of these headers for certain applications and service requests and override the global defaults.
Global Configuration
The following settings and properties are available from the CAS configuration catalog:
cas.http-web-request.cors.enabled=false
Whether CORS should be enabled for http requests.
|
cas.http-web-request.header.enabled=true
Allow CAS to inject and enforce http security headers via an http filter that are outlined here for caching, HSTS, etc.
|
cas.http-web-request.allow-multi-value-parameters=false
Whether CAS should accept multi-valued parameters in incoming requests. Example block would to prevent requests where more than one
|
cas.http-web-request.characters-to-forbid=none
Characters to block in incoming requests.
|
cas.http-web-request.cors.allow-credentials=true
The Access-Control-Allow-Credentials header Indicates whether or not the response to the request can be exposed when the credentials flag is true. When used as part of a response to a preflight request, this indicates whether or not the actual request can be made using credentials. Note that simple GET requests are not preflighted, and so if a request is made for a resource with credentials, if this header is not returned with the resource, the response is ignored by the browser and not returned to web content.
|
cas.http-web-request.cors.allow-headers=
The Access-Control-Allow-Headers header is used in response to a preflight request to indicate which HTTP headers can be used when making the actual request. Default is everything.
|
cas.http-web-request.cors.allow-methods=
The Access-Control-Allow-Methods header specifies the method or methods allowed when accessing the resource. This is used in response to a pre-flight request. The conditions under which a request is pre-flighted are discussed above. Default is everything.
|
cas.http-web-request.cors.allow-origin-patterns=
Comma-separated list of origin patterns to allow. Unlike allowed origins which only supports
|
cas.http-web-request.cors.allow-origins=
The Origin header indicates the origin of the cross-site access request or preflight request. The origin is a URI indicating the server from which the request initiated. When credentials are allowed, '*' cannot be used and origin patterns should be configured instead. It does not include any path information, but only the server name.
|
cas.http-web-request.cors.exposed-headers=
The Access-Control-Expose-Headers header lets a server accept headers that browsers are allowed to access.
|
cas.http-web-request.cors.max-age=3600
The Access-Control-Max-Age header indicates how long the results of a preflight request can be cached.
|
cas.http-web-request.custom-headers=
Custom response headers to inject into the response as needed.
|
cas.http-web-request.header.cache=true
When true, will inject the following headers into the response for non-static resources. Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: 0
|
cas.http-web-request.header.cache-control-static-resources=css|js|png|txt|jpg|ico|jpeg|bmp|gif
Files with these extensions are considered static, so they will be cached by browsers. The value is part of a RegEx. This settings supports regular expression patterns. [?].
|
cas.http-web-request.header.content-security-policy=script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.googletagmanager.com https://www.google.com; object-src 'none'; worker-src 'self' blob: 'unsafe-inline';
Helps you reduce XSS risks on modern browsers by declaring what dynamic resources are allowed to load via a HTTP Header. Header value is made up of one or more directives. Multiple directives are separated with a semicolon. @nonce@ is a specific value which is replaced by a generated random value saved as the request attribute 'contentSecurityPolicyGeneratedNonce'. This setting supports the Spring Expression Language.
|
cas.http-web-request.header.hsts=true
When true, will inject the following headers into the response:
|
cas.http-web-request.header.hsts-options=max-age=15768000 ; includeSubDomains
Control the value of the
|
cas.http-web-request.header.xcontent=true
When true, will inject the following headers into the response:
|
cas.http-web-request.header.xframe=true
When true, will inject the following headers into the response:
|
cas.http-web-request.header.xframe-options=DENY
Will inject values into the
|
cas.http-web-request.header.xss=true
When true, will inject the following headers into the response:
|
cas.http-web-request.header.xss-options=1; mode=block
Will inject values into the
|
cas.http-web-request.only-post-params=password
Parameters that are only allowed and accepted during posts.
|
cas.http-web-request.params-to-check=ticket,service,renew,gateway,warn,method,target,SAMLart,pgtUrl,pgt,pgtId,pgtIou,targetService,entityId,token
Parameters to sanitize and cross-check in incoming requests. Separate parameter names by a comma. The special value * instructs the Filter to check all parameters.
|
cas.http-web-request.pattern-to-block=
Specify a regular expression that would be checked against the request URL. If a successful match is found, the request would be blocked. This settings supports regular expression patterns. [?].
|
cas.http-web-request.web.encoding=
Control and specify the encoding for all http requests.
|
cas.http-web-request.web.force-encoding=true
Whether specified encoding should be forced for every request. Whether the specified encoding is supposed to override existing request and response encodings
|
Configuration Metadata
The collection of configuration properties listed in this section are automatically generated from the CAS source and components that contain the actual field definitions, types, descriptions, modules, etc. This metadata may not always be 100% accurate, or could be lacking details and sufficient explanations.
Be Selective
This section is meant as a guide only. Do NOT copy/paste the entire collection of settings into your CAS configuration; rather pick only the properties that you need. Do NOT enable settings unless you are certain of their purpose and do NOT copy settings into your configuration only to keep them as reference. All these ideas lead to upgrade headaches, maintenance nightmares and premature aging.
YAGNI
Note that for nearly ALL use cases, declaring and configuring properties listed here is sufficient. You should NOT have to explicitly massage a CAS XML/Java/etc configuration file to design an authentication handler, create attribute release policies, etc. CAS at runtime will auto-configure all required changes for you. If you are unsure about the meaning of a given CAS setting, do NOT turn it on without hesitation. Review the codebase or better yet, ask questions to clarify the intended behavior.
Naming Convention
Property names can be specified in very relaxed terms. For instance cas.someProperty
, cas.some-property
, cas.some_property
are all valid names. While all
forms are accepted by CAS, there are certain components (in CAS and other frameworks used) whose activation at runtime is conditional on a property value, where
this property is required to have been specified in CAS configuration using kebab case. This is both true for properties that are owned by CAS as well as those
that might be presented to the system via an external library or framework such as Spring Boot, etc.
When possible, properties should be stored in lower-case kebab format, such as cas.property-name=value
.
The only possible exception to this rule is when naming actuator endpoints; The name of the
actuator endpoints (i.e. ssoSessions
) MUST remain in camelCase mode.
Settings and properties that are controlled by the CAS platform directly always begin with the prefix cas
. All other settings are controlled and provided
to CAS via other underlying frameworks and may have their own schemas and syntax. BE CAREFUL with
the distinction. Unrecognized properties are rejected by CAS and/or frameworks upon which CAS depends. This means if you somehow misspell a property definition
or fail to adhere to the dot-notation syntax and such, your setting is entirely refused by CAS and likely the feature it controls will never be activated in the
way you intend.
Validation
Configuration properties are automatically validated on CAS startup to report issues with configuration binding, specially if defined CAS settings cannot be recognized or validated by the configuration schema. Additional validation processes are also handled via Configuration Metadata and property migrations applied automatically on startup by Spring Boot and family.
Indexed Settings
CAS settings able to accept multiple values are typically documented with an index, such as cas.some.setting[0]=value
. The index [0]
is meant to be
incremented by the adopter to allow for distinct multiple configuration blocks.
Service HTTP Headers
The following properties are available and recognized by CAS for various modules and features:
Name | Default Value | Type | Group |
---|---|---|---|
httpHeaderEnableCacheControl
|
true
|
BOOLEAN
|
HTTP_HEADERS
|
httpHeaderEnableXContentOptions
|
true
|
BOOLEAN
|
HTTP_HEADERS
|
httpHeaderEnableStrictTransportSecurity
|
true
|
BOOLEAN
|
HTTP_HEADERS
|
httpHeaderStrictTransportSecurity
|
|
STRING
|
HTTP_HEADERS
|
httpHeaderEnableXFrameOptions
|
true
|
BOOLEAN
|
HTTP_HEADERS
|
httpHeaderXFrameOptions
|
DENY
|
STRING
|
HTTP_HEADERS
|
httpHeaderEnableContentSecurityPolicy
|
true
|
STRING
|
HTTP_HEADERS
|
httpHeaderEnableXSSProtection
|
true
|
BOOLEAN
|
HTTP_HEADERS
|
A sample JSON file follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
{
"@class" : "org.apereo.cas.services.CasRegisteredService",
"serviceId" : "^https://.+",
"name" : "sample service",
"id" : 100,
"properties" : {
"@class" : "java.util.HashMap",
"httpHeaderEnableXContentOptions" : {
"@class" : "org.apereo.cas.services.DefaultRegisteredServiceProperty",
"values" : [ "java.util.HashSet", [ "true" ] ]
}
}
}
CORS Policies
Cross-origin resource sharing (CORS) policies can also be defined per application in form of service properties.
The following properties are available and recognized by CAS for various modules and features:
Name | Default Value | Type | Group |
---|---|---|---|
corsAllowCredentials
|
false
|
BOOLEAN
|
CORS
|
corsMaxAge
|
|
INTEGER
|
CORS
|
corsAllowedOrigins
|
|
STRING
|
CORS
|
corsAllowedOriginPatterns
|
|
STRING
|
CORS
|
corsAllowedMethods
|
|
STRING
|
CORS
|
corsAllowedHeaders
|
|
STRING
|
CORS
|
corsExposedHeaders
|
|
STRING
|
CORS
|
A sample JSON file follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
{
"@class" : "org.apereo.cas.services.CasRegisteredService",
"serviceId" : "^https://.+",
"name" : "sample service",
"id" : 100,
"properties" : {
"@class" : "java.util.HashMap",
"corsMaxAge" : {
"@class" : "org.apereo.cas.services.DefaultRegisteredServiceProperty",
"values" : [ "java.util.HashSet", [ "1000" ] ]
}
}
}