Repository navigation
refactor: rework auth and session layer #1235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
80fef66
2abcb18
c8ebbbb
a50c3c1
e79431e
6654fe4
c16daa8
afe1f0f
d1c9f73
d2e888e
4c1f12e
527011d
7d715bf
2278504
fdff696
5745d11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,7 +92,7 @@ sql: | |
| sqlc generate | ||
|
|
||
| # Go gen | ||
| generate: | ||
| generate: webui | ||
| go generate ./... | ||
|
|
||
| # an alias for generate | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| module github.com/tinyauthapp/tinyauth | ||
|
|
||
| go 1.26.4 | ||
| go 1.27.3 | ||
|
|
||
| require ( | ||
| charm.land/huh/v2 v2.0.3 | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,7 @@ | ||||||||||||||
| DROP TABLE IF EXISTS "users"; | ||||||||||||||
| DROP TABLE IF EXISTS "identities"; | ||||||||||||||
| DROP TABLE IF EXISTS "sessions"; | ||||||||||||||
|
Comment on lines
+1
to
+3
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop dependent tables before their parent tables. After the up migration, Proposed fix
Committable suggestion
|
||||||||||||||
|
|
||||||||||||||
| CREATE TABLE IF NOT EXISTS "sessions" ( | ||||||||||||||
| "uuid" TEXT NOT NULL PRIMARY KEY, | ||||||||||||||
| "username" TEXT NOT NULL, | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| Drop the old, legacy, terrible sessions table | ||
|
|
||
| Will log out all users, but that's fine. | ||
| */ | ||
|
|
||
| DROP TABLE IF EXISTS "sessions"; | ||
|
|
||
| /* | ||
| The new structure consists of the following: | ||
|
|
||
| Users: holds the user data like the username, password, etc. | ||
| Identities: links the user to the identity provider. | ||
| Sessions: holds the session data like the UUID, CSRF, expiration time, etc. | ||
| */ | ||
|
|
||
| CREATE TABLE IF NOT EXISTS "users" ( | ||
| "uuid" TEXT PRIMARY KEY, | ||
| "username" TEXT NOT NULL, | ||
| "email" TEXT NOT NULL, | ||
| "name" TEXT NOT NULL | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS "identities" ( | ||
| "uuid" TEXT PRIMARY KEY, | ||
| "user_uuid" TEXT NOT NULL, | ||
| "provider_type" TEXT NOT NULL, | ||
| "provider" TEXT NOT NULL, | ||
| "provider_user_id" TEXT NOT NULL, | ||
| "context_json" TEXT NOT NULL, | ||
| FOREIGN KEY("user_uuid") REFERENCES "users"("uuid") ON DELETE CASCADE | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS "sessions" ( | ||
| "uuid" TEXT PRIMARY KEY, | ||
| "identity_uuid" TEXT NOT NULL, | ||
| "expires_at" BIGINT NOT NULL, | ||
| "created_at" BIGINT NOT NULL, | ||
| "context_json" TEXT NOT NULL, | ||
| FOREIGN KEY("identity_uuid") REFERENCES "identities"("uuid") ON DELETE CASCADE | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| Drop the old, legacy, terrible sessions table | ||
|
|
||
| Will log out all users, but that's fine. | ||
| */ | ||
|
|
||
| DROP TABLE IF EXISTS "sessions"; | ||
|
|
||
| /* | ||
| The new structure consists of the following: | ||
|
|
||
| Users: holds the user data like the username, password, etc. | ||
| Identities: links the user to the identity provider. | ||
| Sessions: holds the session data like the UUID, CSRF, expiration time, etc. | ||
| */ | ||
|
|
||
| CREATE TABLE IF NOT EXISTS "users" ( | ||
| "uuid" TEXT PRIMARY KEY, | ||
| "username" TEXT NOT NULL, | ||
| "email" TEXT NOT NULL, | ||
| "name" TEXT NOT NULL | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS "identities" ( | ||
| "uuid" TEXT PRIMARY KEY, | ||
| "user_uuid" TEXT NOT NULL, | ||
| "provider_type" TEXT NOT NULL, | ||
| "provider" TEXT NOT NULL, | ||
| "provider_user_id" TEXT NOT NULL, | ||
| "context_json" TEXT NOT NULL, | ||
| FOREIGN KEY("user_uuid") REFERENCES "users"("uuid") ON DELETE CASCADE | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS "sessions" ( | ||
| "uuid" TEXT PRIMARY KEY, | ||
| "identity_uuid" TEXT NOT NULL, | ||
| "expires_at" INTEGER NOT NULL, | ||
| "created_at" INTEGER NOT NULL, | ||
| "context_json" TEXT NOT NULL, | ||
| FOREIGN KEY("identity_uuid") REFERENCES "identities"("uuid") ON DELETE CASCADE | ||
| ); |
Uh oh!
There was an error while loading. Please reload this page.