From the course: Build REST APIs with FastAPI
Unlock this course with a free trial
Join today to access over 24,200 courses taught by industry experts.
Security - Python Tutorial
From the course: Build REST APIs with FastAPI
Security
It might surprise you, but not everyone on the internet is nice. And when you're writing an application, you need to be aware of security. And it's not just a job for the sys admins, it's also a job for you to write secure code. Usually, a good start is the OWASP Top 10. They gather the top 10 common mistakes in applications and publish a list. And this list is a very sad list because nothing here is something new. It's been here for a long time, but people are still doing the same mistakes over and over again. For example, broken access control, cryptographic failure, injection like database injections, and others. So let's have a look at an application. Here I have my server, and this is basically a user server. So I can add a user, get a user, and set the icon for a user. So importing FastAPI, and a JSON response, and creating my application. And you can get a user, right? So get user login. The login is a string. And we get the user, and if it's none we return 404, otherwise, we…