SlideShare a Scribd company logo
Django User Management
Spin
& Social Authentication
Before we get started …
Before We Get Started …
Here’s something you should know about
▸ Class-based Views
▸ Mixins
▸ Django Forms
▸ Custom field widgets
▸ Django Templates
▸ tags & filters
Before We Get Started …
Source code of today’s class
▸ git clone https://github.com/spin/eshop.git
▸ cd eshop
▸ git checkout course6
▸ Create virtual environment
▸ pip install -r base.txt
▸ python manage.py migrate
Let’s get started …
Django User Authentication
Social Authentication in Django
Django User Authentication
Social Authentication in Django
Django User Authentication
Authentication & Authorisation
▸ Authentication
▸ Who you are?
▸ Authorisation
▸ What you can do?
Django User Authentication
Django Authentication System
▸ Users
▸ Forms
▸ Views
▸ Permissions
▸ Groups
Django User Authentication
Prerequisites
▸ settings.INSTALLED_APPS
▸ django.contrib.auth
▸ django.contrib.contenttypes
▸ settings.MIDDLEWARE_CLASSES
▸ django.contrib.auth.middleware.AuthenticationMiddleware
Django User Authentication
Prerequisites
Django User Authentication
Prerequisites
Django User Authentication
Django Authentication System
▸ Built-in Views
▸ login()
▸ logout()
▸ password_change()
▸ password_reset()
▸ …
Django User Authentication
Django Authentication System
▸ Built-in Forms
▸ AuthenticationForm
▸ UserCreationForm
▸ UserChangeForm
▸ PasswordResetForm
▸ …
Django User Authentication
Django Authentication System
▸ Built-in Forms
▸ AuthenticationForm
▸ UserCreationForm
▸ UserChangeForm
▸ PasswordResetForm
▸ …
Django User Authentication
Django Authentication System
▸ Templates
▸ No built-in templates for these views
▸ Create your own !
Django User Authentication
Django Authentication System
▸ URLConf
▸ url('^', include('django.contrib.auth.urls')),
Django User Authentication
Django Authentication System
▸ URLConf
▸ url('^', include('django.contrib.auth.urls')),
Django User Authentication
Django Authentication System
▸ Restrict access to views
▸ FBV : django.contrib.auth.decorators.login_required
▸ CBV : django.contrib.auth.mixins.LoginRequiredMixin
Django User Authentication
Django Authentication System
▸ settings
▸ LOGIN_REDIRECT_URL
▸ default = ‘/accounts/profile/’
▸ LOGIN_URL
▸ default = ‘/accounts/login/’
▸ LOGOUT_REDIRECT_URL
▸ default = None
User Login
Django User Authentication
User Login
Django User Authentication
User Login - Create new app
▸ Create new app `members`
▸ python manage.py startapp members
Django User Authentication
User Login - Add Login View
▸ bookshop/urls.py
Django User Authentication
User Login - Add Login View
▸ bookshop/urls.py
Django User Authentication
User Login - Create template
▸ templates/members/login.html
Django User Authentication
User Login - Create template
▸ templates/members/login.html
Django User Authentication
User Login - Create custom login form
▸ members/forms.py
Django User Authentication
User Login - Create custom login form
▸ members/forms.py
User Logout
Django User Authentication
User Logout - Add Logout View
▸ bookshop/urls.py
Django User Authentication
User Logout - Add Logout View
▸ bookshop/urls.py
User Profile Page
Django User Authentication
User Profile Page
Django User Authentication
User Profile Page - Create view
▸ members/views.py
Django User Authentication
User Profile Page - Create view
▸ members/views.py
Django User Authentication
User Profile Page - Create view
▸ members/views.py
Django User Authentication
User Profile Page - Create view
▸ members/views.py
Django User Authentication
User Profile Page - Create view
▸ members/views.py
Django User Authentication
User Profile Page - URLConf
▸ bookshop/urls.py
▸ members/urls.py
Account Info Dropdown
Django User Authentication
Account Info Dropdown
Django User Authentication
Account Info Dropdown
Django User Authentication
Account Info Dropdown
▸ account_dropdown.html
▸ {% if request.user.is_authenticated %}
▸ {% url 'members:profile' pk=request.user.id %}
▸ {% url 'logout' %}
▸ {% url 'members:registration' %}
▸ {% url 'login' %}?next={% url 'home' %}
User Registration
Django User Authentication
User Registration
Django User Authentication
User Registration - Create view
▸ members/views.py
Django User Authentication
User Registration - Create view
▸ members/views.py
Django User Authentication
User Registration - Create view
▸ members/views.py
Django User Authentication
User Registration - URLConf
▸ members/urls.py
Django User Authentication
User Registration - Create registration form
▸ members/forms.py
Django User Authentication
User Registration - Create registration form
▸ members/forms.py
Django User Authentication
Social Authentication in Django
Social Authentication In Django
Python Social Auth
▸ https://github.com/python-social-auth
▸ Social authentication and authorization mechanism for
Python projects
▸ Supporting protocols like
▸ OAuth (1 and 2)
▸ OpenId
▸ …
Social Authentication In Django
Python Social Auth
▸ Supporting frameworks
▸ Django
▸ Flask
▸ Pyramid
▸ WebPy
▸ …
Social Authentication In Django
Python Social Auth
▸ Concepts
▸ Authentication
▸ Association
▸ Disconnection
Social Authentication In Django
Python Social Auth
▸ Components
▸ Pipelines
▸ Strategies
▸ Backends
Social Authentication In Django
Python Social Auth - Pipelines
▸ A list of functions which :
▸ Go through the steps of the authentication process
▸ Build up data about the user
Social Authentication In Django
Python Social Auth - Authentication Pipelines
Social Authentication In Django
Python Social Auth - Authentication Pipelines
Social Authentication In Django
Python Social Auth - Authentication Pipelines
Social Authentication In Django
Python Social Auth - Authentication Pipelines
Social Authentication In Django
Python Social Auth - Disconnection Pipelines
Social Authentication In Django
Python Social Auth - Strategies
▸ Encapsulate different frameworks capabilities under a
common API.
▸ Django
▸ Flask
▸ …
Social Authentication In Django
Python Social Auth - Backends
▸ Implement Authentication mechanism for different
services
▸ OAuth for Facebook
▸ OAuth2 for Instagram
▸ OpenID for Google
▸ …
Prerequisites
Social Authentication In Django
Prerequisites
▸ Social accounts (e.g Facebook)
▸ Set hostname (localhost won’t work in some cases)
▸ /etc/hosts
Social Authentication In Django
Prerequisites
▸ Social accounts (e.g Facebook)
▸ Set hostname (localhost won’t work in some cases)
▸ /etc/hosts
Facebook Login
Social Authentication In Django
Facebook Login
Social Authentication In Django
Facebook Login - Create App
▸ https://developers.facebook.com/apps/
Social Authentication In Django
Facebook Login - Create App
▸ https://developers.facebook.com/apps/
Social Authentication In Django
Facebook Login - Create App
Social Authentication In Django
Facebook Login - Install Package
▸ Install Python Social Auth for Django
▸ pip install social-auth-app-django
Social Authentication In Django
Facebook Login - Settings
▸ INSTALLED_APPS
▸ social_django
▸ AUTHENTICATION_BACKENDS
▸ social_core.backends.facebook.FacebookOAuth2
▸ django.contrib.auth.backends.ModelBackend
▸ SOCIAL_AUTH_URL_NAMESPACE = 'social'
Social Authentication In Django
Facebook Login - Settings
▸ SOCIAL_AUTH_FACEBOOK_KEY
▸ SOCIAL_AUTH_FACEBOOK_SECRET
Social Authentication In Django
Facebook Login - Settings
▸ SOCIAL_AUTH_FACEBOOK_KEY
▸ SOCIAL_AUTH_FACEBOOK_SECRET
Social Authentication In Django
Facebook Login - Settings
▸ SOCIAL_AUTH_FACEBOOK_KEY
▸ SOCIAL_AUTH_FACEBOOK_SECRET
Social Authentication In Django
Facebook Login - Settings
▸ SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
▸ SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS
Social Authentication In Django
Facebook Login - Settings
▸ SOCIAL_AUTH_PIPELINE
▸ Use default value
▸ SOCIAL_AUTH_DISCONNECT_PIPELINE
▸ Disable “allowed_to_disconnect”
Social Authentication In Django
Facebook Login - URLConf
▸ bookshop/urls.py
Social Authentication In Django
Facebook Login - URLConf
▸ bookshop/urls.py
Social Authentication In Django
Facebook Login - URLConf
▸ bookshop/urls.py
Social Authentication In Django
Facebook Login - Update login page
▸ Social buttons
▸ https://lipis.github.io/bootstrap-social/
Social Authentication In Django
Facebook Login - Update login page
▸ templates/members/login.html
Facebook Disconnect
Social Authentication In Django
Facebook Disconnect
Social Authentication In Django
Facebook Disconnect
Social Authentication In Django
Facebook Disconnect - Add disconnect button
▸ templates/members/profile.html
Hands on
Hands On
Django User Authentication
▸ Add “Change Password” functionality
▸ Auth Views
▸ django.contrib.auth.views.password_change
▸ django.contrib.auth.views.password_change_done
▸ Forms
▸ django.contrib.auth.forms.PasswordChangeForm
Hands On
Social Authentication In Django
▸ Add Twitter Login
▸ Add settings for Twitter Auth
▸ Add Twitter Auth Button to the Login Page

