diff --git a/.gitignore b/.gitignore index 9f54ee5..1e9dc90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ todo.md hasura/hasura hasura/hasura.exe -img/ \ No newline at end of file +img/ +.venv diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 282f7eb..86c3641 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,12 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + rev: v5.0.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - id: check-merge-conflict - - id: check-added-large-files - - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.41.0 - hooks: - - id: markdownlint - repo: https://github.com/Agilicus/pre-commit-hook-k8svalidate.git rev: v0.2.0 @@ -22,68 +16,15 @@ repos: files: .yml$ - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt - rev: 0.2.1 # or other specific tag + rev: 0.2.3 hooks: - id: yamlfmt - repo: https://github.com/tekwizely/pre-commit-golang - rev: master + rev: v1.0.0-rc.1 hooks: - id: go-build-mod - - id: go-build-pkg - id: go-build-repo-mod - - id: go-build-repo-pkg - id: go-mod-tidy - id: go-mod-tidy-repo - - id: go-sec-mod - id: go-sec-pkg - - id: go-sec-repo-mod - - id: go-sec-repo-pkg - - id: go-staticcheck-mod - - id: go-staticcheck-pkg - - id: go-staticcheck-repo-mod - - id: go-staticcheck-repo-pkg - - id: go-structslop-mod - - id: go-structslop-pkg - - id: go-structslop-repo-mod - - id: go-structslop-repo-pkg - - id: go-fmt - - id: go-fmt-repo - - id: go-fumpt # replaces go-fmt - - id: go-fumpt-repo # replaces go-fmt-repo - - id: go-imports # replaces go-fmt - - id: go-imports-repo # replaces go-fmt-repo - - id: go-returns # replaces go-imports & go-fmt - - id: go-returns-repo # replaces go-imports-repo & go-fmt-repo - # - # Style Checkers - # - - id: go-lint - - id: go-critic - # - # GolangCI-Lint - # - Fast Multi-Linter - # - Can be configured to replace MOST other hooks - # - Supports repo config file for configuration - # - https://github.com/golangci/golangci-lint - # - - id: golangci-lint - - id: golangci-lint-mod - - id: golangci-lint-pkg - - id: golangci-lint-repo-mod - - id: golangci-lint-repo-pkg - # - # Invoking Custom Go Tools - # - Configured *entirely* through the `args` attribute, ie: - # args: [ go, test, ./... ] - # - Use arg `--hook:error-on-output` to indicate that any output from the tool - # should be treated as an error. - # - Use the `name` attribute to provide better messaging when the hook runs - # - Use the `alias` attribute to be able to invoke your hook via `pre-commit run` - # - - id: my-cmd - - id: my-cmd-mod - - id: my-cmd-pkg - - id: my-cmd-repo - - id: my-cmd-repo-mod - - id: my-cmd-repo-pkg diff --git a/dev_compose.yml b/dev_compose.yml new file mode 100644 index 0000000..4417aaa --- /dev/null +++ b/dev_compose.yml @@ -0,0 +1,48 @@ +--- + +services: + postgres: + image: postgres + restart: no + ports: + - 5432:5432 + volumes: + - hasura_ci_db_data:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: postgrespassword + + graphql-engine: + image: hasura/graphql-engine:v2.36.1 + restart: no + ports: + - 8080:8080 + depends_on: + - postgres + environment: + HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres + HASURA_GRAPHQL_ENABLE_CONSOLE: 'true' + HASURA_GRAPHQL_ADMIN_SECRET: my-secret + HASURA_GRAPHQL_JWT_SECRET: '{ "type": "HS256", "key": "this-is-a-generic-HS256-secret-key-and-you-should-really-change-it" }' + HASURA_GRAPHQL_UNAUTHORIZED_ROLE: anonymous + JWT_URL: http://hasura-jwt:3000 + + hasura-jwt: + build: + context: ./src + dockerfile: Dockerfile + restart: no + ports: + - 3000:3000 + environment: + JWT_KEY: this-is-a-generic-HS256-secret-key-and-you-should-really-change-it + HASURA_SECRET: my-secret + APP_URL: http://localhost:3000 + EMAIL_VERIFICATION: true + SMTP_HOST: mail.example.com + SMTP_PORT: '587' + SMTP_USER: user@example.com + SMTP_PASSWORD: user_password + + +volumes: + hasura_ci_db_data: diff --git a/dev_docker_compose.yml b/dev_docker_compose.yml deleted file mode 100644 index c0717ca..0000000 --- a/dev_docker_compose.yml +++ /dev/null @@ -1,48 +0,0 @@ -version: "3.11" - -services: - postgres: - image: postgres - restart: no - ports: - - "5432:5432" - volumes: - - hasura_ci_db_data:/var/lib/postgresql/data - environment: - POSTGRES_PASSWORD: postgrespassword - - graphql-engine: - image: hasura/graphql-engine:v2.36.1 - restart: no - ports: - - "8080:8080" - depends_on: - - "postgres" - environment: - HASURA_GRAPHQL_DATABASE_URL: "postgres://postgres:postgrespassword@postgres:5432/postgres" - HASURA_GRAPHQL_ENABLE_CONSOLE: "true" - HASURA_GRAPHQL_ADMIN_SECRET: "my-secret" - HASURA_GRAPHQL_JWT_SECRET: '{ "type": "HS256", "key": "this-is-a-generic-HS256-secret-key-and-you-should-really-change-it" }' - HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "anonymous" - JWT_URL: 'http://hasura-jwt:3000' - - hasura-jwt: - build: - context: ./src - dockerfile: Dockerfile - restart: no - ports: - - "3000:3000" - environment: - JWT_KEY: 'this-is-a-generic-HS256-secret-key-and-you-should-really-change-it' - HASURA_SECRET: 'my-secret' - APP_URL: 'http://localhost:3000' - EMAIL_VERIFICATION: true - SMTP_HOST: 'mail.example.com' - SMTP_PORT: '587' - SMTP_USER: 'user@example.com' - SMTP_PASSWORD: 'user_password' - - -volumes: - hasura_ci_db_data: diff --git a/hasura/metadata/actions.graphql b/hasura/metadata/actions.graphql index 1006508..9d2338c 100644 --- a/hasura/metadata/actions.graphql +++ b/hasura/metadata/actions.graphql @@ -20,4 +20,3 @@ type CreateUserOutput { type JsonWebToken { Token: String! } - diff --git a/hasura/migrations/default/1707348091521_init/up.sql b/hasura/migrations/default/1707348091521_init/up.sql index ca56c39..fb9e507 100644 --- a/hasura/migrations/default/1707348091521_init/up.sql +++ b/hasura/migrations/default/1707348091521_init/up.sql @@ -2,7 +2,7 @@ SET check_function_bodies = false; CREATE FUNCTION public.create_assigned_user_role() RETURNS trigger LANGUAGE plpgsql AS $$ -BEGIN +BEGIN INSERT INTO assigned_user_roles (user_id, user_role_name) VALUES (NEW.id, 'user'); RETURN NEW; diff --git a/src/go.mod b/src/go.mod index 07f4411..8c6f663 100644 --- a/src/go.mod +++ b/src/go.mod @@ -2,6 +2,6 @@ module hasura-jwt go 1.23.0 -require golang.org/x/crypto v0.26.0 +require golang.org/x/crypto v0.31.0 require github.com/golang-jwt/jwt/v5 v5.2.1 diff --git a/src/go.sum b/src/go.sum index b01c380..bb79625 100644 --- a/src/go.sum +++ b/src/go.sum @@ -1,4 +1,4 @@ github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=