Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security NachrichtenTrump White House Press Ban Matches 1933 Nazi Law(23.09.2026 um 23:17 Uhr)
IT Security NachrichtenGitLab Email Addresses Can Be Weaponized for Supply Chain Attacks(23.09.2026 um 22:53 Uhr)
IT Security NachrichtenEDR Evasion Stack Helps Process Injection Slip Past Defenses(23.09.2026 um 23:03 Uhr)
IT Security NachrichtenZwei Probleme in Gzip (Ubuntu)(23.09.2026 um 23:08 Uhr)
Malware / Trojaner / VirenNew RemControl Android banking malware targets users in Europe and Canada(23.09.2026 um 23:25 Uhr)
IT Security NachrichtenFAA-Ausfall lähmt US-Flugverkehr im Nordosten(23.09.2026 um 17:26 Uhr)
IT Security NachrichtenApple positioniert neue Macs gegen Nvidia(23.09.2026 um 18:16 Uhr)
IT Security NachrichtenTrump White House Press Ban Matches 1933 Nazi Law(23.09.2026 um 23:17 Uhr)
IT Security NachrichtenGitLab Email Addresses Can Be Weaponized for Supply Chain Attacks(23.09.2026 um 22:53 Uhr)
IT Security NachrichtenEDR Evasion Stack Helps Process Injection Slip Past Defenses(23.09.2026 um 23:03 Uhr)
IT Security NachrichtenZwei Probleme in Gzip (Ubuntu)(23.09.2026 um 23:08 Uhr)
Malware / Trojaner / VirenNew RemControl Android banking malware targets users in Europe and Canada(23.09.2026 um 23:25 Uhr)
IT Security NachrichtenFAA-Ausfall lähmt US-Flugverkehr im Nordosten(23.09.2026 um 17:26 Uhr)
IT Security NachrichtenApple positioniert neue Macs gegen Nvidia(23.09.2026 um 18:16 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

My project 2 : Flask Authentication System(with Python + Flask)

🔐 Flask Authentication System I’ve always been curious about how the websites we use every day are actually built. We constantly interact with features like sign-up, login, and logout, yet most of us never really understand what happ…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

🔐 Flask Authentication System




I’ve always been curious about how the websites we use every day are actually built.
We constantly interact with features like sign-up, login, and logout, yet most of us never really understand what happens behind the scenes.
I was no exception — this curiosity kept growing, and I wanted to experience the structure myself.
So I decided to try building it from scratch, hoping that by doing it hands-on, I could finally understand how these systems really work.






📂 1. Project Structure




auth_blog/
│── main.py
│── users.db (auto-created)
└── templates/
├── home.html
├── signup.html
└── login.html





🧠 2. What This Project Does




  • User sign-up (stores hashed passwords)

  • User login with session management

  • Protected dashboard page using a custom login_required decorator

  • Logout functionality

  • Basic mini blog UI layout



This structure forms the foundation of nearly every modern web application.






🖥️ 3. Backend Code (main.py)





from flask import Flask, render_template, request, redirect, session
import sqlite3
from werkzeug.security import generate_password_hash, check_password_hash

app = Flask(__name__)
app.secret_key = "super_secret_key"

# Login-required decorator
def login_required(func):
def wrapper(*args, **kwargs):
if "user_id" not in session:
return redirect("/login")
return func(*args, **kwargs)
wrapper.__name__ = func.__name__
return wrapper

# Initialize database
def init_db():
conn = sqlite3.connect("users.db")
cur = conn.cursor()
cur.execute("""
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE NOT NULL,
password TEXT NOT NULL
)
""")
conn.commit()
conn.close()

init_db()

# Signup
@app.route("/signup", methods=["GET", "POST"])
def signup():
if request.method == "POST":
username = request.form["username"]
password = request.form["password"]

hashed_pw = generate_password_hash(password)

conn = sqlite3.connect("users.db")
cur = conn.cursor()
try:
cur.execute("INSERT INTO users (username, password) VALUES (?, ?)",
(username, hashed_pw))
conn.commit()
except sqlite3.IntegrityError:
return "Signup failed: Username already exists."
finally:
conn.close()

return redirect("/login")

return render_template("signup.html")

# Login
@app.route("/login", methods=["GET", "POST"])
def login():
if request.method == "POST":
username = request.form["username"]
password = request.form["password"]

conn = sqlite3.connect("users.db")
cur = conn.cursor()
cur.execute("SELECT id, username, password FROM users WHERE username = ?",
(username,))
user = cur.fetchone()
conn.close()

if user and check_password_hash(user[2], password):
session["user_id"] = user[0]
session["username"] = user[1]
return redirect("/dashboard")
else:
return "Login failed: Invalid username or password."

return render_template("login.html")

# Dashboard (protected)
@app.route("/dashboard")
@login_required
def dashboard():
return f"Welcome, {session['username']}! (Dashboard Page)"

# Logout
@app.route("/logout")
def logout():
session.clear()
return redirect("/login")

# Home
@app.route("/")
def home():
return render_template("home.html")

if __name__ == "__main__":
app.run(debug=True)








🖼️ 4. Templates



🏠 home.html





<!DOCTYPE html>
<html>
<head>
<title>Mini Blog</title>
<style>
body { font-family: sans-serif; padding: 20px; background-color: #f4f7f9; }
.post {
border: 1px solid #ddd;
padding: 15px;
margin-bottom: 15px;
border-radius: 8px;
background-color: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.top {
display: flex; justify-content: space-between;
align-items: center; border-bottom: 2px solid #007bff;
margin-bottom: 20px; padding-bottom: 10px;
}
a { text-decoration: none; color: #007bff; font-weight: bold; }
</style>
</head>
<body>

<div class="top">
<h1>Mini Blog Posts</h1>
<a href="/new">Write New Post →</a>
</div>

{% for post in posts %}
<div class="post">
<h3>{{ post[1] }}</h3>
<p>{{ post[2] }}</p>
</div>
{% endfor %}

{% if not posts %}
<p style="color: #6c757d;">No posts yet. Start writing your first entry!</p>
{% endif %}

</body>
</html>








🔑 login.html





<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<style>
body { font-family: sans-serif; padding: 20px; }
form { display: flex; flex-direction: column; width: 300px; gap: 10px; }
input { padding: 10px; border: 1px solid #ccc; border-radius: 4px; }
button { padding: 10px; background: #28a745; color: white;
border: none; border-radius: 4px; cursor: pointer; }
button:hover { background: #1e7e34; }
</style>
</head>
<body>

<h1>Log In</h1>

<form action="/login" method="POST">
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Log In</button>
</form>

</body>
</html>








📝 signup.html





<!DOCTYPE html>
<html>
<head>
<title>Sign Up</title>
<style>
body { font-family: sans-serif; padding: 20px; }
form { display: flex; flex-direction: column; width: 300px; gap: 10px; }
input { padding: 10px; border: 1px solid #ccc; border-radius: 4px; }
button { padding: 10px; background: #007bff; color: white;
border: none; border-radius: 4px; cursor: pointer; }
button:hover { background: #0056b3; }
</style>
</head>
<body>

<h1>Sign Up</h1>

<form action="/signup" method="POST">
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Register</button>
</form>

</body>
</html>








🔧 5. Try It Yourself — Easy Improvements




  • Add post creation to the authenticated dashboard

  • Allow users to edit/delete their posts

  • Add timestamps for posts

  • Add password reset functionality

  • Improve the UI with a CSS stylesheet




These small improvements will help you understand web authentication and backend structure more deeply.
Try making one or two changes and watch how quickly this project evolves into a real application!

CTI Threat Relationship Graph2 Knoten / 1 Relationen
CVE / Incident Software MITRE ATT&CK CWE Weakness IoC
IR-PLAYBOOK-VULN-REMEDIATION
MEDIUM
SOC Incident Playbook: Vulnerability Remediation & Verification
1-Click Detection Engineering: Sigma & YARA Rules
SOC Ready
title: Detect Exploitation - My project 2 : Flask Authentication System(with Python + Flask)
id: 87850a5e-2641-44ce-ad7a-5ac2a1fd14a8
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-23
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-23"
        description = "YARA Signature for "
    strings:
        $str = "My project 2 : Flask Authentic" ascii wide
    condition:
        any of them
}
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten My project 2 : Flask Authentication System(with Python + Flask)

Thematisch verwandte Begriffe: project, Flask, Authentication, Systemwith · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-82405 | Klever-Go Account takeover: `kleverUpdateAccountPermission` authorizes o…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick