Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
80fef66
wip: initial schema
steveiliop56 Nov 3, 2026
2abcb18
wip: add new services for identity, sessions and oauth
steveiliop56 Nov 6, 2026
c8ebbbb
refactor: migrate oauth controller to new identity model
steveiliop56 Nov 6, 2026
a50c3c1
refactor: update context middleware
steveiliop56 Nov 6, 2026
e79431e
refactor: adapt user controller to new services
steveiliop56 Nov 6, 2026
6654fe4
wip: working prototype
steveiliop56 Nov 10, 2026
c16daa8
chore: remove csrf token from db
steveiliop56 Nov 10, 2026
afe1f0f
deps: bump go to 1.27.3
steveiliop56 Nov 10, 2026
d1c9f73
feat: make linking mode configurable
steveiliop56 Nov 10, 2026
d2e888e
tests: fix controller tests
steveiliop56 Nov 13, 2026
4c1f12e
tests: fix service tests
steveiliop56 Nov 13, 2026
527011d
tests: fix middleware tests
steveiliop56 Nov 13, 2026
7d715bf
tests: fix model tests
steveiliop56 Nov 13, 2026
2278504
tests: add tests for sessions and identity service
steveiliop56 Nov 13, 2026
fdff696
fix: build webui before code gen
steveiliop56 Nov 13, 2026
5745d11
fix: copy frontend before codegen checks in ci
steveiliop56 Nov 13, 2026
169f47a
chore: remove deprecated version file
steveiliop56 Nov 16, 2026
90b1c36
fix: batch no 1 of review comments
steveiliop56 Nov 16, 2026
f503198
refactor: use a factory to support stores with transactions
steveiliop56 Nov 17, 2026
2a7dd8d
chore: use different db for each test
steveiliop56 Nov 23, 2026
0f73071
fix: review comments
steveiliop56 Nov 23, 2026
5135c1d
tests: add tests for identity service
steveiliop56 Nov 23, 2026
d5c7652
fix: retry serilization on transaction
steveiliop56 Nov 24, 2026
3a1cd75
tests: use database id in file name
steveiliop56 Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ TINYAUTH_SERVER_SOCKETPATH=

# auth config

# Linking mode for users (username, email, both).
TINYAUTH_AUTH_LINKINGMODE="both"
# List of allowed IPs or CIDR ranges.
TINYAUTH_AUTH_IP_ALLOW=
# List of blocked IPs or CIDR ranges.
Expand Down Expand Up @@ -245,10 +247,10 @@ TINYAUTH_LDAP_GROUPCACHETTL=900

# experimental config

# Enable the OAuth bridge, uses a new way to format OAuth user information.
TINYAUTH_EXPERIMENTAL_OAUTHBRIDGEENABLED=false
# Disable the fallback to forward_auth modules when auth_request or ext_authz fail.
TINYAUTH_EXPERIMENTAL_DISABLEAUTHMODULEFALLBACK=false
# Disable the generation of additional OAuth user information, avoids things like myuser_myprovider.
TINYAUTH_EXPERIMENTAL_NOOAUTHUSERINFOGEN=false

# tailscale config

Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "^1.26.4"
go-version: "^1.27.3"

- name: Go dependencies
run: go mod download
Expand All @@ -36,20 +36,10 @@ jobs:
- name: Setup controller-gen
run: go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.22.0

- name: Check codegen is up to date
run: |
sqlc generate
go generate ./...
git diff --exit-code
git status --porcelain | grep -q . && echo "untracked files code gen files" && exit 1 || true

- name: Install frontend dependencies
working-directory: ./frontend
run: pnpm ci

- name: Set version
run: echo testing > internal/assets/version

- name: Lint frontend
working-directory: ./frontend
run: pnpm run lint
Expand All @@ -61,6 +51,13 @@ jobs:
- name: Copy frontend
run: cp -r frontend/dist internal/assets/dist

- name: Check codegen is up to date
run: |
sqlc generate
go generate ./...
git diff --exit-code
git status --porcelain | grep -q . && echo "untracked files code gen files" && exit 1 || true
Comment thread
steveiliop56 marked this conversation as resolved.
Resolved

