Skip to content

Decrypt the EncryptedID of a LogoutRequest - #1039

Open
christophdb wants to merge 1 commit into
IdentityPython:masterfrom
christophdb:decrypt-encrypted-id-in-logout-request
Open

christophdb wants to merge 1 commit into
IdentityPython:masterfrom
christophdb:decrypt-encrypted-id-in-logout-request

Conversation

@christophdb

Copy link
Copy Markdown

Fixes #536.

A Shibboleth IdP encrypts the NameID of a front-channel LogoutRequest by default whenever the SP publishes an encryption key in its metadata (SAML2.Logout profile notes: "The default value of encryptNameIDs is also conditional on the same basis", i.e. on for the front channel). So this is what every SP in a Shibboleth-based federation receives:

<samlp:LogoutRequest ...>
  <saml:Issuer>https://idp.example.org/idp/shibboleth</saml:Issuer>
  <saml:EncryptedID>
    <xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element">...</xenc:EncryptedData>
  </saml:EncryptedID>
  <samlp:SessionIndex>_8b84...</samlp:SessionIndex>
</samlp:LogoutRequest>

LogoutRequest left the EncryptedID alone, so message.name_id was None, Saml2Client.handle_logout_request compared that with the NameID stored at login and answered UnknownPrincipal / "Wrong user" for the very user the IdP asked about. The IdP shows an error and cannot finish the logout.

LogoutRequest._loads now decrypts the EncryptedID with the configured encryption keys, the same way AuthnResponse.get_subject handles an encrypted NameID in an assertion. If no key can decrypt it, the NameID stays empty and the behaviour is as before. Since this sits in LogoutRequest, Server.parse_logout_request benefits as well when a Shibboleth SP sends an encrypted NameID to a pysaml2 IdP.

Verified against a production Shibboleth IdP (5.x): the logout that used to end in "Wrong user" now completes.

A Shibboleth IdP encrypts the NameID of a front-channel LogoutRequest by
default whenever the service provider publishes an encryption key in its
metadata, so this is what a service provider in an identity federation
receives. LogoutRequest left the EncryptedID alone: the parsed message
carried no NameID, Saml2Client.handle_logout_request compared None with
the NameID stored at login and answered UnknownPrincipal, "Wrong user",
for the very user the IdP asked about. The IdP could not finish the
logout.

LogoutRequest now decrypts the EncryptedID with the configured
encryption keys when it loads the message, the same way AuthnResponse
handles an encrypted NameID in an assertion. If no key can decrypt it,
the NameID stays empty and the behaviour is as before.

Fixes IdentityPython#536
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Does pysaml2 handle encrypted NameId in SLO?

1 participant