What is Authentication?
No code on this page. Just the idea - because understanding what we are building before we build it makes everything much easier.
Some doors are open. Some are locked.
Think about your school building. The main entrance is open to everyone - students, visitors, parents. But the staffroom? That needs a key card or a knock and permission. The server room? Only certain people can go in there.
Websites work exactly the same way. Some pages are open to anyone. Some pages should only be accessible to people who have logged in.
Right now your Flask apps have no concept of "logged in" or "not logged in". Anyone who visits any URL can see everything. That is fine for a personal website or a simple tool. But what if you had a dashboard showing private information? Or an admin panel where you can delete records? You would not want just anyone to open that.
That is what this group is about.
What "logging in" actually means
When you log in to a website - any website - here is what happens:
- You type your username and password
- The site looks up your username in its database
- It checks whether the password you entered matches the one stored for that username
- If they match, the site remembers you for the rest of your visit
- That memory is what "being logged in" means
While you are logged in, the site knows who you are on every page you visit. It can show you your own data, let you into locked pages, and greet you by name.
What "logging out" means
Logging out is the site choosing to forget you. It clears that memory. The next time you visit, it does not know who you are and you have to log in again.
What we are going to build
A small Flask site with three pages:
- A home page - anyone can see it, no login needed
- A dashboard page - locked; only logged-in users can see it
- A login page - where users enter their username and password
If someone tries to visit the dashboard without logging in, the site will send them to the login page automatically.
That is it. By the end of this group, you will have a working login system using PookieDB to store users.
← Challenge - Student Registration Next: Setting Up Flask-Login →