Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use non-deprecated authenticate methods (hyperledger#5852)
Browse files Browse the repository at this point in the history
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
macfarla authored and eum602 committed Nov 3, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 5e8067d commit cfe813d
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -33,6 +33,9 @@
import io.vertx.ext.auth.JWTOptions;
import io.vertx.ext.auth.User;
import io.vertx.ext.auth.authentication.AuthenticationProvider;
import io.vertx.ext.auth.authentication.Credentials;
import io.vertx.ext.auth.authentication.TokenCredentials;
import io.vertx.ext.auth.authentication.UsernamePasswordCredentials;
import io.vertx.ext.auth.jwt.JWTAuth;
import io.vertx.ext.auth.jwt.JWTAuthOptions;
import io.vertx.ext.web.RoutingContext;
@@ -166,7 +169,7 @@ public void handleLogin(final RoutingContext routingContext) {

private void login(
final RoutingContext routingContext, final AuthenticationProvider credentialAuthProvider) {
final JsonObject requestBody = routingContext.getBodyAsJson();
final JsonObject requestBody = routingContext.body().asJsonObject();

if (requestBody == null) {
routingContext
@@ -181,8 +184,10 @@ private void login(
final JsonObject authParams = new JsonObject();
authParams.put(USERNAME, requestBody.getValue(USERNAME));
authParams.put("password", requestBody.getValue("password"));
final Credentials credentials = new UsernamePasswordCredentials(authParams);

credentialAuthProvider.authenticate(
authParams,
credentials,
r -> {
if (r.failed()) {
routingContext
@@ -227,7 +232,7 @@ public void authenticate(final String token, final Handler<Optional<User>> handl
try {
getJwtAuthProvider()
.authenticate(
new JsonObject().put("token", token),
new TokenCredentials(new JsonObject().put("token", token)),
r -> {
if (r.succeeded()) {
final Optional<User> user = Optional.ofNullable(r.result());

0 comments on commit cfe813d

Please sign in to comment.