You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE] Introduce SQLite database for session management #226
Hey @everyone, sorry for pinging everyone but it's for an important matter I would like to inform everyone about. Keeping tinyauth stateless is becoming increasingly hard and it is creating security holes. I believe it's time to introduce a simple statefull tinyauth with a simple sqlite database for session management. This would of course require a docker volume and a breaking update but I think it's worth it as it would skyrocket the security of tinyauth as well as allow for the invalidation of sessions server-side. The cookie will have to store minimal info consisting of a simple UUID instead of the mess that we have right now. Let me know what you think either in #💻・development or by reacting to this message.
Keeping tinyauth stateless is hard and insecure, that's why we should move to a simple storage backend to store sessions. The idea is to move all the cookie information in a database row and assign a UUID to this row. Then the cookie get's the same UUID. In the authentication flow if the UUID the cookie contains matches with a row of the database, we use the user as usual, if not we assume the session is invalid. For the database we can use Gorm alongside a native SQLite driver to avoid the need for CGO.
To begin with stateless relies on the client to store all information about your session and I recently discovered a misconfiguration in the session library I use resulting not encrypting the cookie contents. Although this does not allow someone to create the cookie or modify it, it exposes some personal information like your email address and name. This has been fixed #225 but it still made me worry that small errors like this can expose information. By moving to the database not only you don't store anything important in the cookie except for a UUID but you also have a way smaller cookie size. Additionally by using a database the server can revoke one or all sessions which is currently not possible without changing the secret. Lastly by using a database I can store way more info in comparison to the cookie that could be useful in the future.
changed the title [-]Introduce SQLite database for session management[/-][+][FEATURE] Introduce SQLite database for session management[/+]on Jul 5, 2025
Activity
steveiliop56 commentedon Jul 5, 2025
Reason for this change quoted from Dicsord:
[-]Introduce SQLite database for session management[/-][+][FEATURE] Introduce SQLite database for session management[/+]steveiliop56 commentedon Aug 29, 2025
Added in #326