Skip to content
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

update main #6

Merged
merged 91 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
cc1f592
init
bookpanda Jun 22, 2024
c9c8bc8
init 2
bookpanda Jun 22, 2024
f5c3586
air
bookpanda Jun 22, 2024
3eef187
fix: air
bookpanda Jun 22, 2024
4d2bd31
fix: mf
bookpanda Jun 22, 2024
d82a958
fix: move constant
bookpanda Jun 22, 2024
e775e53
mocks
bookpanda Jun 22, 2024
a03e255
fix: user email
bookpanda Jun 22, 2024
9d766eb
config redis
bookpanda Jun 22, 2024
23f3600
redis
bookpanda Jun 22, 2024
8694974
fix: auth wip
bookpanda Jun 22, 2024
35906e8
jwt
bookpanda Jun 22, 2024
d4194a2
token
bookpanda Jun 22, 2024
2d6c5cb
cache
bookpanda Jun 22, 2024
03d6427
feat: token svc
bookpanda Jun 22, 2024
58080bb
feat: login signup
bookpanda Jun 22, 2024
62f9971
register auth proot
bookpanda Jun 22, 2024
b5de0f0
fix: env
bookpanda Jun 22, 2024
028d763
gitignore
bookpanda Jun 22, 2024
407a0f2
fix: staff
bookpanda Jun 22, 2024
3b53cce
feat: workflow
bookpanda Jun 22, 2024
ae7880a
feat: log svc
bookpanda Jun 22, 2024
2870a1c
fix: test
bookpanda Jun 22, 2024
2268e3e
fix: Dockerfile
bookpanda Jun 22, 2024
596ab57
fix; create user with correct role
bookpanda Jun 23, 2024
77a18ef
fix: user svc logs
bookpanda Jun 23, 2024
a8ee630
fix: redis pw
bookpanda Jun 23, 2024
3fa0046
fix: env
bookpanda Jun 23, 2024
d35c9b4
fix: staff folder
bookpanda Jun 23, 2024
35878d7
microservices config
bookpanda Jun 23, 2024
52310d6
feat: gg oauth
bookpanda Jun 24, 2024
44da306
oauth config
bookpanda Jun 24, 2024
acaf500
feat: gg login
bookpanda Jun 24, 2024
8cd7301
add expiresIn
bookpanda Jun 24, 2024
6cf9b02
update protop
bookpanda Jun 24, 2024
f16996b
fix: remove authsession
bookpanda Jun 25, 2024
4380b98
fix; remove mock auth svc
bookpanda Jun 25, 2024
e0d850a
fix; unused code
bookpanda Jun 25, 2024
7e8d9d4
feat: model
bookpanda Jun 25, 2024
e58b327
feat; setup user
bookpanda Jun 26, 2024
0e55b2e
fix: auth gg login
bookpanda Jun 28, 2024
6092b99
feat: user add ProtoToModel
bookpanda Jun 28, 2024
409f53d
ndy: Add fields to ProtoToModel and ModelToProto, wrote generic stuff…
P-CAST Jun 28, 2024
8a7a1c3
feat: qa compose
bookpanda Jun 28, 2024
10db4a7
update user
bookpanda Jun 28, 2024
913d5ae
Merge branch 'dev' into feat/update_user
bookpanda Jun 28, 2024
bf9dbc3
Merge pull request #1 from isd-sgcu/feat/update_user
bookpanda Jun 28, 2024
77d61db
fix: auth svc lint
bookpanda Jun 28, 2024
7204fd6
fix: compose
bookpanda Jun 28, 2024
1397efa
fix: docker
bookpanda Jun 28, 2024
d39bf62
add latest tag
bookpanda Jun 29, 2024
a054d56
fix: lint
bookpanda Jun 29, 2024
53383ac
feat: apply latest tags
bookpanda Jun 29, 2024
c13c2ca
feat: qa temp
bookpanda Jun 29, 2024
495e0bb
feat: readme
bookpanda Jun 29, 2024
aea1671
fix: full qa compose
bookpanda Jun 29, 2024
09dffa5
feat: update proto, model
bookpanda Jun 29, 2024
fc16d56
fix; proto user groupid
bookpanda Jun 29, 2024
84ce80a
feat: chula email check
bookpanda Jun 29, 2024
89ea272
Merge pull request #2 from isd-sgcu/auth-verify-refresh-checkcu
bookpanda Jun 29, 2024
4e18493
fix: auth vol qa
bookpanda Jun 29, 2024
153f9cc
fix: makefile
bookpanda Jun 29, 2024
61a6d16
fix: add oauth env qa
bookpanda Jun 29, 2024
7ba386f
fix: err handling
bookpanda Jun 29, 2024
bb97ef1
remove ResetTokenTTL
bookpanda Jun 29, 2024
a38d872
update proto
bookpanda Jun 29, 2024
0c2a337
fix; SERVICE_AUTH
bookpanda Jun 29, 2024
324f6f0
host.docker.internal
bookpanda Jun 29, 2024
85b4709
fix: credentials give ttl
bookpanda Jun 29, 2024
58cd6be
feat: prometheus grafana
bookpanda Jun 29, 2024
f9def4f
fix: prom target
bookpanda Jun 29, 2024
4e8fa94
readme
bookpanda Jun 30, 2024
cdc87ee
update proto
bookpanda Jun 30, 2024
6903fa4
fix: role
bookpanda Jun 30, 2024
c12c2a8
UpdateUserRequest remove email
bookpanda Jun 30, 2024
f17d8ca
fix: IsEmailChulaStudent Unauthenticated
bookpanda Jun 30, 2024
0c48e9f
fix: update user bool
bookpanda Jun 30, 2024
496b953
create user return stamp
bookpanda Jul 1, 2024
b2a19bb
get user return stamp
bookpanda Jul 1, 2024
9b98df7
Merge pull request #3 from isd-sgcu/user-init-stamp
bookpanda Jul 4, 2024
3eb4f44
fix: verify gg add userid
bookpanda Jul 4, 2024
a107a83
feat: get user have stamp
bookpanda Jul 4, 2024
9893a20
fix: create group when create user
bookpanda Jul 6, 2024
71ce02e
feat: check chula email env
bookpanda Jul 7, 2024
74ddb92
feat: add devcontainer and action
PatrickChoDev Jul 10, 2024
b17163f
ci: optimize image
PatrickChoDev Jul 10, 2024
94e6a0c
feat: remove deplicate bump tag
PatrickChoDev Jul 10, 2024
80d8a7d
Merge pull request #4 from isd-sgcu/feat/containers
bookpanda Jul 10, 2024
1f52f9b
new wf
bookpanda Jul 12, 2024
9dd8e79
mod tidy
bookpanda Jul 12, 2024
5529a62
Merge pull request #5 from isd-sgcu/workflows
bookpanda Jul 12, 2024
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
51 changes: 51 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = ";export $(grep -v '^#' .env | xargs); ./tmp/main"
cmd = "go build -o ./tmp/main ./cmd/main.go"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[proxy]
app_port = 0
enabled = false
proxy_port = 0

