/** * 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://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.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); } }
if (config.getSite() == null) { handler.handle(Future.failedFuture("issuer cannot be null")); return; final HttpClientRequest request = makeRequest(vertx, config, HttpMethod.GET, config.getSite() + "/.well-known/openid-configuration", res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); if (issuerEndpoint != null && !config.getSite().equals(issuerEndpoint)) { handler.handle(Future.failedFuture("issuer validation failed: received [" + issuerEndpoint + "]")); return;
/** * Construct the URL to be used to redirect the user to the authorization page of the OAuth "Authorization Server" * * @param params - redirectURI: A String that represents the registered application URI where the user is redirected after authorization. * scope: A String that represents the application privileges. Set to "openid" for OpenID Connect. * scopes: A array of strings that will encoded as a single string "scope" following the provider requirements * state: A String that represents an optional opaque value used by the client to maintain state between the request and the callback. */ @Override public String authorizeURL(JsonObject params) { final JsonObject query = params.copy(); if (query.containsKey("scopes")) { // scopes have been passed as a list so the provider must generate the correct string for it query.put("scope", String.join(config.getScopeSeparator(), query.getJsonArray("scopes").getList())); query.remove("scopes"); } query.put("response_type", "code"); query.put("client_id", config.getClientID()); final String path = config.getAuthorizationPath(); final String url = path.charAt(0) == '/' ? config.getSite() + path : path; return url + '?' + stringify(query); }
final String url = path.charAt(0) == '/' ? config.getSite() + path : path; LOG.debug("Fetching URL: " + url);
clientSecretParameterName = other.getClientSecretParameterName(); site = other.getSite(); clientID = other.getClientID(); clientSecret = other.getClientSecret();