More Related Content

PPT
Django
PPTX
Django - Python MVC Framework
PPTX
Pytest KT.pptx
PDF
Web Development with Python and Django
PDF
Flask Introduction - Python Meetup
PDF
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
ODP
Django for Beginners
PPTX
Python/Flask Presentation
Django
Django - Python MVC Framework
Pytest KT.pptx
Web Development with Python and Django
Flask Introduction - Python Meetup
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
Django for Beginners
Python/Flask Presentation

What's hot (20)

PDF
ORM in Django
PDF
3.2 javascript regex
PPTX
PHP Presentation
PDF
A Basic Django Introduction
PPTX
Django Framework Overview forNon-Python Developers
PPTX
Flask – Python
PPTX
Angular Directives
PPTX
REST Easy with Django-Rest-Framework
PPTX
Node js for beginners
PPT
Collections Framework
PDF
ZgPHP 97 - Microservice architecture in Laravel
PDF
What is JavaScript? Edureka
PPTX
Android share preferences
PDF
API for Beginners
PDF
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
PPTX
Web development with django - Basics Presentation
PPTX
Redis Streams for Event-Driven Microservices
PDF
Lecture 01 - Basic Concept About OOP With Python
PPT
Introduction to the Web API
PDF
Building an API with Django and Django REST Framework
ORM in Django
3.2 javascript regex
PHP Presentation
A Basic Django Introduction
Django Framework Overview forNon-Python Developers
Flask – Python
Angular Directives
REST Easy with Django-Rest-Framework
Node js for beginners
Collections Framework
ZgPHP 97 - Microservice architecture in Laravel
What is JavaScript? Edureka
Android share preferences
API for Beginners
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Web development with django - Basics Presentation
Redis Streams for Event-Driven Microservices
Lecture 01 - Basic Concept About OOP With Python
Introduction to the Web API
Building an API with Django and Django REST Framework
Ad

