代码之家  ›  专栏  ›  技术社区  ›  data_henrik

如何将Python OpenID Connect模块与IBM云应用程序ID一起使用?

  •  1
  • data_henrik  · 技术社区  · 6 年前

    我注册了 IBM Cloud App ID 保护对我的云应用程序的访问。有一个示例显示该服务可以与Python一起使用。但是,我想使用一个(标准)OpenID连接模块。如何配置,例如。, 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)
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   data_henrik    6 年前

    以下是 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
    }
    

    这个 clientId secret 然后将用于填充 client_info 烧瓶化脓液所需的对象。我有 sample code using Flask-pyoidc with App ID in a GitHub repository 。它显示了从配置到使用装饰器保护Flask中的应用程序路由的所有步骤。