/** * Create a OAuth2Auth provider for OpenID Connect Discovery. The discovery will use the given site in the * configuration options and attempt to load the well known descriptor. * * If the discovered config includes a json web key url, it will be also fetched and the JWKs will be loaded * into the OAuth provider so tokens can be decoded. * @param vertx the vertx instance * @param config the initial config, it should contain a site url * @param handler the instantiated Oauth2 provider instance handler */ public static void discover(io.vertx.rxjava.core.Vertx vertx, OAuth2ClientOptions config, Handler<AsyncResult<io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth>> handler) { io.vertx.ext.auth.oauth2.providers.OpenIDConnectAuth.discover(vertx.getDelegate(), config, new Handler<AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth>>() { public void handle(AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
/** * Create a OAuth2Auth provider for OpenID Connect Discovery. The discovery will use the given site in the * configuration options and attempt to load the well known descriptor. * * If the discovered config includes a json web key url, it will be also fetched and the JWKs will be loaded * into the OAuth provider so tokens can be decoded. * @param vertx the vertx instance * @param config the initial config, it should contain a site url * @param handler the instantiated Oauth2 provider instance handler */ public static void discover(io.vertx.rxjava.core.Vertx vertx, OAuth2ClientOptions config, Handler<AsyncResult<io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth>> handler) { io.vertx.ext.auth.oauth2.providers.OpenIDConnectAuth.discover(vertx.getDelegate(), config, new Handler<AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth>>() { public void handle(AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.auth.oauth2.OAuth2Auth.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
public static void discover(io.vertx.ext.auth.oauth2.providers.OpenIDConnectAuth j_receiver, io.vertx.core.Vertx vertx, java.util.Map<String, Object> config, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth>> handler) { io.vertx.ext.auth.oauth2.providers.OpenIDConnectAuth.discover(vertx, config != null ? new io.vertx.ext.auth.oauth2.OAuth2ClientOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(config)) : null, handler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.ext.auth.oauth2.OAuth2Auth> ar) { handler.handle(ar.map(event -> io.vertx.core.impl.ConversionHelper.fromObject(event))); } } : null); } }
/** * Create a OAuth2Auth provider for OpenID Connect Discovery. The discovery will use the default site in the * configuration options and attempt to load the well known descriptor. If a site is provided (for example when * running on a custom instance) that site will be used to do the lookup. * <p> * If the discovered config includes a json web key url, it will be also fetched and the JWKs will be loaded * into the OAuth provider so tokens can be decoded. * * @param vertx the vertx instance * @param config the initial config * @param handler the instantiated Oauth2 provider instance handler */ static void discover(final Vertx vertx, final OAuth2ClientOptions config, final Handler<AsyncResult<OAuth2Auth>> handler) { final OAuth2ClientOptions options = new OAuth2ClientOptions(config); OpenIDConnectAuth.discover(vertx, options, discover -> { // apply the Keycloak RBAC if (discover.succeeded()) { discover.result().rbacHandler(KeycloakRBAC.create(options)); } handler.handle(discover); }); } }
/** * Create a OAuth2Auth provider for OpenID Connect Discovery. The discovery will use the default site in the * configuration options and attempt to load the well known descriptor. If a site is provided (for example when * running on a custom instance) that site will be used to do the lookup. * <p> * If the discovered config includes a json web key url, it will be also fetched and the JWKs will be loaded * into the OAuth provider so tokens can be decoded. * * @param vertx the vertx instance * @param config the initial config * @param handler the instantiated Oauth2 provider instance handler */ static void discover(final Vertx vertx, final OAuth2ClientOptions config, final Handler<AsyncResult<OAuth2Auth>> handler) { // don't override if already set final String site = config.getSite() == null ? "https://accounts.google.com" : config.getSite(); OpenIDConnectAuth.discover( vertx, new OAuth2ClientOptions(config) .setSite(site) .setUserInfoParameters(new JsonObject() .put("alt", "json")) .setScopeSeparator(" "), handler); }
/** * Create a OAuth2Auth provider for OpenID Connect Discovery. The discovery will use the default site in the * configuration options and attempt to load the well known descriptor. If a site is provided (for example when * running on a custom instance) that site will be used to do the lookup. * <p> * If the discovered config includes a json web key url, it will be also fetched and the JWKs will be loaded * into the OAuth provider so tokens can be decoded. * * @param vertx the vertx instance * @param config the initial config * @param handler the instantiated Oauth2 provider instance handler */ static void discover(final Vertx vertx, final OAuth2ClientOptions config, final Handler<AsyncResult<OAuth2Auth>> handler) { // don't override if already set final String site = config.getSite() == null ? "https://login.salesforce.com" : config.getSite(); OpenIDConnectAuth.discover(vertx, new OAuth2ClientOptions(config) .setSite("https://login.salesforce.com") .setScopeSeparator("+"), handler); } }
/** * Create a OAuth2Auth provider for OpenID Connect Discovery. The discovery will use the default site in the * configuration options and attempt to load the well known descriptor. If a site is provided (for example when * running on a custom instance) that site will be used to do the lookup. * <p> * If the discovered config includes a json web key url, it will be also fetched and the JWKs will be loaded * into the OAuth provider so tokens can be decoded. * * @param vertx the vertx instance * @param config the initial config * @param handler the instantiated Oauth2 provider instance handler */ static void discover(final Vertx vertx, final OAuth2ClientOptions config, final Handler<AsyncResult<OAuth2Auth>> handler) { // don't override if already set final String site = config.getSite() == null ? "https://login.windows.net/common" : config.getSite(); OpenIDConnectAuth.discover( vertx, new OAuth2ClientOptions(config) // Azure OpenId does not return the same url where the request was sent to .setValidateIssuer(false) .setSite(site) .setScopeSeparator(","), handler); } }
public void testFullCycle() { OpenIDConnectAuth.discover( vertx, new OAuth2ClientOptions()
@Ignore @Test public void testDecode() { OpenIDConnectAuth.discover( vertx, new OAuth2ClientOptions() .setClientID("vertx") .setSite("http://localhost:8080/auth/realms/master"), res -> { if (res.failed()) { fail(res.cause()); return; } final OAuth2Auth oidc = res.result(); oidc.decodeToken("borked", res1 -> { if (res1.failed()) { testComplete(); return; } fail("Should not reach this!"); }); }); await(); } }