Skip to content

Allow mapping authentication query columns to user attributes - #756

Open
jnbdz wants to merge 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:issue-694-row-mapping
Open

Allow mapping authentication query columns to user attributes#756
jnbdz wants to merge 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:issue-694-row-mapping

Conversation

@jnbdz

@jnbdz jnbdz commented Aug 9, 2026

Copy link
Copy Markdown

The SQL authentication provider discards every column of the authentication query except the password (row.getString(0)), so callers that need more user data right after login — typically the user id for a session or token — have to run a second query for the row they just fetched.

Following the guidance in #694, this adds a SqlAuthentication.create(client, options, attributeMapper) overload where the mapper is a Function<Row, JsonObject> living on the auth type (options stay data-only). The mapper receives the authenticated row and the returned JSON object is merged into the authenticated User attributes:

AuthenticationProvider provider = SqlAuthentication.create(sqlClient,
  new SqlAuthenticationOptions()
    .setAuthenticationQuery("SELECT password, email FROM users WHERE username = ?"),
  row -> new JsonObject().put("email", row.getString("email")));

Behavior notes:

  • the password is still expected in the first column, existing create overloads are unchanged
  • a null mapper result is ignored
  • a mapper that throws fails the authentication future
  • the mapper only runs after the password has been verified

Includes a test in MySQLTest (the DDL gains a nullable email column), an example and documentation.

Fixes #694

The SQL authentication provider discards every column of the
authentication query except the password, forcing a second query to
load user data such as its id right after authentication.

Add a SqlAuthentication.create overload taking a mapping function that
receives the authenticated row and returns a JSON object to merge into
the user attributes. The password remains expected in the first column
and options stay data only, following the guidance in the issue.

Fixes eclipse-vertx#694
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return full user information on authentication query

1 participant