Skip to main content

Shibboleth

This guide connects a Shibboleth Identity Provider (IdP) version 5 to Knocknoc for user sign-in. It assumes your IdP already signs people in against your directory (LDAP or Active Directory) and that you can edit its configuration files under /opt/shibboleth-idp/conf.

In this example, the IdP's entity ID is https://idp.example.com/idp/shibboleth and Knocknoc is hosted at https://knocknoc.example.com. Replace both with your own. For an on-premises Knocknoc server, use its base URL.

Knocknoc needs three things from Shibboleth, and a stock IdP sends none of them in the form Knocknoc reads:

Knocknoc needs Shibboleth default Change
A persistent NameID Transient NameIDs only. The login fails with InvalidNameIDPolicy Add a persistent NameID generator (step 3)
groups and realName attributes No group attribute is sent, and the attributes that are sent are named by OID, such as urn:oid:0.9.2342.19200300.100.1.3 for mail Define attributes with the names Knocknoc reads (step 4)
The Knocknoc SP's metadata Not trusted Add a metadata provider (step 2)

Shibboleth encrypts assertions by default, using AES-GCM with RSA-OAEP. Knocknoc decrypts these, so leave encryption on.

1. Add Shibboleth to Knocknoc

  1. In the Knocknoc admin portal, go to Settings > Authentication > User SAML (SSO) and click Set up.
  2. Fill in the form:
Field Value
Identity Provider Name Shibboleth, or your organization's name for it. This is the label on the login button
Metadata file Upload /opt/shibboleth-idp/metadata/idp-metadata.xml, copied from the IdP
Metadata URL Instead of the file, you can enter https://idp.example.com/idp/shibboleth, which serves the same file
Public URL https://knocknoc.example.com
  1. Click Save. Knocknoc generates a signing key and certificate if you did not supply your own.
  2. Note the two values Knocknoc now shows under Register these at your identity provider:
    • Metadata / Entity ID: https://knocknoc.example.com/api/saml/metadata
    • Reply URL (ACS): https://knocknoc.example.com/api/saml/acs

The User SAML settings with Shibboleth saved, showing the Metadata / Entity ID and Reply URL (ACS) to register at the IdP

2. Register Knocknoc as a service provider

Add a metadata provider to conf/metadata-providers.xml, inside the outer <MetadataProvider> element:

<MetadataProvider id="Knocknoc" xsi:type="FileBackedHTTPMetadataProvider"
    metadataURL="https://knocknoc.example.com/api/saml/metadata"
    backingFile="%{idp.home}/metadata/knocknoc-sp.xml"
    maxRefreshDelay="PT4H" />

Fetch the metadata from Knocknoc's URL rather than saving a copy with a FilesystemMetadataProvider. Knocknoc's metadata carries a validUntil date two days ahead, and Shibboleth ignores metadata once that date has passed, so a saved copy stops working after two days. The IdP logs No metadata returned for https://knocknoc.example.com/api/saml/metadata and shows the user an error page. The HTTP provider refreshes well before that.

The IdP must trust the certificate on Knocknoc's web server. If it does not, every refresh fails with a PKIX path error in logs/idp-warn.log and the IdP keeps using the backing file until that copy expires. If Knocknoc uses a self-signed certificate, replace it with one your IdP trusts under Settings > SSL Certificates.

3. Send a persistent NameID

Knocknoc asks for the persistent NameID format and uses the NameID as the username. In conf/saml-nameid.xml, add a generator to the shibboleth.SAML2NameIDGenerators list, after the transient one:

<util:list id="shibboleth.SAML2NameIDGenerators">
    <ref bean="shibboleth.SAML2TransientGenerator" />

    <!-- Knocknoc: persistent NameID taken from the user's email address -->
    <bean parent="shibboleth.SAML2AttributeSourcedGenerator"
        p:omitQualifiers="true"
        p:format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
        p:attributeSourceIds="#{ {'mail'} }" />
</util:list>

This makes the username the person's email address, such as [email protected]. The mail attribute must be defined in your attribute resolver and released to Knocknoc (step 5).

If your organization's policy is an opaque identifier, enable shibboleth.SAML2PersistentGenerator instead and set idp.persistentId.sourceAttribute and idp.persistentId.salt in conf/saml-nameid.properties. Users then arrive in Knocknoc as a hashed value, so also send realName (step 4) to show their names. Whichever you choose, keep it stable: a changed NameID signs the person in as a new Knocknoc account.

4. Define the groups and realName attributes

Knocknoc reads attributes by their SAML Name. It matches groups and realName and ignores the FriendlyName. Shibboleth's built-in attributes go out named by OID, so define attributes of your own for Knocknoc.

In conf/attribute-resolver.xml, add two attribute definitions. This example reads from an LDAP data connector with the id myLDAP. Use the id of your own connector, and make sure it returns memberOf and displayName:connector.

