.setClientID("client-id") .setClientSecret("client-secret") .setSite("http://localhost:10000"));
.setClientID("client-id") .setClientSecret("client-secret") .setSite("http://localhost:10000"));
.setClientID("client-id") .setClientSecret("client-secret") .setSite("http://localhost:10000"));
/** * 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 Foursquare * * @param clientId the client id given to you by Foursquare * @param clientSecret the client secret given to you by Foursquare * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://foursquare.com") .setTokenPath("/oauth2/access_token") .setAuthorizationPath("/oauth2/authenticate") .setUserInfoPath("/users/self") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for SoundCloud * * @param clientId the client id given to you by SoundCloud * @param clientSecret the client secret given to you by SoundCloud * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://api.soundcloud.com") .setTokenPath("/oauth2/token") .setAuthorizationPath("/connect") .setUserInfoPath("/me.json") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for live.com * * @param clientId the client id given to you by live.com * @param clientSecret the client secret given to you by live.com * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://login.live.com") .setTokenPath("/oauth20_token.srf") .setAuthorizationPath("/oauth20_authorize.srf") .setScopeSeparator(" ") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for Heroku * * @param clientId the client id given to you by Heroku * @param clientSecret the client secret given to you by Heroku * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://id.heroku.com") .setTokenPath("/oauth/token") .setAuthorizationPath("/oauth/authorize") .setScopeSeparator(" ") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for Mailchimp * * @param clientId the client id given to you by Mailchimp * @param clientSecret the client secret given to you by Mailchimp * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://login.mailchimp.com") .setTokenPath("/oauth2/token") .setAuthorizationPath("/oauth2/authorize") .setUserInfoPath("/oauth2/metadata") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for Twitter * * @param clientId the client id given to you by Twitter * @param clientSecret the client secret given to you by Twitter * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://api.twitter.com") .setTokenPath("/oauth/access_token") .setAuthorizationPath("/oauth/authorize") .setUserInfoPath("/1.1/users/show.json") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for CloudFoundry UAA * * @param clientId the client id given to you by CloudFoundry UAA * @param clientSecret the client secret given to you by CloudFoundry UAA * @param uuaURL the url to your UUA server instance * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, String uuaURL, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite(uuaURL) .setTokenPath("/oauth/token") .setAuthorizationPath("/oauth/authorize") .setScopeSeparator(" ") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for Salesforce * * @param clientId the client id given to you by Salesforce * @param clientSecret the client secret given to you by Salesforce * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, new OAuth2ClientOptions(httpClientOptions) .setFlow(OAuth2FlowType.AUTH_CODE) .setSite("http://login.salesforce.com") .setTokenPath("/services/oauth2/token") .setAuthorizationPath("/services/oauth2/authorize") .setScopeSeparator("+") .setClientID(clientId) .setClientSecret(clientSecret)); }
/** * Create a OAuth2Auth provider for Stripe * * @param clientId the client id given to you by Stripe * @param clientSecret the client secret given to you by Stripe * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://connect.stripe.com") .setTokenPath("/oauth2/token") .setAuthorizationPath("/oauth2/authorize") .setUserInfoPath("/v1/account") .setScopeSeparator(" ") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for App.net * * @param clientId the client id given to you by box.com * @param clientSecret the client secret given to you by box.com * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://account.box.com") .setTokenPath("/api/oauth2/token") .setAuthorizationPath("/api/oauth2/authorize") .setUserInfoPath("/users/me") .setScopeSeparator(" ") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for Facebook * * @param clientId the client id given to you by Facebook * @param clientSecret the client secret given to you by Facebook * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://www.facebook.com") .setTokenPath("https://graph.facebook.com/oauth/access_token") .setAuthorizationPath("/dialog/oauth") .setUserInfoPath("https://graph.facebook.com/me") .setScopeSeparator(",") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for LinkedIn * * @param clientId the client id given to you by LinkedIn * @param clientSecret the client secret given to you by LinkedIn * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://www.linkedin.com") .setTokenPath("/uas/oauth2/accessToken") .setAuthorizationPath("/uas/oauth2/authorization") .setUserInfoPath("/people/~") .setScopeSeparator(" ") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for Dropbox * * @param clientId the client id given to you by Dropbox * @param clientSecret the client secret given to you by Dropbox * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://www.dropbox.com") .setTokenPath("/oauth2/token") .setAuthorizationPath("/oauth2/authorize") .setRevocationPath("/oauth2/token/revoke") .setUserInfoPath("/account/info") .setClientID(clientId) .setClientSecret(clientSecret)); } }
/** * Create a OAuth2Auth provider for Instagram * * @param clientId the client id given to you by Instagram * @param clientSecret the client secret given to you by Instagram * @param httpClientOptions custom http client options */ static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) { return OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions(httpClientOptions) .setSite("https://api.instagram.com") .setTokenPath("/oauth/access_token") .setAuthorizationPath("/oauth/authorize") .setUserInfoPath("/v1/users/self") .setScopeSeparator(" ") .setClientID(clientId) .setClientSecret(clientSecret)); } }
@Test public void unknownHost() { OAuth2Auth auth = OAuth2Auth.create(vertx, OAuth2FlowType.AUTH_CODE, new OAuth2ClientOptions() .setClientID("client-id") .setClientSecret("client-secret") .setSite("http://zlouklfoux.net.com.info.pimpo.molo")); auth.authenticate(tokenConfig, res -> { if (res.failed()) { assertThat(res.cause(), instanceOf(UnknownHostException.class)); testComplete(); } else { fail("Should have failed"); } }); await(); } }
@Before public void setUp(TestContext should) { final Async test = should.async(); OAuth2ClientOptions options = new OAuth2ClientOptions() .setFlow(OAuth2FlowType.PASSWORD) .setSite(site + "/auth/realms/vertx-test") .setClientID("public-client"); options.setTrustAll(true); KeycloakAuth.discover( rule.vertx(), options, discover -> { should.assertTrue(discover.succeeded()); keycloak = discover.result(); test.complete(); }); }