Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Okta Auth0 as OIDC provider #712

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hosuaby
Copy link

@hosuaby hosuaby commented Jan 21, 2025

This PR adds a provider for Okta Auth0. Auth0 itself is OIDC OP, so also works with discovery. This value this PR brings is to enforce the user to provide a mandatory parameter "audience." The following notations are equivalent:

With OIDC discovery

        WebClient client = WebClient.create(vertx, new WebClientOptions());
        String site = "https://{tenant}.auth0.com";
        OpenIDConnectAuth.discover(
                        vertx,
                        new OAuth2Options()
                                .setSite(site)
                                .setClientId(Auth0Credentials.CLIENT_ID)
                                .setClientSecret(Auth0Credentials.CLIENT_SECRET)
                                .setTenant(Auth0Credentials.TENANT)
                                .setExtraParameters(new JsonObject()
                                        .put("audience", Auth0Credentials.AUDIENCE)))
                .onSuccess(oauth2 -> {
                    Oauth2Credentials credentials = new Oauth2Credentials()
                            .setUsername(Auth0Credentials.CLIENT_ID)
                            .setPassword(Auth0Credentials.CLIENT_SECRET)
                            .setFlow(OAuth2FlowType.CLIENT);
                    OAuth2WebClient authClient = OAuth2WebClient
                            .create(client, oauth2)
                            .withCredentials(credentials);

                    // Here goes an authenticated call
                })

With factory method

        WebClient client = WebClient.create(vertx, new WebClientOptions());
        OAuth2Auth oauth2 = Auth0Auth.create(
                vertx,
                Auth0Credentials.CLIENT_ID,
                Auth0Credentials.CLIENT_SECRET,
                Auth0Credentials.TENANT,
                Auth0Credentials.AUDIENCE);

        Oauth2Credentials credentials = new Oauth2Credentials()
                .setUsername(Auth0Credentials.CLIENT_ID)
                .setPassword(Auth0Credentials.CLIENT_SECRET)
                .setFlow(OAuth2FlowType.CLIENT);
        OAuth2WebClient authClient = OAuth2WebClient
                .create(client, oauth2)
                .withCredentials(credentials);

         // Here goes an authenticated call

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.

1 participant