如何将 Python OpenID Connect 模块与 IBM Cloud App ID 配合使用?



我注册了 IBM Cloud App ID 以保护对我的云应用程序的访问。有一个示例显示该服务可以与 Python 一起使用。但是,我想使用其中一个(标准)OpenID Connect模块。例如,如何配置Flask-pyoidc以使用应用程序ID?它需要几个参数,我不确定它们与应用程序 ID 提供的内容有何关系。

provider_config = {
'issuer': 'https://op.example.com',
'authorization_endpoint': 'https://op.example.com/authorize',
'token_endpoint': 'https://op.example.com/token',
'userinfo_endpoint': 'https://op.example.com/userinfo'
}
auth = OIDCAuthentication(provider_configuration_info=provider_config)

下面介绍了如何配置provider_config

provider_config={
"issuer": "appid-oauth.ng.bluemix.net",
"authorization_endpoint": appIDInfo['oauthServerUrl']+"/authorization",
"token_endpoint": appIDInfo['oauthServerUrl']+"/token",
"userinfo_endpoint": appIDInfo['profilesUrl']+"/api/v1/attributes",
"jwks_uri": appIDInfo['oauthServerUrl']+"/publickeys"
}

appIDInfo可以从 IBM Cloud 上的 Cloud Foundry 环境中获取,也可以使用如下所示的结构手动配置:

"AppID": {
"clientId": "your App ID client Id",
"managementUrl": "https://appid-management.ng.bluemix.net/management/v4/-----tenantID----",
"oauthServerUrl": "https://appid-oauth.ng.bluemix.net/oauth/v3/-----tenantID----",
"profilesUrl": "https://appid-profiles.ng.bluemix.net",
"secret": "the App ID secret",
"tenantId": "-----tenantID----",
"version": 3
}

然后,clientIdsecret将用于填充 Flask-pyoidc 所需的client_info对象。我在 GitHub 存储库中使用带有应用程序 ID 的 Flask-pyoidc 的示例代码。它显示了从配置到使用装饰器保护 Flask 中的应用路由的所有步骤。

最新更新