Keycloak 中的 SAML 注销失败

时间:2021-04-13 18:44:05

标签: keycloak saml saml-2.0

我们正在从 Spring Security SAML 切换到使用 Keycloak 作为 SAML 代理。

首先,我通过从我们的身份提供者导入 IdP 元数据 XML,在 Keycloak 中配置了 IdP。这导致服务提供商实体 ID 变为 https://saml.test-nemlog-in.dk/,并且在登录时我从 IdP 收到以下错误:

The entity ID https://saml.test-nemlog-in.dk/ could not be found

我认为使用了错误的值,因为这必须是 SP entityId (https://our.address.com)。
当我将 Service Provider Entity ID 更改为我们的 entityId 时,登录工作正常。

使用登录作为上述解决方法,现在当我从第三方注销时,我会通过注销请求(如预期的那样)重定向到我们的 SP。目的地是正确的,发行人也是如此:

<LogoutRequest
    Destination="https://our.address.com/auth/realms/saml-broker-realm/protocol/saml"
    ID="..." IssueInstant="..." NotOnOrAfter="..." Version="2.0"
    xmlns="urn:oasis:names:tc:SAML:2.0:protocol">
    <Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity"
        xmlns="urn:oasis:names:tc:SAML:2.0:assertion">https://saml.test-nemlog-in.dk/</Issuer>
    <NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName"
        xmlns="urn:oasis:names:tc:SAML:2.0:assertion">....</NameID>
    <SessionIndex>....</SessionIndex>
</LogoutRequest>

它失败了,我在 Keycloak 日志中得到以下信息:

type=LOGOUT_ERROR, realmId=saml-broker-realm, clientId=https://saml.test-nemlog-in.dk/, userId=null, ipAddress=192.168.32.1, error=client_not_found

我知道在 Keycloak 的 IdP 配置中,entityId 设置为 https://our.address.com,但这是出现在字段 Service Provider Entity ID 中的地址,如果我将其更改为 IdP entityId 登录不起作用。

我是否遗漏了什么 - 也许我错过了配置的 Keycloak?

以下是从 Keycloak 导出的 IdP 配置。

"identityProviders": [
    {
      "alias": "NemLog-in",
      "displayName": "NemLog-in",
      "internalId": "",
      "providerId": "saml",
      "enabled": true,
      "updateProfileFirstLoginMode": "on",
      "trustEmail": false,
      "storeToken": false,
      "addReadTokenRoleOnCreate": false,
      "authenticateByDefault": false,
      "linkOnly": false,
      "firstBrokerLoginFlowAlias": "Simple browser flow",
      "config": {
        "validateSignature": "true",
        "signingCertificate": "",
        "postBindingLogout": "false",
        "nameIDPolicyFormat": "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
        "postBindingResponse": "true",
        "singleLogoutServiceUrl": "https://login.test-nemlog-in.dk/adfs/ls/",
        "entityId": "https://our.address.com",
        "signatureAlgorithm": "RSA_SHA256",
        "wantAssertionsEncrypted": "false",
        "xmlSigKeyInfoKeyNameTransformer": "KEY_ID",
        "useJwksUrl": "true",
        "loginHint": "false",
        "authnContextComparisonType": "exact",
        "postBindingAuthnRequest": "false",
        "syncMode": "IMPORT",
        "singleSignOnServiceUrl": "https://login.test-nemlog-in.dk/adfs/ls/",
        "wantAuthnRequestsSigned": "true",
        "addExtensionsElementWithKeyInfo": "false",
        "encryptionPublicKey": "",
        "principalType": "SUBJECT"
      }
    }

以上 JSON 结果

above JSON results in this

0 个答案:

没有答案