<!-- Knocknoc: display name, sent as the "realName" attribute -->
<AttributeDefinition id="knocknocRealName" xsi:type="Simple">
    <InputDataConnector ref="myLDAP" attributeNames="displayName" />
</AttributeDefinition>

<!-- Knocknoc: group names, sent as the "groups" attribute.
     memberOf holds DNs (cn=knocknoc-users,ou=groups,dc=example,dc=com), so keep the CN. -->
<AttributeDefinition id="knocknocGroups" xsi:type="RegexSplit" regex="^CN=([^,]+),.*$" caseSensitive="false">
    <InputDataConnector ref="myLDAP" attributeNames="memberOf" />
</AttributeDefinition>

The connector must return displayName and memberOf. Many directories, including OpenLDAP and Active Directory, return memberOf only when it is asked for by name, so list both in the connector's <ReturnAttributes>, alongside any attributes it already returns:

<DataConnector id="myLDAP" xsi:type="LDAPDirectory" ...>
    ...
    <ReturnAttributes>mail displayName memberOf</ReturnAttributes>
</DataConnector>

RegexSplit drops any value the regex does not match, and it is case-sensitive unless told otherwise, so keep caseSensitive="false" to match both cn= and Active Directory's CN=. Active Directory lists only direct group memberships in memberOf. If your groups already arrive as plain names, for example isMemberOf from Grouper, use a Simple definition like the knocknocRealName one instead.

Then give each attribute its SAML name. Create two files in conf/attributes/custom/:

conf/attributes/custom/knocknocGroups.properties:

id=knocknocGroups
transcoder=SAML2StringTranscoder
saml2.name=groups

conf/attributes/custom/knocknocRealName.properties:

id=knocknocRealName
transcoder=SAML2StringTranscoder
saml2.name=realName

Knocknoc reads other optional attributes the same way, such as sessionDuration and company. Add a definition and a properties file for each one you want to send. The full list is on the SAML page.

5. Release the attributes to Knocknoc

In conf/attribute-filter.xml, add a policy inside <AttributeFilterPolicyGroup>:

<!-- Knocknoc -->
<AttributeFilterPolicy id="Knocknoc">
    <PolicyRequirementRule xsi:type="Requester" value="https://knocknoc.example.com/api/saml/metadata" />
    <AttributeRule attributeID="mail" permitAny="true" />
    <AttributeRule attributeID="knocknocRealName" permitAny="true" />
    <AttributeRule attributeID="knocknocGroups" permitAny="true" />
</AttributeFilterPolicy>

mail is released because the NameID generator in step 3 reads it.

Restart the IdP's servlet container (Jetty or Tomcat) to load the changes, and check logs/idp-process.log for errors.

6. Create the groups in Knocknoc

Each value in groups is matched against a Knocknoc group of the same name. In the admin portal, go to Identities > Groups > Create Group, enter the group name exactly as Shibboleth sends it (knocknoc-users in this example), set Type to SAML, and attach the knocs the group should reach. See Create groups.

7. Test the sign-in

Go to Settings > Authentication > User SAML (SSO) and click Test SAML. Sign in at the Shibboleth login page. A working setup shows:

  • Signed in as: the user's email address, such as [email protected]
  • Groups assigned: the Knocknoc groups that matched, such as knocknoc-users
  • Attributes returned by your IdP: groups and realName under those names, plus mail under its OID name, urn:oid:0.9.2342.19200300.100.1.3, which Knocknoc ignores

A successful Test SAML result for Shibboleth, signed in as jdoe@example.com with the knocknoc-users group and the realName, mail and groups attributes

Troubleshooting

What you see Cause Fix
Knocknoc shows "Authentication failed" after the Shibboleth login page. The IdP log has unsupportable identifier format: urn:oasis:names:tc:SAML:2.0:nameid-format:persistent and InvalidNameIDPolicy No persistent NameID generator, or its source attribute is not released Step 3, and check mail is in the filter policy in step 5
Shibboleth shows an error page instead of its login page. The IdP log has No metadata returned for https://knocknoc.example.com/api/saml/metadata The IdP does not have Knocknoc's metadata, or its copy has expired Step 2. Check the IdP can reach the metadata URL and trusts Knocknoc's certificate
The user signs in but sees "You are not in any login-groups that match access paths" No Knocknoc group matches the values sent Run Test SAML. If groups is missing, check that the data connector returns memberOf, that the regex in step 4 matches your directory's values, and that the filter in step 5 releases knocknocGroups. If groups is there, create a group with the same name (step 6)
Test SAML shows mail under its urn:oid:... name but no groups or realName The data connector did not return displayName and memberOf, or the IdP has no SAML name for the Knocknoc attributes, so it does not send themattributes Check the connector's <ReturnAttributes> (step 4) and that the two properties files are in conf/attributes/custom/, andthen restart the IdP
The user arrives with a hashed username and no name Computed persistent IDs are on and realName is not sent Send realName (step 4), or use the email-based NameID in step 3

Shibboleth documentation