WSO2 SAML2BearerGrantHandler SAML令牌发行方验证失败或发行方未注册

时间:2016-01-12 08:26:18

标签: node.js wso2 wso2is wso2-am

我将WSO2 Identity Server配置为WSO2 API Manager的密钥管理器。

这就是我所做的

  • 我在API Manager中创建了应用程序并发布了它。 [OK]
  • 我创建了API并在商店中订阅。 [OK]
  • 我使用NodeJS Application作为客户端应用程序并作为资源提供者使用
  • 这是使用passport-saml策略的Passport配置:

     passport.use(new SamlStrategy({
        path: configSaml.path,
        entryPoint: configSaml.entryPoint,
        issuer: configSaml.issuer,
        decryptionPvk: configSaml.decryptionPvk,
        validateInResponseTo: true
    },
    function(profile, done) {
        done(null, profile)
    }
    ));
    

    它有效

  • 当我尝试从Saml 2.0持有者获取Access令牌时遇到问题,这是代码:

    app.post('/login/callback',function(req, res, next) {
    passport.authenticate('saml', function(err, user, info) {
        Log.d("OAuth Callback", arguments);
        if (err) { return next(err); }
        if (!user) { return res.redirect('/login'); }
        //req.logIn(user, function(err) {
        //    if (err) { return next(err); }
        //    return res.send(user);
        //});
    
        request.post({
            url: "https://localhost:9444/oauth2/token",
            headers: {
                'Content-Type' : 'application/x-www-form-urlencoded',
                'charset': "UTF-8",
                "Authorization": "Basic " + new Buffer("Ihd6BrTufShu7GPR4QXlypoIlsca:gTyBdDVd0zGQZRr29NhPoooHpeka").toString("base64")
            },
            body:"grant_type=urn:ietf:params:oauth:grant-type:saml2-bearer&assertion=" +
                require("base64-url").encode(user.getAssertionXml()) +
                "&scope=PRODUCTION"
        }, function(err,httpResponse,body){
            Log.d("Http Error", err);
            res.json(body);
        })
    })(req, res, next);
    });
    

    身体反应:

    "{\"error\":\"invalid_grant\",\"error_description\":\"Provided Authorization Grant is invalid.\"}"
    
  • 控制台调试打印:

    [2016-01-12 10:57:27,645] DEBUG - SAML2BearerGrantHandler SAML Token Issuer verification failed or Issuer not registered
    [2016-01-12 10:57:27,645] DEBUG - AccessTokenIssuer Invalid Grant provided by the client, id=Ihd6BrTufShu7GPR4QXlypoIlsca, user-name=null to application=admin-AT-safarifoneict.com_SamarimartWebPortal_PRODUCTION
    [2016-01-12 10:57:27,646] DEBUG - AccessTokenIssuer OAuth-Error-Code=invalid_grant client-id=Ihd6BrTufShu7GPR4QXlypoIlsca grant-type=urn:ietf:params:o auth:grant-type:saml2-bearer scope=PRODUCTION
    

欢迎任何帮助

1 个答案:

答案 0 :(得分:0)

"身份提供商实体ID" IDP配置中的值必须等于SAML2断言的颁发者值。有关详细信息,请参阅this

当您将WSO2IS配置为密钥管理器时,您的/令牌终点将位于WSO2IS中。所以;您的SAML2 SSO提供商& OAuth2提供程序是相同的(WSO2IS)。在这种情况下,您无需配置新的IDP配置。

但是,您可以通过提取SAML2断言来验证这一点,只需在SAML2断言中找到颁发者值并验证它是否等于您已配置为"身份提供商实体ID"