Similar to Django User Management & Social Authentication (20)

PPTX
Social login integration
PDF
Angular 11 google social login or sign in tutorial using angularx social-login
PDF
Tracking across devices
PDF
Introduction to development with Django web framework
PPTX
Advanced Google Analytics
PDF
Virtual Environment and Web development using Django
DOCX
What is Full Stack with Django and how to start learning It.docx
PDF
How to implement sso using o auth in golang application
PPTX
Getting Started with GitHub Security.pptx
PDF
Django Third party packages
PDF
DIY in 5 Minutes: Testing Django App with Pytest
PDF
Passwords suck, but centralized proprietary services are not the answer
PPTX
Github security bug bounty hunting
PPTX
Django Level Five Django Level Five.pptx
ODP
Marek Kuziel - Deploying Django with Buildout
PDF
Frappe ERPNext Open Day February 2014
PDF
Google Analytics - OptSus Marketing
PPT
iGoogle Gadgets @ Your Library
PDF
The state of navigator.register protocolhandler
PDF
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
Social login integration
Angular 11 google social login or sign in tutorial using angularx social-login
Tracking across devices
Introduction to development with Django web framework
Advanced Google Analytics
Virtual Environment and Web development using Django
What is Full Stack with Django and how to start learning It.docx
How to implement sso using o auth in golang application
Getting Started with GitHub Security.pptx
Django Third party packages
DIY in 5 Minutes: Testing Django App with Pytest
Passwords suck, but centralized proprietary services are not the answer
Github security bug bounty hunting
Django Level Five Django Level Five.pptx
Marek Kuziel - Deploying Django with Buildout
Frappe ERPNext Open Day February 2014
Google Analytics - OptSus Marketing
iGoogle Gadgets @ Your Library
The state of navigator.register protocolhandler
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
Ad

More from Spin Lai (6)

PDF
Django class based views for beginners
PDF
Bdd for legacy system
PDF
Two scoops of Django - Security Best Practices
PDF
Speed up your web development
PDF
Hitcon2013 overview
PDF
The django book - Chap10 : Advanced Models
Django class based views for beginners
Bdd for legacy system
Two scoops of Django - Security Best Practices
Speed up your web development
Hitcon2013 overview
The django book - Chap10 : Advanced Models

Recently uploaded (20)

PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Digital Strategies for Manufacturing Companies
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
history of c programming in notes for students .pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
System and Network Administraation Chapter 3
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
Odoo Companies in India – Driving Business Transformation.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Odoo POS Development Services by CandidRoot Solutions
Understanding Forklifts - TECH EHS Solution
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Digital Strategies for Manufacturing Companies
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
history of c programming in notes for students .pptx
Design an Analysis of Algorithms I-SECS-1021-03
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Which alternative to Crystal Reports is best for small or large businesses.pdf
Reimagine Home Health with the Power of Agentic AI​
Navsoft: AI-Powered Business Solutions & Custom Software Development
System and Network Administraation Chapter 3
Wondershare Filmora 15 Crack With Activation Key [2025

Django User Management & Social Authentication