- name: Run tests
run: go test -coverprofile=coverage.txt -v ./...

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Install go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "^1.26.4"
go-version: "^1.27.3"

- name: Install frontend dependencies
working-directory: ./frontend
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
- name: Install go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "^1.26.4"
go-version: "^1.27.3"

- name: Install frontend dependencies
working-directory: ./frontend
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Install go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "^1.26.4"
go-version: "^1.27.3"

- name: Install frontend dependencies
working-directory: ./frontend
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
- name: Install go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "^1.26.4"
go-version: "^1.27.3"

- name: Install frontend dependencies
working-directory: ./frontend
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Contributing to Tinyauth is straightforward. Follow the steps below to set up a
## Requirements

- pnpm
- Golang v1.26.4 or later
- Golang v1.27.3 or later
- Git
- Docker
- Make
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ COPY ./frontend/vite.config.ts ./
RUN pnpm run build

# Builder
FROM golang:1.26-alpine3.23 AS builder
FROM golang:1.27-alpine3.23 AS builder

ARG VERSION
ARG COMMIT_HASH
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.26-alpine3.23
FROM golang:1.27-alpine3.23

WORKDIR /tinyauth

Expand All @@ -8,7 +8,7 @@ COPY go.sum ./
RUN go mod download

RUN go install github.com/air-verse/air@v1.61.7
RUN go install github.com/go-delve/delve/cmd/dlv@v1.26.3
RUN go install github.com/go-delve/delve/cmd/dlv@v1.27.2

COPY ./cmd ./cmd
COPY ./internal ./internal
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.distroless
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ COPY ./frontend/vite.config.ts ./
RUN pnpm run build

# Builder
FROM golang:1.26-alpine3.23 AS builder
FROM golang:1.27-alpine3.23 AS builder

ARG VERSION
ARG COMMIT_HASH
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ sql:
sqlc generate

# Go gen
generate:
generate: webui
go generate ./...

# an alias for generate
Expand Down
2 changes: 1 addition & 1 deletion cmd/tinyauth/create_oidc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func createOidcClientCmd() *cli.Command {

u := uuid.New()
clientId := u.String()
clientSecret := "ta-" + utils.GenerateString(61)
clientSecret := "ta-" + utils.GenerateSecureString(61)

uclientName := strings.ToUpper(clientName)
lclientName := strings.ToLower(clientName)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/domain-warning/domain-warning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const DomainWarning = (props: Props) => {
const { t } = useTranslation();
const { search } = useLocation();

const searchParams = new URLSearchParams(search);
const searchParams = (new URLSearchParams(search)).toString();

return (
<Card role="alert" aria-live="assertive">
Expand All @@ -45,7 +45,7 @@ export const DomainWarning = (props: Props) => {
<CardFooter className="flex flex-col items-stretch gap-3">
<Button
onClick={() =>
window.location.assign(`${appUrl}/login?${searchParams.toString()}`)
window.location.assign(`${appUrl}/login${searchParams ? `?${searchParams}` : ""}`)
}
variant="outline"
>
Expand Down
2 changes: 1 addition & 1 deletion go.mod
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
DROP TABLE IF EXISTS "sessions";
DROP TABLE IF EXISTS "identities";
DROP TABLE IF EXISTS "users";

CREATE TABLE IF NOT EXISTS "sessions" (
"uuid" TEXT NOT NULL PRIMARY KEY,
"username" TEXT NOT NULL,
Expand Down
41 changes: 41 additions & 0 deletions internal/assets/migrations/postgres/000004_identity.up.sql
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
@@ -1,3 +1,7 @@
DROP TABLE IF EXISTS "sessions";
DROP TABLE IF EXISTS "identities";
DROP TABLE IF EXISTS "users";

CREATE TABLE IF NOT EXISTS "sessions" (
"uuid" TEXT NOT NULL PRIMARY KEY UNIQUE,
"username" TEXT NOT NULL,
Expand Down
41 changes: 41 additions & 0 deletions internal/assets/migrations/sqlite/000012_identity.up.sql
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
);
Loading