@ -34,11 +34,12 @@ Once installed there are a few required changes in Django settings:
@@ -34,11 +34,12 @@ Once installed there are a few required changes in Django settings:
```
INSTALLED_APPS = [
...,
'sqrl',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.staticfiles',
...,
'sqrl',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.staticfiles',
...
]
```
@ -46,9 +47,10 @@ INSTALLED_APPS = [
@@ -46,9 +47,10 @@ INSTALLED_APPS = [
```
MIDDLEWARE_CLASSES = [
...
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
...
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
...
]
```
@ -57,7 +59,7 @@ MIDDLEWARE_CLASSES = [
@@ -57,7 +59,7 @@ MIDDLEWARE_CLASSES = [
```
AUTHENTICATION_BACKENDS = [
'sqrl.backends.SQRLModelBackend',
'sqrl.backends.SQRLModelBackend',
]
```
@ -69,10 +71,10 @@ overwrites some of them.
@@ -69,10 +71,10 @@ overwrites some of them.
```
INSTALLED_APPS = [
...,
'sqrl',
'django.contrib.admin',
...
...,
'sqrl',
'django.contrib.admin',
...
]
```
@ -85,7 +87,7 @@ to explicitly extend from `django.contrib.admin` `base.html` template:
@@ -85,7 +87,7 @@ to explicitly extend from `django.contrib.admin` `base.html` template:
import os
import django
TEMPLATE_DIRS = [
os.path.dirname(django.__file__),
os.path.dirname(django.__file__),
]
```
@ -97,9 +99,9 @@ All of SQRL functionality is enabled by adding its URLs to the root URL config:
@@ -97,9 +99,9 @@ All of SQRL functionality is enabled by adding its URLs to the root URL config:
from django.urls import path, include
urlpatterns = [
...
path('sqrl/', include('sqrl.urls', namespace="sqrl")),
...
...
path('sqrl/', include('sqrl.urls', namespace="sqrl")),
...
]
```
@ -114,13 +116,42 @@ page with three simple template tags:
@@ -114,13 +116,42 @@ page with three simple template tags:
```
{% load sqrl %}
{% sqrl as sqrl_session %}
{% sqrl_login_dropin sqrl_session [[a named redirect]] %}
{% sqrl_login_dropin sqrl_session "named:redirect" %}
```
The `"named:redirect"` is the page that should be redirected to after logging
in. Any name that can be resolved by django's `reverse` function will work. For
example, here are the necessary lines needed to resolve `"app:main"` :
* Main project's `urls.py` :
```
urlpatterns = [
...
path("", include('app.urls', namespace="app"))
...
]
```
* Your `app` 's `urls.py` :
```
urlpatterns = [
...
path("", main_view, name="main")
...
]
```
The [[named redirect]] is the page that should be redirected to after logging
in. Any name that can be resolved by django's `reverse` function will work (i.e.
`path("scheme/", view, name="example")` in the app `app` with namespace "app"
could be selected as `app:example` ).
* Your `main_view` 's template:
```
...
{% load sqrl %}
{% sqrl as sqrl_session %}
{% sqrl_login_dropin sqrl_session "app:main" %}
...
```
These three tags will add a simple element to your login page:
@ -133,7 +164,7 @@ following essential tags:
@@ -133,7 +164,7 @@ following essential tags:
{% load sqrl %}
{% sqrl as sqrl_session %}
< a href = "{{ sqrl_session.sqrl_url }}" >
< div id = "sqrl-qr" data-sqrl = "{{ sqrl_session.sqrl_url }}" > < / div >
< div id = "sqrl-qr" data-sqrl = "{{ sqrl_session.sqrl_url }}" > < / div >
< / a >
< script > SQRL _NEXT = "{{ your desired redirect }}" ; SQRL _CHECK _URL = "{% sqrl_status_url_script_tag sqrl_session %}" < / script >
< script type = "application/javascript" src = "{% static 'sqrl/sqrl.js' %}" > < / script >