Vertx Form Login Handler with Postgresql Failure

228 Views Asked by At

I am trying to authenticate user using FormLoginHandler and Postgresql Database with SqlAuthentication.

But I get the following error: Jun 15, 2022 1:14:34 PM io.vertx.ext.web.RoutingContext SEVERE: Unhandled exception in router io.vertx.ext.web.handler.HttpException: Unauthorized Caused by: io.vertx.core.impl.NoStackTraceThrowable: Invalid username/password

I am providing the right credentials.

The code snippet is:

SqlAuthenticationOptions sauthopts = new SqlAuthenticationOptions();

sauthopts.setAuthenticationQuery(AUTHENTICATE_QUERY);

SqlAuthentication authenticationProvider = SqlAuthentication.create(sqlClient, sauthopts);

router.route("/secure/*").handler(RedirectAuthHandler.create(authenticationProvider, "/login.html"));

FormLoginHandler formLoginHandler =  FormLoginHandler.create(authenticationProvider);

router.route("/loginhandler").handler(formLoginHandler);  

Please let me know if I am missing something here; or point me to a sample example.

Thanks in Advance.

1

There are 1 best solutions below

3
On

Your setup doesn't show anything abnormal at first sight. For security reasons, we cannot "just" log the authentication data, as it would be a critical OWASP bug and security vulnerability.

My best guess is that probably is something not totally correct with the query, so this means you have now 2 options:

  1. debug the application and see the query that is being sent + the arguments
  2. prepare a small complete example that shows the bug and open an issue in vert.x so we can debug it further.

If you're upgrading from an older version, be aware that in vert.x 4.2.0 some changes were made to the base64 encoding to keep it consistent across modules. This could be a reason why authentication could fail as the encoded hashes may be slightly different. If you're just doing 4.3.0 from the start, then this would not be a problem.