This shows you the differences between two versions of the page.
ii:labs:s2:03:tasks:02 [2022/05/04 14:05] radu.ciobanu created |
ii:labs:s2:03:tasks:02 [2024/04/01 21:39] (current) florin.stancu created |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== 02. [10p] Running containers ==== | + | ==== 02. [30p] Mock Authentication ==== |
+ | |||
+ | Now, it's the time to add authentication to our website. | ||
+ | |||
+ | * Use a server-side ''session'' to store the user's state (e.g., an ''authenticated'' bool + ''username'' string keys). | ||
+ | * Don't forget to set a ''secret_key'' for the session, otherwise it won't work! | ||
+ | * Write the Flask functions for ''/login'' and ''/logout'' with the appropriate checks / actions. | ||
+ | * You can either use the included ''login.html'' template page, or roll out your own! | ||
+ | * Check out the input names inside the ''<form>''! | ||
+ | * Hint: you can also set the ''authenticated'' variable inside the Jinja template to conditionally display the user's status. | ||
+ | * You can use a Flask [[https://flask.palletsprojects.com/en/3.0.x/templating/#context-processors|context processor]] to avoid needless code duplication; | ||
+ | * //Alternative//: the ''session'' is readily available inside Jinja2 templates! | ||
+ |