0
有人可以帮我设置Oauth 2授权服务器Vert.x(3.3.0)。我没有找到任何与它相关的文档。 我发现vertx认证 - 这的oauth2模块vert.x,但我想,如果授权服务器是不同 如Vert.x Oauth 2授权服务器
下面的代码片段是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中实现授权服务器,我知道spring security提供了这个功能,即Oauth2Server和OAuth2Client。
你知道,如果隐流将在未来得到支持? – Skullcrasher
你可以要求它在问题追踪器上实现。然后根据路线图和资源或社区拉请求,它可能在。 –