Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Feature/add auth module #2

Draft
wants to merge 15 commits into
base: feature/add-db-migrations
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# db
DB_URL=postgres://postgres:password@db:5432/twinte_db?sslmode=disable

# cookie
COOKIE_SECURE=false
COOKIE_SESSION_NAME=twinte_session
COOKIE_OAUTH2_STATE_NAME=twinte_oauth2_state
COOKIE_OAUTH2_STATE_MAX_AGE=180

# auth
AUTH_REDIRECT_URL=http://localhost:3000

# oauth2 google
OAUTH2_GOOGLE_CLIENT_ID=***
OAUTH2_GOOGLE_CLIENT_SECRET=***
OAUTH2_GOOGLE_CALLBACK_URL=http://localhost:8080/oauth2/callback/google

# others
SESSION_LIFE_TIME_DAYS=90
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
extend-ignore = E203,E501
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"golang.go",
"ms-python.black-formatter",
"ms-python.flake8",
"ms-python.isort",
"ms-python.python",
]
}
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.lintOnSave": true,
"python.formatting.provider": "black",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
}
}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN curl -L https://github.com/golang-migrate/migrate/releases/download/v4.15.2/
&& go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest \
&& go install google.golang.org/protobuf/cmd/protoc-gen-go@latest \
&& go install github.com/bufbuild/connect-go/cmd/protoc-gen-connect-go@latest \
&& go install github.com/spf13/cobra-cli@latest \
&& go install golang.org/x/tools/gopls@latest

COPY go.mod go.sum ./
Expand Down
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include .env

up:
docker compose up -d

Expand Down Expand Up @@ -25,19 +27,25 @@ tidy:
test:
go test -count=1 ./...

serve:
go run . serve

buf-gen:
rm -rf ./api/gen && buf generate ./twinte-proto

# ex.) make migrate-create name=foo
migrate-create:
migrate create -dir ./db/migrations -ext sql -seq -digits 6 ${name}

migrate-up:
migrate -database postgres://postgres:password@db:5432/twinte-db?sslmode=disable -path ./db/migrations up
migrate -database $(DB_URL) -path ./db/migrations up

migrate-down:
migrate -database postgres://postgres:password@db:5432/twinte-db?sslmode=disable -path ./db/migrations down -all
migrate -database $(DB_URL) -path ./db/migrations down -all

# ex.) make migrate-force version=1
migrate-force:
migrate -database postgres://postgres:password@db:5432/twinte-db?sslmode=disable -path ./db/migrations force ${version}
migrate -database $(DB_URL) -path ./db/migrations force ${version}

sqlboiler:
sqlboiler psql -c sqlboiler.toml
160 changes: 160 additions & 0 deletions api/gen/apigenconnect/auth_service.connect.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading