From 9aafce4e00634161ecf3c673810b83bf2b940c95 Mon Sep 17 00:00:00 2001 From: Mohamed El-Kalioby Date: Fri, 15 Mar 2019 14:11:33 +0300 Subject: [PATCH] Updated README.md --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 2 ++ setup.py | 2 +- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 86ad326..0b0d8d1 100644 --- a/README.md +++ b/README.md @@ -101,3 +101,44 @@ Depends on ```
  • Security
  • ``` For Example, See https://github.com/mkalioby/AutoDeploy/commit/5f1d94b1804e0aa33c79e9e8530ce849d9eb78cc in AutDeploy Project + +# Going Passwordless + +To be able to go passwordless for returning users, create a cookie named 'base_username' containing username as shown in snippet below +```python + response = render(request, 'Dashboard.html', context)) + if request.session.get("mfa",{}).get("verified",False) and getattr(settings,"MFA_QUICKLOGIN",False): + if request.session["mfa"]["method"]!="Trusted Device": + response.set_cookie("base_username", request.user.username, path="/",max_age = 15*24*60*60) + return response +``` + +Second, update the GET part of your login view +```python + if "mfa" in settings.INSTALLED_APPS and getattr(settings,"MFA_QUICKLOGIN",False) and request.COOKIES.get('base_username'): + username=request.COOKIES.get('base_username') + from mfa.helpers import has_mfa + res = has_mfa(username = username,request=request,) + if res: return res + ## continue and return the form. +``` +# Checking MFA on Client Side + +Sometimes you like to verify that the user is still there so simple you can ask django-mfa2 to check that for you + +```html + {% include 'mfa_check.html' %} +``` +````js +function success_func() { + //logic if mfa check succeeds +} +function fail_func() { + //logic if mfa check fails +} +function some_func() { + recheck_mfa(success_func,fail_func,MUST_BE_MFA) + //MUST_BE_MFA true or false, if the user must has with MFA + } + +```` \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 6746094..a4f0f2c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,8 @@ site_name: MkLorum nav: - Home: index.md + - Installation: installation.md + - Code Changes: change_login.md theme: readthedocs markdown_extensions: - fenced_code diff --git a/setup.py b/setup.py index c11fc56..404cec8 100644 --- a/setup.py +++ b/setup.py @@ -51,5 +51,5 @@ setup( "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules", -], +] )