From the course: Secure Coding in Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Secure the end point

Solution: Secure the end point - Python Tutorial

From the course: Secure Coding in Python

Start my 1-month free trial

Solution: Secure the end point

(energetic music) - So our goal for this challenge was to secure this small application. And basically there are two issues I see with this code. And the first being that we are using an implicit check for is authenticated. To fix that, we'll add is true after is authenticated. That way we know we're comparing against true and not against something that is truthy or falsey. The main issue that's causing the unauthenticated user to get success equals true is the fact that we are using an assert for core business logic. So let's go ahead and fix that. All I have to do, is do an if statement. So instead of assert, I'll do, if user is authenticated is true colon, and then the rest. I don't even need to do an else. I can just use this return after the block. So why do you see this in code so often? Well, one of the reasons is that try except blocks are very Pythonic in nature. There's a saying in the Python…

Contents