【问题标题】:How to authenticate on Bluemix using SSO and REST?如何使用 SSO 和 REST 在 Bluemix 上进行身份验证?
【发布时间】:2017-11-30 17:24:12
【问题描述】:

我正在使用 rest 使用 API 密钥向 Bluemix 验证用户。我还想实现用户名和密码认证。

def auth(self):
    self.log.debug('Authenticating to CloudFoundry')
    url = self.info['authorization_endpoint'] + '/oauth/token'
    headers = {
                'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
                'Accept': 'application/x-www-form-urlencoded;charset=utf-8',
                'Authorization': 'Basic Y2Y6'
            }

    if self.api_auth:
        data = 'grant_type=password&username=apikey&password={}'.format(self.api_key)
    elif self.userpass_auth:
        data = 'grant_type=password&username={}&password={}'.format(self.username, self.password)
    else:
        raise ValueError()

    # send request ...

但是,当我尝试使用用户名和密码发出请求时,我收到了响应:

{"error_description":"BMXLS0202E: You are using a federated user ID,
  please use one time code to login with option --sso.","error":"unauthorized"}

所以我可以将我的用户发送到 SSO 网页以获取令牌,但是当他们拥有 SSO 令牌时我需要制作什么 REST api?或者,我是否使用与上面相同的 rest api,但提供不同的参数?

【问题讨论】:

    标签: ibm-cloud single-sign-on


    【解决方案1】:

    为什么要支持用户名和密码(我觉得我在这里错过了一块拼图)?

    我建议使用 API 令牌作为一般的良好做法 - 一些联合登录需要基于 Web 的令牌步骤,这在使用集成时不是很好。

    【讨论】:

    • 我同意你的看法。我更喜欢 API 令牌,我从 my library 中的 API 令牌支持开始。但是,有些用户要求我也支持用户名/密码:(
    • 好吧,你可以支持它,但那些拥有联合 ID 的人将不得不选择 API 令牌路由。我真的不认为你可以解决这个问题:/
    猜你喜欢
    • 2021-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-24
    • 2017-11-26
    • 1970-01-01
    • 2012-04-15
    相关资源
    最近更新 更多