[screen]
clear_on_rebuild = false
keep_scroll = true
13 changes: 13 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM mcr.microsoft.com/devcontainers/go:1-1.22-bookworm

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment the next lines to use go get to install anything else you need
# USER vscode
# RUN go get -x <your-dependency-or-tool>
# USER root

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
32 changes: 32 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go-postgres
{
"name": "RPKM67 Auth Service",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"customizations": {
"vscode": {
"extensions": [
"aldijav.golangwithdidi",
"VisualStudioExptTeam.vscodeintellicode",
"VisualStudioExptTeam.vscodeintellicode-completions",
"ZainChen.json",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"ms-vscode.makefile-tools",
"DavidAnson.vscode-markdownlint",
"esbenp.prettier-vscode",
"christian-kohler.path-intellisense",
"zxh404.vscode-proto3",
"redhat.vscode-yaml",
"ms-azuretools.vscode-docker",
"aaron-bond.better-comments"
]
}
},
"forwardPorts": [
5432,
6379
],
"postStartCommand": "make setup"
}
34 changes: 34 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3.8'

volumes:
postgres-data:

services:
app:
build:
context: .
dockerfile: Dockerfile
env_file:
- .env

volumes:
- ../..:/workspaces:cached
command: sleep infinity
network_mode: service:db

