0

如何为服务器安全的 SPA 应用程序创建自定义 IBM Cloud App ID 登录小部件(云目录)?

受保护的 SPA 应用程序将仅通过网关 API 使用 IBM Cloud Functions。

我是否只需将https://github.com/ibm-cloud-security/appid-serversdk-nodejs实现为云功能来自定义小部件并按我的意愿保留我的应用程序服务器?

我无法从文档https://console.bluemix.net/catalog/services/app-id中找到线索

想法?

@Jarkko

4

1 回答 1

1

如果您不想使用 App ID 登录小部件,而是自己收集凭据并使用云函数中的 ROP REST API。你可以这样做:

let request = require('request');

// put your App ID credentials here (can be found in App ID console):
let credentials = {
    "version": 3,
    "clientId": "xxxxx",
    "secret": "xxxxx",
    "tenantId": "xxxxx",
    "oauthServerUrl": "https://appid-oauth.eu-gb.bluemix.net/oauth/v3/xxxxx",
    "profilesUrl": "https://appid-profiles.eu-gb.bluemix.net"
};


function main(params) {
    return new Promise(function (resolve, reject) {
        request({
            url: credentials.oauthServerUrl + '/token',
            method: 'POST',
            auth: {
                username: credentials.clientId,
                password: credentials.secret
            },
            form: {

                grant_type: "password",
                // replace with actual credentials:
                username: "aaa@bbb.com",
                password: "11111111"
            }
        }, function (error, response, body) {
            resolve(response);
            // handle errors...
        });
    })
}

在这种情况下,响应将是 App ID 访问令牌。

于 2018-01-04T15:12:24.917 回答