SAML 2.0 single sign-on support for Fess.
This plugin provides the authenticator behind sso.type=saml, which is what makes Fess act as a
SAML service provider. It answers the three endpoints SsoAction routes to it:
/sso/starts the login by redirecting to the IdP, and is also the assertion consumer service the IdP posts the assertion back to/sso/metadatapublishes the SP metadata, which is what the IdP is registered from/sso/logoutis the single logout service
It was part of the Fess distribution until 15.9. It moved here with saml4j and Apache Santuario, jars that an installation authenticating any other way never loads.
Only SP-initiated login is supported. Every SAML response is bound to the ID of the AuthnRequest
Fess sent, so an unsolicited (IdP-initiated) response has nothing to match against and is refused;
point an IdP-side tile at /sso/ instead.
$ bin/fess-setup install plugin fess-sso-saml
Or download the jar from maven.codelibs.org
and put it in app/WEB-INF/plugin. Restart Fess afterwards: the components this plugin
contributes are read when the DI container is built.
Set these in the admin general page, or write them into app/WEB-INF/conf/system.properties, which
is the file that page saves to. Not fess_config.properties. They can also be given
outside the file.
| Key | Value |
|---|---|
sso.type |
saml |
saml.idp.entityid |
the IdP entity ID |
saml.idp.single_sign_on_service.url |
where the AuthnRequest is sent |
saml.idp.single_logout_service.url |
the IdP single logout service (leave blank to not use SLO) |
saml.idp.x509cert |
the IdP signing certificate, base64, no PEM header |
saml.sp.base.url |
the URL Fess is reached at; the three SP URLs are derived from it (default http://localhost:8080) |
saml.sp.entityid |
overrides the derived <base>/sso/metadata |
saml.sp.assertion_consumer_service.url |
overrides the derived <base>/sso/ |
saml.sp.single_logout_service.url |
overrides the derived <base>/sso/logout |
saml.sp.nameidformat |
the requested NameID format (default urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress) |
saml.sp.privatekey |
the SP private key, base64 PKCS#8 (a PEM header is accepted); needed to sign messages and to decrypt an encrypted assertion |
saml.sp.x509cert |
the SP certificate that goes with it |
saml.attribute.group.name |
the assertion attribute holding the user's groups (default memberOf) |
saml.attribute.role.name |
the assertion attribute holding the user's roles |
saml.default.groups |
comma-separated groups added to every SAML login |
saml.default.roles |
comma-separated roles added to every SAML login |
saml.request.id.ttl |
how long an unanswered AuthnRequest ID stays usable, in seconds (default 3600) |
saml.session.end_with_idp |
a login session ends when the IdP's session ends (SessionNotOnOrAfter of the assertion, plus saml.security.clock_drift); false turns this off (default true). Needs a Fess whose FessUser has isExpired() (15.10) |
A login is refused when the NameID, or a value of the group or role attribute, contains a control
character, a line or paragraph separator or an invisible format character such as a bidirectional
override or a zero-width space (U+200C and U+200D are accepted). The value is never rewritten;
only the white space around a group or role value is trimmed.
Every other saml. key is passed to saml4j without the prefix, and a key it does not know is refused when
the settings are built, so a mistyped security setting cannot go unnoticed. The security keys:
| Key | Default |
|---|---|
saml.security.authnrequest_signed |
false; needs saml.sp.privatekey |
saml.security.want_messages_signed |
false; require the Response to be signed |
saml.security.want_assertions_signed |
false; require the Assertion to be signed |
saml.security.want_assertions_encrypted |
false |
saml.security.want_logout_signed |
true; logout messages from the IdP must be signed |
saml.security.allow_deprecated_alg |
false; accept SHA-1 signatures |
saml.security.allow_rsa_1_5 |
false; accept RSA 1.5 key transport |
saml.security.clock_drift, saml.security.max_message_size |
120 seconds, 1048576 bytes |
saml.security.requested_authncontext, saml.security.requested_authncontextcomparison |
Password, exact; a blank value requests nothing. It is only a request: the AuthnContext of the response is not checked, so do not rely on it to require a stronger authentication |
saml.idp.x509certMulti.1, .2, ... |
more IdP certificates, for a key rollover |
Either the Response or the Assertion must be signed, whatever these say. The audience, recipient, destination, issuer and validity period are always checked, and a response has to answer a login Fess started.
A saml.* key that system.properties does not hold is read, like other Fess settings, from the
-Dfess.system.<key>=... option on the JVM command line and from the FESS_SYSTEM_<KEY> environment
variable: the key in upper case with every character other than a letter or a digit replaced by _,
so saml.idp.x509cert is FESS_SYSTEM_SAML_IDP_X509CERT and saml.idp.x509certMulti.1 is
FESS_SYSTEM_SAML_IDP_X509CERTMULTI_1. Every key above can be given in any of these ways. The first of
the following wins, which is also what the General page of the administration screen shows:
- the value in
system.properties, even an empty one; - a
-Dfess.system.<key>option with a value; - the environment variable (an empty variable counts as not set);
- a
-Dfess.system.<key>=option with nothing after the=, which gives an empty value; - the default.
- An empty value therefore cannot be given by a variable. To request no authentication context, or to leave
the NameID format unspecified, write
saml.security.requested_authncontext=orsaml.sp.nameidformat=in the file, or pass the empty option and leave the variable unset. - An unknown
saml.*option is refused like an unknown key of the file. AFESS_SYSTEM_SAML_*variable that names no key is ignored, with a warning that names it: check the log after setting one. - The key of an additional certificate is taken from the name of its variable, so give it a number or an upper-case suffix.
- Give
saml.sp.privatekeyby the variable rather than the option: an option is visible in the process list. - Saving the General page does not store a value that a key gets from the option or the variable, but a
value changed there is stored and wins from then on. On a Fess build without the change of
codelibs/fess#4058, however, a value that the page shows is copied into
system.propertiesby every save, even an unchanged one, when it has blanks or a line break at its start or end, or CR line breaks, such as asaml.idp.x509certthat ends with a line break: give such a value without them.
Changes to be aware of when upgrading are listed in UPGRADING.md.
The full saml.* reference, including a worked configuration for each supported IdP, is the SAML
SSO page of the Fess documentation.
The IdP returns the assertion as a cross-site POST. A SameSite=Lax cookie is not sent on such a
request, so the shipped default has to be changed for SAML. In tomcat_config.properties
(lib/classes/ in the ZIP package, /etc/fess/ in the DEB and RPM packages):
tomcat.sameSiteCookies = none
Browsers only accept none on a Secure cookie, so Fess has to be served over HTTPS. Over plain
HTTP this setting makes it impossible to log in at all.
With FESS_SESSION_STORE=opensearch (Fess keeps the HTTP sessions in OpenSearch) a login can start on
one node and finish on another, and the logged-in user is shared. The plugin stores the NameID, the
groups and roles, and the session index, NameID format and qualifiers that single logout needs; the
permissions are derived again on each node and the assertion is never stored. Use the same plugins, 15.10,
on every node: adding or removing an SSO plugin invalidates the stored sessions, and users log in again.
Without the store, SAML needs sticky sessions as before.
An AuthnRequest ID is consumed once per session, but the store is last-writer-wins: two nodes that answer the same assertion at the same moment can both accept it, and the node that finishes later can write an ID back that the other consumed. Both need the session cookie of the user.
| Fess | Plugin |
|---|---|
| 15.10.x | 15.10.x |
Match the minor version. Installing this plugin into Fess 15.8 or earlier breaks SSO with a 500:
those versions register samlAuthenticator in their own fess_sso++.xml, and a second registration
from this plugin makes getComponent fail with TooManyRegistrationComponentException — not only
for sso.type=saml, but for every SSO type, because the failure is in building the container's view
of that component name.
Nothing here is wired by class name from Fess. The plugin ships one additive LastaDi file that Fess
merges from every jar on the class path: fess_sso++.xml registers samlAuthenticator.
SsoManager resolves an authenticator as <sso.type>Authenticator, so that component name is what
makes sso.type=saml resolve. It is a singleton because init() registers the instance with the
SsoManager, and because the pending AuthnRequest IDs and the replay cache it holds have to be the
same ones on the request that answers the IdP.
fess_sso.xml is included from the webapp's app.xml and from no other Di xml, so the crawler,
thumbnail, suggest and chunk processes never build this component. That is why the jar carries
Fess-WebAppJar: true and why jakarta.servlet-api is a provided dependency: the servlet
container supplies it where the authenticator actually runs.
SsoAuthenticator, SsoManager, SsoAction, the SSO part of the admin general page and the
sso.* configuration keys all stay in Fess. Only the authenticator, the credential it produces and
the SAML library ship here. saml4j and xmlsec are shaded in without relocation,
because Santuario reads its own algorithm registry out of a bundled config.xml and instantiates
every entry by name. Woodstox, which xmlsec asks for at runtime, is left out: saml4j uses only
Santuario's DOM API, and shipping Woodstox would announce a StAX implementation to the whole webapp
without the stax2-api that goes with it.