eclipse-vertx / vertx-auth

Apache License 2.0
166 stars 156 forks source link

OAuth2AuthProvider CLIENT flow with custom data #643

Closed pqab closed 1 year ago

pqab commented 1 year ago

Describe the feature

The OAuth2AuthProviderImpl is only sending scopes or grant_type in the request, but our OIDC authentication server needs some custom data for the authentication, it would be nice if CLIENT flow could inject some more custom data, for example

oauth2.authenticate(new JsonObject()
      .put("flow", "client_credentials")
      .put("data1", "......")
      .put("data2", "......"))
  .onSuccess(user -> {
       // need data1 & data2 to pass through the request to get success
  })
  .onFailure(err -> {
       // always failure because data1 & data2 never pass to the request
  });

Version

4.3.0

pendula95 commented 1 year ago

You can set extraParams field in OAuth2Options when creating your oauth2 provider: https://github.com/eclipse-vertx/vertx-auth/blob/60af91463c0625a256cdc6ac6cb8e3254bd6bdc9/vertx-auth-oauth2/src/main/java/io/vertx/ext/auth/oauth2/OAuth2Options.java#L454-L457

This will be added to the request: https://github.com/eclipse-vertx/vertx-auth/blob/60af91463c0625a256cdc6ac6cb8e3254bd6bdc9/vertx-auth-oauth2/src/main/java/io/vertx/ext/auth/oauth2/impl/OAuth2API.java#L176-L180

pqab commented 1 year ago

Thank you, it works, I can see the custom params injected to the authenticate request now

pendula95 commented 1 year ago

You are welcome @pqab , can you please close this issue as the problem seems to be resolved?