2016-07-20 5 views
0

私はAuth0でSwaggerを使用しようとしています。 私は現在ApiFirstHandとSwagger-uiを使って私のAPIをテストしています。Auth0でSwaggerを使用する

このexample.yamlからは、getUserTodosにはuser, admin:org, admin:public_keyのスコープが必要です。ここで

はsecurityDefinitionsです:

securityDefinitions: 
    internalOAuth: 
    type: oauth2 
    scopes: 
     user: Grants read/write access to profile info only. 
     admin:org: Fully manage organization, teams, and memberships. 
     admin:public_key: Fully manage public keys. 
    flow: implicit 
    # we use a single API here to issue token (for SwaggerUI) 
    authorizationUrl: http://localhost:9000/example/token 
    # and to validate it later 
    x-token-validation-url: http://localhost:9000/example/token 

私の質問は、私が代わりにinternal0AuthのAuth0を使用したい場合はAuth0とexample.yamlの私securityDefinitionsに私のユーザーのメタデータがどうあるべきか、ですか? これに加えてSwagger-UIを使用することはできますか?

私は

securityDefinitions: 
    auth0: 
    type: oauth2 
    scopes: 
     openid: Grants access to user_id. 
     read:task: Grants read access to task 
    flow: accessCode 
    authorizationUrl: https://test.eu.auth0.com/authorize 
    tokenUrl: https://test.eu.auth0.com/userinfo 
    x-token-validation-url: https://test.eu.auth0.com/userinfo 

を試してみました

"user_metadata": { 
     "admin:org": true, 
     "admin:public_key": true, 
     "openid": true 
    } 

答えて

0

internalOAuthまたはauth0は、API呼び出しのsecurityプロパティの定義に参照する名前だけです。ある意味では、好きなように名前を付けることができます。API呼び出し定義で正しい名前を使用するだけです。あなたのケースでは

それはおそらくそのようになります。

security: 
    - auth0: 
    - openid 
    - admin:org 
    - admin:public_key 

securityDefinitions: 
    auth0: 
    type: oauth2 
    scopes: 
     openid: Grants access to user_id 
     admin:org: Fully manage organization, teams, and memberships. 
     admin:public_key: Fully manage public keys. 
    flow: accessCode 
    authorizationUrl: https://test.eu.auth0.com/authorize 
    tokenUrl: https://test.eu.auth0.com/userinfo 
    x-token-validation-url: https://test.eu.auth0.com/userinfo 
paths: 
    /some/url: 
    get: 
     description: Returns something 
     summary: cool API endpoint 
     security: 
     - auth0: 
      - admin:org 

それはまさにあなたの要件を知らなくても、それを定義するのは難しい、私は闊歩仕様を見てみるために役立つかもしれないと思いますSecurity Definitions Object

Security Requirement Object

闊歩UIはそれで動作するはずです、あなたはO、それを試みることができますAuth0ことで

+0

routesファイルにconfフォルダやコメントを解除ライン33にsecurity.api.yamlを移動することによって、UT、私は、彼らが持っているように、このサース=> https://auth0.com/docs/api/authentication に見え意味していますある種の "accessCode"と "implicit"フローが流れますが、 "scope"という概念はSwaggerとAuth0の間では一致していないようです。 –

+0

私はAuth0を知らなかった、申し訳ありません。私が助ける最もよい方法は、api-firstアクティベータテンプレートで別の例を作成することです。 [こちら](https://github.com/zalando/play-swagger-service)の問題を作成してもよろしいですか? –

関連する問題