A reusable application to allow users of your Django application to "authenticate" against your Salsa user store.
-
Add
salsa_auth
to yourINSTALLED_APPS
:INSTALLED_APPS = [ ... 'salsa_auth', ]
-
Include the
salsa_auth
URLs in your project URL conf:path('salsa/', include('salsa_auth.urls')),
-
Run
python manage.py migrate
to create thesalsa_auth
models. -
Add the following to your project settings, being sure to fill in real values.
# Configure Django email backend: https://docs.djangoproject.com/en/2.2/topics/email/#smtp-backend EMAIL_USE_TLS = True EMAIL_HOST = '' # e.g., smtp.gmail.com EMAIL_HOST_USER = '' # e.g., [email protected] EMAIL_HOST_PASSWORD = '' EMAIL_PORT = 0 # e.g., 587 DEFAULT_FROM_EMAIL = '' # e.g., 'DataMade <[email protected]>' # Configure salsa_auth SALSA_AUTH_API_KEY = '' # https://help.salsalabs.com/hc/en-us/articles/224470007-Getting-Started#acquiring-a-token # Name and domain for cookie set for authorized users SALSA_AUTH_COOKIE_NAME = '' # e.g., salsa-auth SALSA_AUTH_COOKIE_DOMAIN = '' # e.g., datamade.us # Location to which user will be redirected on authorization SALSA_AUTH_REDIRECT_LOCATION = '/'
-
Include Bootstrap Mobile Fullscreen Modals, authentication modals, and required JavaScript in templates that require login.
<link href="{% static 'css/bootstrap-fs-modal.css' %}" rel="stylesheet"> ... {% include 'auth_modals.html' %} ... <script src="{% static 'js/render_salsa_auth.js' %}"></script> {% if messages %} <script type="text/javascript"> $('#messageModal').modal() </script> {% endif %}
-
Trigger the login or signup modal.
$('#loginModal').modal()