Repository: incubator-airflow
Updated Branches:
  refs/heads/master f1df9575b -> be3d551f7


[AIRFLOW-1115] fix github oauth api URL

Closes #3469 from renzofrigato/airflow_1115


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/be3d551f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/be3d551f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/be3d551f

Branch: refs/heads/master
Commit: be3d551f72e42a19242e3f8e1b1a00a82e1c2eb8
Parents: f1df957
Author: renzofrigato <rfrig...@gmail.com>
Authored: Mon Jun 11 15:13:52 2018 -0700
Committer: Joy Gao <joy...@apache.org>
Committed: Mon Jun 11 15:14:02 2018 -0700

----------------------------------------------------------------------
 .../auth/backends/github_enterprise_auth.py      | 19 ++++++++++---------
 docs/security.rst                                |  9 +++++++++
 2 files changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/be3d551f/airflow/contrib/auth/backends/github_enterprise_auth.py
----------------------------------------------------------------------
diff --git a/airflow/contrib/auth/backends/github_enterprise_auth.py 
b/airflow/contrib/auth/backends/github_enterprise_auth.py
index 3bbcf35..5196725 100644
--- a/airflow/contrib/auth/backends/github_enterprise_auth.py
+++ b/airflow/contrib/auth/backends/github_enterprise_auth.py
@@ -84,17 +84,18 @@ class GHEAuthBackend(object):
         self.login_manager.login_view = 'airflow.login'
         self.flask_app = None
         self.ghe_oauth = None
-        self.api_rev = None
+        self.api_url = None
 
     def ghe_api_route(self, leaf):
-        if not self.api_rev:
-            self.api_rev = get_config_param('api_rev')
-
-        return '/'.join(['https:/',
-                         self.ghe_host,
-                         'api',
-                         self.api_rev,
-                         leaf.strip('/')])
+        if not self.api_url:
+            self.api_url = (
+                'https://api.github.com' if self.ghe_host == 'github.com'
+                else '/'.join(['https:/',
+                               self.ghe_host,
+                               'api',
+                               get_config_param('api_rev')])
+            )
+        return self.api_url + leaf
 
     def init_app(self, flask_app):
         self.flask_app = flask_app

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/be3d551f/docs/security.rst
----------------------------------------------------------------------
diff --git a/docs/security.rst b/docs/security.rst
index 5d459de..3c328d8 100644
--- a/docs/security.rst
+++ b/docs/security.rst
@@ -267,6 +267,15 @@ backend. In order to setup an application:
 6. Click 'Register application'
 7. Copy 'Client ID', 'Client Secret', and your callback route to your 
airflow.cfg according to the above example
 
+Using GHE Authentication with github.com
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+It is possible to use GHE authentication with github.com:
+
+1. `Create an Oauth App 
<https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/>`_
+2. Copy 'Client ID', 'Client Secret' to your airflow.cfg according to the 
above example
+3. Set ``host = github.com`` and ``oauth_callback_route = /oauth/callback`` in 
airflow.cfg
+
 Google Authentication
 '''''''''''''''''''''
 

Reply via email to