/*
 * Copyright 2020 Red Hat, Inc.
 *
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  and Apache License v2.0 which accompanies this distribution.
 *
 *  The Eclipse Public License is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *
 *  The Apache License v2.0 is available at
 *  http://www.opensource.org/licenses/apache2.0.php
 *
 *  You may elect to redistribute this code under either of these licenses.
 */
package io.vertx.ext.auth.oauth2.providers;

import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.auth.oauth2.OAuth2Auth;
import io.vertx.ext.auth.oauth2.OAuth2Options;
import io.vertx.ext.auth.oauth2.OAuth2FlowType;

/**
 * Simplified factory to create an {@link OAuth2Auth} for GitLab.com.
 *
 * https://gitlab.com/help/api/oauth2.md
 */
@VertxGen
public interface GitLabAuth {

  /**
   * Create a OAuth2Auth provider for GitLab
   *
   * @param clientId the client id given to you by GitLab
   * @param clientSecret the client secret given to you by GitLab
   */
  static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret) {
    return create(vertx, clientId, clientSecret, new HttpClientOptions());
  }

  /**
   * Create a OAuth2Auth provider for GitLab
   *
   * @param clientId the client id given to you by GitLab
   * @param clientSecret the client secret given to you by GitLab
   * @param httpClientOptions custom http client options
   */
  static OAuth2Auth create(Vertx vertx, String clientId, String clientSecret, HttpClientOptions httpClientOptions) {
    return
      OAuth2Auth.create(vertx, new OAuth2Options()
        .setHttpClientOptions(httpClientOptions)
        .setFlow(OAuth2FlowType.AUTH_CODE)
        .setClientID(clientId)
        .setClientSecret(clientSecret)
        .setSite("https://gitlab.com")
        .setTokenPath("/oauth/token")
        .setAuthorizationPath("/oauth/authorize")
        .setUserInfoPath("https://gitlab.com/api/v4/user")
        .setScopeSeparator(" ")
        .setHeaders(new JsonObject()
          .put("User-Agent", "vertx-auth-oauth2")));
  }
}

@@ -940,16 +940,25 @@
 .%0A *%0A * 
+%3Ca href=%22
 https://
@@ -986,16 +986,59 @@
 auth2.md
+%22%3Ehttps://gitlab.com/help/api/oauth2.md%3C/a%3E
 %0A */%0A@Ve
@@ -1117,32 +1117,37 @@
 vider for GitLab
+.com.
 %0A   *%0A   * @para
@@ -1370,16 +1370,38 @@
 e(vertx,
+ %22https://gitlab.com%22,
  clientI
@@ -1498,22 +1498,635 @@
 r GitLab
+.
 %0A   *%0A
+   * This method allows to specify custom GitLab domain.%0A   *%0A   * @param site root URL for the provider without trailing slashes, eg. https://gitlab.com%0A   * @param clientId the client id given to you by GitLab%0A   * @param clientSecret the client secret given to you by GitLab%0A   */%0A  static OAuth2Auth create(Vertx vertx, String site, String clientId, String clientSecret) %7B%0A    return create(vertx, site, clientId, clientSecret, new HttpClientOptions());%0A  %7D%0A%0A  /**%0A   * Create a OAuth2Auth provider for GitLab.%0A   *%0A   * @param site root URL for the provider without trailing slashes, eg. https://gitlab.com%0A
    * @pa
@@ -2335,32 +2335,45 @@
 ate(Vertx vertx,
+ String site,
  String clientId
@@ -2675,36 +2675,20 @@
 setSite(
-%22https://gitlab.com%22
+site
 )%0A      
@@ -2795,34 +2795,16 @@
 foPath(%22
-https://gitlab.com
 /api/v4/

Add method to specify custom gitlab domain