Clemens Wolff 6 years ago
parent
commit
80f386d85a
4 changed files with 14 additions and 2 deletions
  1. 5
      app/app/settings.py
  2. 8
      app/server/templates/login.html
  3. 1
      app/server/views.py
  4. 2
      requirements.txt

5
app/app/settings.py

@ -92,12 +92,17 @@ WSGI_APPLICATION = 'app.wsgi.application'
AUTHENTICATION_BACKENDS = [
'social_core.backends.github.GithubOAuth2',
'social_core.backends.azuread_tenant.AzureADTenantOAuth2',
'django.contrib.auth.backends.ModelBackend',
]
SOCIAL_AUTH_GITHUB_KEY = os.getenv('OAUTH_GITHUB_KEY')
SOCIAL_AUTH_GITHUB_SECRET = os.getenv('OAUTH_GITHUB_SECRET')
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY = os.getenv('OAUTH_AAD_KEY')
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_SECRET = os.getenv('OAUTH_AAD_SECRET')
SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID = os.getenv('OAUTH_AAD_TENANT')
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases

8
app/server/templates/login.html

@ -53,11 +53,17 @@
<div class="is-divider" data-content="OR"></div>
{% endif %}
{% if github_login %}
<a href="{% url 'social:begin' 'github' %}" class="button is-fullwidth is-middle">
<a href="{% url 'social:begin' 'github' %}" class="button is-fullwidth mb10">
<span class="icon"><i class="fab fa-github"></i></span>
<span>Login with Github</span>
</a>
{% endif %}
{% if aad_login %}
<a href="{% url 'social:begin' 'azuread-tenant-oauth2' %}" class="button is-fullwidth mb10">
<span class="icon"><i class="fab fa-microsoft"></i></span>
<span>Login with Active Directory</span>
</a>
{% endif %}
</div>
</div>
</div>

1
app/server/views.py

@ -185,6 +185,7 @@ class LoginView(BaseLoginView):
redirect_authenticated_user = True
extra_context = {
'github_login': bool(settings.SOCIAL_AUTH_GITHUB_KEY),
'aad_login': bool(settings.SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID),
}
def get_context_data(self, **kwargs):

2
requirements.txt

@ -13,7 +13,7 @@ python-dateutil==2.7.3
pytz==2018.4
six==1.11.0
social-auth-app-django==3.1.0
social-auth-core==3.0.0
social-auth-core[azuread]==3.0.0
text-unidecode==1.2
tornado==5.0.2
whitenoise==3.3.1
Loading…
Cancel
Save