Commit 6ad18f92 authored by Nico Vermaas's avatar Nico Vermaas

Merge branch 'esap-gateway-query' into 'master'

Esap gateway query

See merge request !55
parents 40ba658a e472bd0c
Pipeline #9772 passed with stages
in 1 minute and 26 seconds
......@@ -58,9 +58,15 @@ class EsapUserProfileViewSet(viewsets.ModelViewSet):
def get_queryset(self):
# Returns nothing if no user_name supplied instead of all
try:
# id_token = self.request.session["oidc_id_token"]
# uid = id_token["iss"]+id_token["sub"]
# preferred_username = id_token["preferred_username"]
# name = id_token["name"]
# access_token = self.request.session["oidc_access_token"]
user = auth.get_user(self.request)
user_email = user.email
return EsapUserProfile.objects.filter(user_email=user_email)
except AttributeError as e:
user_name = self.request.query_params.get("user_name", None)
return EsapUserProfile.objects.filter(user_name=user_name)
from mozilla_django_oidc.auth import OIDCAuthenticationBackend
class MyOIDCAB(OIDCAuthenticationBackend):
# this is an example of overriding a part of the Authentication backend
def verify_claims(self, claims):
print('MyOIDCAB.verify_claims('+str(claims)+')')
verified = super(MyOIDCAB, self).verify_claims(claims)
is_admin = 'admin' in claims.get('group', [])
return True
# return verified and is_admin
\ No newline at end of file
......@@ -45,14 +45,14 @@ INSTALLED_APPS = [
'django_filters',
]
DATABASES = {
'awlofar': {
'ENGINE': 'django.db.backends.oracle',
'NAME': 'awlofar',
'USER': 'AWWORLD',
'PASSWORD': 'WORLD',
}
}
#DATABASES = {
# 'awlofar': {
# 'ENGINE': 'django.db.backends.oracle',
# 'NAME': 'awlofar',
# 'USER': 'AWWORLD',
# 'PASSWORD': 'WORLD',
# }
#}
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
......@@ -207,7 +207,8 @@ LOGGING = {
# use 'mozilla_django_oidc' authentication backend
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'mozilla_django_oidc.auth.OIDCAuthenticationBackend',
#'mozilla_django_oidc.auth.OIDCAuthenticationBackend',
'accounts.my_oidc.MyOIDCAB'
)
OIDC_DRF_AUTH_BACKEND = 'mozilla_django_oidc.auth.OIDCAuthenticationBackend'
......
......@@ -31,6 +31,7 @@ DATABASE_ROUTERS = [
'ida.database_router.IdaRouter',
'rucio.database_router.RucioRouter',
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
......
......@@ -29,7 +29,8 @@ CORS_ORIGIN_ALLOW_ALL = True
# Application definition
# Database
DATABASE_ROUTERS = ['query.database_router.QueryRouter',
DATABASE_ROUTERS = [
'query.database_router.QueryRouter',
'accounts.database_router.AccountsRouter',
'staging.database_router.StagingRouter',
'ida.database_router.IdaRouter',
......
......@@ -70,7 +70,7 @@
</div>
<p class="footer" small>ASTRON - version 16 feb 2021 - 14:15</p>
<p class="footer" small>ASTRON - version 23 feb 2021 - 11:30</p>
{% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment