Menu

GDPR in a FastAPI app: data export, account deletion and cookies
📰

GDPR in a FastAPI app: data export, account deletion and cookies

DEV Community: fastapi·patrykkomow12·about 2 hours ago
#40ctayoy
#devtofastapi#devto#dev#cookie#user
Long article (2763 words) — no AI summary yet.
Reading 0:00
15s threshold

The GDPR features a small SaaS actually has to build come down to three things: let people download their data, let them delete their account, and don't set optional cookies without asking. The interesting part is where these collide with the real world: a deleted customer who is still being charged, and tax law that says some records must stay.

This is how I built it, not legal advice. Have someone who knows the law where you operate review your processes and your privacy policy.

Data export

Articles 15 and 20 give people the right to get their data, in a machine-readable format for the portability part. A JSON download from the settings page covers both, and answers these requests without any manual work on your side. The service gathers the data into plain dicts:

# app/gdpr/service.py async def export_user_data ( session : AsyncSession , user : User ) -> dict : """Everything the app stores about the user, as JSON-ready data (GDPR art. 15 and 20).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.