Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/auth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ Here's an example configuration file with the Github OAuth options:
Replace `<your_client_id>` and `<your_client_secret>` with the actual Client ID and secret obtained from
the Github Settings.

If using Github Enterprise, you can set the `FLOWER_GITHUB_OAUTH_DOMAIN` environment variable to the base URL of your Github Enterprise instance.

See `GitHub OAuth API`_ docs for more info.

.. _Github Settings: https://github.com/settings/applications/new
Expand Down
6 changes: 5 additions & 1 deletion flower/views/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class GithubLoginHandler(BaseHandler, tornado.auth.OAuth2Mixin):

_OAUTH_DOMAIN = os.getenv(
"FLOWER_GITHUB_OAUTH_DOMAIN", "github.com")
if _OAUTH_DOMAIN == "github.com":
_OAUTH_API_URL = f'https://api.{_OAUTH_DOMAIN}/user/emails'
Comment thread
ahmed-wajid marked this conversation as resolved.
Outdated
else:
_OAUTH_API_URL = f'https://{_OAUTH_DOMAIN}/api/v3/user/emails'
_OAUTH_AUTHORIZE_URL = f'https://{_OAUTH_DOMAIN}/login/oauth/authorize'
_OAUTH_ACCESS_TOKEN_URL = f'https://{_OAUTH_DOMAIN}/login/oauth/access_token'
Comment thread
ahmed-wajid marked this conversation as resolved.
Outdated
_OAUTH_NO_CALLBACKS = False
Expand Down Expand Up @@ -138,7 +142,7 @@ async def _on_auth(self, user):
access_token = user['access_token']

response = await self.get_auth_http_client().fetch(
f'https://api.{self._OAUTH_DOMAIN}/user/emails',
self._OAUTH_API_URL,
headers={'Authorization': 'token ' + access_token,
'User-agent': 'Tornado auth'})

Expand Down