2016-07-06 7 views
0

Oauth 2認証サーバーVert.x(3.3.0)のセットアップに役立つものがありますか。 Vert.x Oauth 2認証サーバー

に例えば 次のコードスニペットを私はこのvert.xモジュールVERTX-AUTH-のOAuth2を見つけましたが、認証サーバが異なる場合、私はそれが有用であろうと思いは、それがあるvert.xのドキュメントから

OAuth2Auth oauth2 = OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions() 
     .setClientID("YOUR_CLIENT_ID") 
     .setClientSecret("YOUR_CLIENT_SECRET") 
     .setSite("https://github.com/login") 
     .setTokenPath("/oauth/access_token") 
     .setAuthorizationPath("/oauth/authorize") 
); 

// when there is a need to access a protected resource or call a protected method, 
// call the authZ url for a challenge 

String authorization_uri = oauth2.authorizeURL(new JsonObject() 
    .put("redirect_uri", "http://localhost:8080/callback") 
    .put("scope", "notifications") 
    .put("state", "3(#0/!~")); 

// when working with web application use the above string as a redirect url 

// in this case GitHub will call you back in the callback uri one should now complete the handshake as: 


String code = "xxxxxxxxxxxxxxxxxxxxxxxx"; // the code is provided as a url parameter by github callback call 

oauth2.getToken(new JsonObject().put("code", code).put("redirect_uri", "http://localhost:8080/callback"), res -> { 
    if (res.failed()) { 
    // error, the code provided is not valid 
    } else { 
    // save the token and continue... 
    } 
}); 

です認証サーバーとしてGithubを使用しています。Vert.xでAuthorizationサーバーを実装する方法を知りたいのですが、私は春のセキュリティがこの機能、つまりOauth2ServerとOAuth2Clientを提供していることを知っています。

答えて

3

Vert.x OAuth2は単なるOAuth2Clientなので、サーバーの実装はありません。したがって、Vert.xプロジェクト自体から取得することはできません。 (永続的な情報を格納することができ、サーバとアプリケーションのための)

  • 認証コードフロー:

    Vert.xのOAuth2には、以下のフローをサポートしています。

  • パスワード資格情報のフロー(以前のフローを使用できない場合や開発中の場合)。
  • クライアント資格情報フロー(クライアントのみ、クライアントの資格情報を使用してアクセストークンを要求することができます)
+0

暗黙のフローは、将来的にサポートされている場合、あなたは知っていますか? – Skullcrasher

+0

問題トラッカーに実装するよう依頼することができます。その後、ロードマップ、リソース、またはコミュニティプルリクエストに応じて、 –