Skip to content

[MIRROR] Common base for all SFI projects based on Django.

License

Notifications You must be signed in to change notification settings

sfikrakow/django-sfibase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-sfibase

Common base for all SFI projects based on Django.

What it handles

  • Authentication with SFI SSO and auto user creation
  • Consistent base template with top navbar
  • Perfectionist's touches (e.g. l10n fixes)

Usage

  1. pip install -e git+https://git.sfi.pl/scm/djbase/django-sfibase.git#egg=django-sfibase
  2. In your settings.py:
    • At the top, add:
      from sfi_base.base_settings import *
    • Add to your INSTALLED_APPS list:
      INSTALLED_APPS = [
          # Django apps
          'sfi_base',
          # Your apps
      ]
    • Add to your MIDDLEWARE list:
      MIDDLEWARE = [
          ...
          'mozilla_django_oidc.middleware.SessionRefresh',
          'sfi_base.middleware.TryAuthenticateMiddleware',
          'sfi_base.middleware.ForceAdminInEnglish',
      ]
    • Modify your AUTHENTICATION_BACKENDS:
      AUTHENTICATION_BACKENDS = (
          'django.contrib.auth.backends.ModelBackend',
          'sfi_base.auth.OIDCAuthenticationBackend',
      )
  3. In your urls.py, add:
     from django.urls import include
     from mozilla_django_oidc.urls import OIDCAuthenticateClass
    
     urlpatterns = [
         ...
         path('admin/login/', OIDCAuthenticateClass.as_view()),
         # admin site urls
         path('oidc/', include('sfi_base.urls')),
         ...
     ]
  4. In your base template file, use:
    {% extends "sfi_base/base.html" %}
    

Please note that you need to run your development server using port 8000 - otherwise SSO won't allow you to sign in.

About

[MIRROR] Common base for all SFI projects based on Django.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published