Skip to content

Commit

Permalink
Add flags for login services (#2335)
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikek authored Oct 11, 2024
1 parent 304d7d9 commit 952e192
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
9 changes: 9 additions & 0 deletions ESSArch_Core/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ def login_services(req):
if getattr(settings, 'ENABLE_SSO_LOGIN', False) or getattr(settings, 'ENABLE_ADFS_LOGIN', False):
services.append('sso')

if getattr(settings, 'ENABLE_SSO_WIA_LOGIN', False):
services.append('sso_wia')

if getattr(settings, 'ENABLE_LDAP_LOGIN', False):
services.append('ldap')

if getattr(settings, 'ENABLE_FORM_LOGIN', True):
services.append('form')

return Response(services)


Expand Down
4 changes: 2 additions & 2 deletions ESSArch_Core/essxml/ProfileMaker/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def post(self, request, *args, **kwargs):
if templatePackage.objects.filter(pk=name).exists():
return HttpResponse('ERROR: templatePackage with name "' + name + '" already exists!')

from requests.packages.urllib3.exceptions import (
from urllib3.exceptions import (
InsecurePlatformWarning,
InsecureRequestWarning,
)
Expand Down Expand Up @@ -539,7 +539,7 @@ def post(self, request, *args, **kwargs):
prefix = form.cleaned_data.get('namespace_prefix')
schema = form.cleaned_data.get('schema')

from requests.packages.urllib3.exceptions import (
from urllib3.exceptions import (
InsecurePlatformWarning,
InsecureRequestWarning,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const loginCtrl = [
$scope.auth_services = response.data;
});

$scope.saml2login = function () {
window.location.replace('/saml2/login/');
};

$scope.login = function (formData) {
$scope.error = null;
Validate.form_validation(formData, $scope.errors);
Expand Down
27 changes: 16 additions & 11 deletions ESSArch_Core/frontend/static/frontend/views/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@
<h3>{{ model.app }}</h3>
</div>
<div class="login-body">
<div ng-if="auth_services.length > 0">
<div class="auth-services-container">
<a
ng-if="auth_services.includes('sso')"
href="/saml2/login/"
class="login-service-button login-service-sso"
><i aria-hidden="true"></i>{{ "SSO" | translate }}</a
>
</div>
<div class="or-container">
<div ng-if="auth_services.includes('sso')" class="auth-services-container">
<a
ng-if="auth_services.includes('sso')"
href="/saml2/login/"
class="login-service-button login-service-sso"
><i aria-hidden="true"></i>{{ "SSO" | translate }}</a
>
<div ng-if="auth_services.includes('sso_wia') && !auth_services.includes('form')">{{ saml2login() }}</div>
<div ng-if="auth_services.includes('form')" class="or-container">
<hr class="or-line" />
<div class="or-text">{{ "OR" | translate }}</div>
</div>
</div>
<form role="form" ng-submit="login(loginForm)" name="loginForm" novalidate>
<form
ng-if="auth_services.includes('form')"
role="form"
ng-submit="login(loginForm)"
name="loginForm"
novalidate
>
<div class="form-group">
<label for="id_username">{{ "USERNAME" | translate }}</label>
<input
Expand Down
2 changes: 1 addition & 1 deletion ESSArch_Core/ip/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def get_lock_key(self):
def is_locked(self):
return self.get_lock_key() in cache

def get_permissions(self, user: User, checker=None):
def get_permissions(self, user=User, checker=None):
if checker is not None:
return checker.get_perms(self)
return user.get_all_permissions(self)
Expand Down

0 comments on commit 952e192

Please sign in to comment.