Commit e472bd0c authored by Nico Vermaas's avatar Nico Vermaas

cherry picking AAI from Zooniverse branch

parent e5507315
Pipeline #9768 passed with stages
in 5 minutes and 13 seconds
......@@ -63,9 +63,10 @@ class EsapUserProfileViewSet(viewsets.ModelViewSet):
# 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 = 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',
......
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