Microsoft Virtual Academy Django in the real world
Security
Security concepts
Secure Sockets Layer (SSL)
Securing the data on the wire
How it works
How it works
Performance concerns
Enabling SSL
Authentication vs Authorization
What's the difference?
Modes of authentication You authenticate by providing some form of an accepted credential Just like in real life, the form can change
In real life
On the web
Django and authentication
Authentication in Django
Authentication is automatically enabled In fact, we already used it when we created the admin site We just need to provide the appropriate views
Creating a login page
The view code
Create a login page
Accessing the current user
Access the current user by using user
Logging out Just like there's a login method... There's a logout method def logout(request): auth.logout(request); return redirect("/");
Adding logout and administration links
User registration
To create a user, we need
The code
Creating a registration page
Requiring authentication
If you just need to ensure the user is logged in You could use user.is_authenticated... But a better way to do it is to use the login_required def submit_session(request): return render(request, 'app/submit_session.html');
What does login_required do?
Ensuring the user is logged on