Skip to content

Commit

Permalink
Merge pull request #24 from OpenLXP:add-sso
Browse files Browse the repository at this point in the history
add SSO auth
  • Loading branch information
JDTobin authored Aug 21, 2023
2 parents d92103a + a7d2362 commit 8750fa5
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
FROM python:3.7-buster

# install nginx
RUN apt-get update && apt-get install nginx vim -y --no-install-recommends
RUN apt-get update && apt-get install nginx vim libxml2-dev libxmlsec1-dev -y --no-install-recommends
COPY nginx.default /etc/nginx/sites-available/default
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
Expand Down
57 changes: 56 additions & 1 deletion app/openlxp_xss_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
'core.apps.CoreConfig',
'api',
'users',
'social_django',
'openlxp_authentication',
]

MIDDLEWARE = [
Expand Down Expand Up @@ -175,5 +177,58 @@
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
]
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
],
}

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'openlxp_authentication.models.SAMLDBAuth',
)

# openlxp_authentication settings openlxp_authentication documentation:
# https://github.com/OpenLXP/openlxp-authentication#readme
# social_django documentation:
# https://python-social-auth.readthedocs.io/en/latest/index.html
# SOCIAL_AUTH_STRATEGY = 'openlxp_authentication.models.SAMLDBStrategy'
JSONFIELD_ENABLED = True
USER_MODEL = 'users.CustomUser'
SESSION_EXPIRATION = True

if os.environ.get('LOGIN_REDIRECT_URL') is not None:
LOGIN_REDIRECT_URL = os.environ.get('LOGIN_REDIRECT_URL')

if os.environ.get('OVERIDE_HOST') is not None:
OVERIDE_HOST = os.environ.get('OVERIDE_HOST')
BAD_HOST = os.environ.get('BAD_HOST')

if os.environ.get('STRATEGY') is not None:
SOCIAL_AUTH_STRATEGY = os.environ.get('STRATEGY')

SP_ENTITY_ID = os.environ.get('ENTITY_ID')

SP_PUBLIC_CERT = os.environ.get('SP_PUBLIC_CERT')
SP_PRIVATE_KEY = os.environ.get('SP_PRIVATE_KEY')
ORG_INFO = {
"en-US": {
"name": "example",
"displayname": "Example Inc.",
"url": "http://localhost",
}
}
TECHNICAL_CONTACT = {
"givenName": "Tech Person",
"emailAddress": "technical@localhost.com"
}
SUPPORT_CONTACT = {
"givenName": "Support Person",
"emailAddress": "support@localhost.com",
}
USER_ATTRIBUTES = [
"user_permanent_id",
"first_name",
"last_name",
"email"
]
2 changes: 2 additions & 0 deletions app/openlxp_xss_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
url('', include('openlxp_authentication.urls')),
path('admin/', admin.site.urls),
path('api/', include('api.urls')),
path('api/auth/', include('users.urls')),
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ services:
DJANGO_SUPERUSER_PASSWORD: "${DJANGO_SUPERUSER_PASSWORD}"
DJANGO_SUPERUSER_EMAIL: "${DJANGO_SUPERUSER_EMAIL}"
SECRET_KEY_VAL: "${SECRET_KEY_VAL}"
ENTITY_ID: "${ENTITY_ID}"
SP_PUBLIC_CERT: "${SP_PUBLIC_CERT}"
SP_PRIVATE_KEY: "${SP_PRIVATE_KEY}"
BAD_HOST: "${BAD_HOST}"
OVERIDE_HOST: "${OVERIDE_HOST}"
STRATEGY: "${STRATEGY}"
volumes:
- ./app:/opt/app/openlxp-xss
depends_on:
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ ddt>=1.4.2,<1.5.0

django-model-utils>=4.1.1,<4.2.0

openlxp-authentication >=1.1.0, <1.2

requests>=2.25.1,<2.26.0

0 comments on commit 8750fa5

Please sign in to comment.