db:
image: postgres:latest
restart: unless-stopped
network_mode: service:redis
volumes:
- ./postgres-data:/var/lib/postgresql/data
env_file:
- .env

redis:
image: redis:latest
restart: unless-stopped
env_file:
- .env
volumes:
- ./redis-data:/data
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
microservices/
.devcontainer/*-data
19 changes: 19 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
APP_PORT=3002
APP_ENV=development

DB_URL=postgres://root:1234@localhost:5432/rpkm67_db

REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=5678

JWT_SECRET=secret
JWT_ACCESS_TTL=3600
JWT_REFRESH_TTL=259200
JWT_ISSUER=issuer

AUTH_CHECK_CHULA_EMAIL=false

OAUTH_CLIENT_ID=client_id
OAUTH_CLIENT_SECRET=client_secret
OAUTH_REDIRECT_URI=http://localhost:3000
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Change made

- [ ]  New features
- [ ]  Bug fixes
- [ ]  Breaking changes
- [ ] Refactor
## Describe what you have done
-
### New Features
-
### Fix
-
### Others
-
93 changes: 93 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Build

on:
workflow_dispatch:
pull_request:
types:
- closed
branches:
- main
- dev

env:
SERVICE_NAME: rpkm67-auth
IMAGE_NAME: ghcr.io/${{ github.repository }}
IMAGE_TAG: <WILL_BE_SET>

jobs:
build:
name: Build
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
outputs:
IMAGE_TAG: ${{ steps.tag_action.outputs.new_tag }}

permissions:
contents: write
packages: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'

- name: Bump version and push tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
RELEASE_BRANCHES: dev
DEFAULT_BUMP: patch
id: tag_action

- name: Set IMAGE_TAG
run: echo "IMAGE_TAG=${{ steps.tag_action.outputs.new_tag }}" >> $GITHUB_ENV

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }},${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max

cd:
name: Continuous Deployment
needs: build
runs-on: ubuntu-latest
env:
IMAGE_TAG: ${{ needs.build.outputs.IMAGE_TAG }}

steps:
- name: Checkout DevOps repository
uses: actions/checkout@v4
with:
repository: isd-sgcu/rpkm67-devops
token: ${{ secrets.RPKM67_DEVOPS_TOKEN }}

- name: Update image tag in dev
uses: mikefarah/yq@master
with:
cmd: yq -i '.[0].value = "${{ env.IMAGE_NAME }}:" + strenv(IMAGE_TAG)' isd/${{ env.SERVICE_NAME }}/deployment.yaml

- name: Update image tag in prod
uses: mikefarah/yq@master
if: github.ref == 'refs/heads/main'
with:
cmd: yq -i '.[0].value = "${{ env.IMAGE_NAME }}:" + strenv(IMAGE_TAG)' prod/${{ env.SERVICE_NAME }}/deployment.yaml

- name: Commit & Push changes
uses: actions-js/[email protected]
with:
repository: isd-sgcu/rpkm67-devops
github_token: ${{ secrets.RPKM67_DEVOPS_TOKEN }}
36 changes: 36 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Lint

on:
workflow_dispatch:
pull_request:
branches:
- main
- dev
push:
branches:
- main
- dev
tags:
- v*

permissions:
contents: read

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.22.4'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55
37 changes: 37 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Unit Tests

on:
workflow_dispatch:
pull_request:
branches:
- main
- dev
push:
branches:
- main
- dev
tags:
- v*

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.22

- name: Download dependencies
run: go mod download

- name: Vet
run: |
go vet ./...

- name: Test
run: |
go test -v -coverpkg ./internal/... -coverprofile coverage.out -covermode count ./internal/...
go tool cover -func="./coverage.out"
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
### Go template
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# config file
config.yaml
.env
.env.prod

# idea
.idea

# volumes
volumes

# coverage report
coverage.out
coverage.html

.DS_store
tmp
staff.json
docker-compose.qa.yml

.devcontainer/*-data
Loading
Loading