-
Notifications
You must be signed in to change notification settings - Fork 0
Feature gRPC #47
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
Merged
Merged
Feature gRPC #47
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e6d798d
chore(proto): Add proto submodule
tab a3bf268
feat(grpc) Add gRPC authentication interceptor and permission service
tab 71fd9b2
feat(grpc) Add gRPC scope service
tab c66bf48
feat(grpc) Add gRPC role service
tab c9baa3e
feat(grpc) Add gRPC token service
tab 400e652
feat(grpc) Add gRPC user service
tab eca58fb
fix(errors): Add new error constants for record CRUD operations
tab 2113423
refactor(grpc): Update errors handling
tab b88d57d
chore(codecov): Update codecov ignore patterns
tab 1249b35
refactor(config): Remove SECRET_KEY and use RSA keys for JWT signing
tab 51940e3
chore(grpc) Use FindRoleDetailsById and FindUserDetailsById methods
tab 45aa271
refactor(logger): JSON structured logging
tab 3c98844
chore(env): Add gRPC address to .env.development
tab 76c0c4b
docs(certificates): Add documentation for generating JWT signing keys…
tab 468f8d6
refactor(backoffice): Remove backoffice controllers
tab bcf8538
feat(api): Remove backoffice API endpoints from OpenAPI specification
tab fe4b258
docs(README): Update README
tab ecbdc58
feat(ci): Add integration testing framework and workflow
tab 614d80d
chore(certs): Use single quotes in OpenSSL command for generating CA …
tab b11f31f
chore(Makefile): Update environment variable handling for Loki reposi…
tab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| LOKI_HOME ?= "" | ||
| LOKI_REPO ?= ${LOKI_HOME}/loki | ||
| LOKI_BACKOFFICE_REPO ?= ${LOKI_HOME}/loki-backoffice | ||
|
|
||
| LOKI_DB_NAME = loki-test | ||
| BACKOFFICE_DB_NAME = loki-backoffice-test | ||
| DB_USER = postgres | ||
| DB_PASSWORD = postgres | ||
| DB_HOST = localhost | ||
| DB_PORT = 5432 | ||
|
|
||
| GOOSE_DRIVER = postgres | ||
| LOKI_GOOSE_MIGRATION_DIR = $(LOKI_REPO)/db/migrate | ||
| BACKOFFICE_GOOSE_MIGRATION_DIR = $(LOKI_BACKOFFICE_REPO)/db/migrate | ||
|
|
||
| NETWORK_NAME = loki-network | ||
|
|
||
| ifneq (,$(wildcard $(LOKI_REPO)/.env.test)) | ||
| include $(LOKI_REPO)/.env.test | ||
| export $(shell sed 's/=.*//' $(LOKI_REPO)/.env.test) | ||
| endif | ||
|
|
||
| ifneq (,$(wildcard $(LOKI_BACKOFFICE_REPO)/.env.test)) | ||
| include $(LOKI_BACKOFFICE_REPO)/.env.test | ||
| export $(shell sed 's/=.*//' $(LOKI_BACKOFFICE_REPO)/.env.test) | ||
| endif | ||
|
|
||
| .PHONY: setup | ||
| setup: db\:setup certs\:generate docker\:network docker\:start check\:services | ||
|
|
||
| .PHONY: db\:setup | ||
| db\:setup: db\:create db\:migrate | ||
|
|
||
| .PHONY: db\:create | ||
| db\:create: | ||
| @echo "Creating databases for integration tests..." | ||
| @echo "PostgreSQL: $(DB_HOST):$(DB_PORT)" | ||
| PGPASSWORD=$(DB_PASSWORD) psql -h $(DB_HOST) -U $(DB_USER) -c "DROP DATABASE IF EXISTS \"$(LOKI_DB_NAME)\";" postgres | ||
| PGPASSWORD=$(DB_PASSWORD) psql -h $(DB_HOST) -U $(DB_USER) -c "CREATE DATABASE \"$(LOKI_DB_NAME)\";" postgres | ||
| PGPASSWORD=$(DB_PASSWORD) psql -h $(DB_HOST) -U $(DB_USER) -c "DROP DATABASE IF EXISTS \"$(BACKOFFICE_DB_NAME)\";" postgres | ||
| PGPASSWORD=$(DB_PASSWORD) psql -h $(DB_HOST) -U $(DB_USER) -c "CREATE DATABASE \"$(BACKOFFICE_DB_NAME)\";" postgres | ||
| @echo "Databases created successfully" | ||
|
|
||
| .PHONY: db\:migrate | ||
| db\:migrate: | ||
| @echo "Running migrations..." | ||
| @if [ -d "$(LOKI_GOOSE_MIGRATION_DIR)" ]; then \ | ||
| echo "Running loki migrations..."; \ | ||
| GOOSE_DRIVER=$(GOOSE_DRIVER) GOOSE_DBSTRING="host=$(DB_HOST) port=$(DB_PORT) user=$(DB_USER) password=$(DB_PASSWORD) dbname=$(LOKI_DB_NAME) sslmode=disable" goose -dir $(LOKI_GOOSE_MIGRATION_DIR) up || echo "Note: Some loki migrations might fail if tables already exist from schema"; \ | ||
| else \ | ||
| echo "Warning: Loki migrations directory not found at $(LOKI_GOOSE_MIGRATION_DIR)"; \ | ||
| fi | ||
|
|
||
| @if [ -d "$(BACKOFFICE_GOOSE_MIGRATION_DIR)" ]; then \ | ||
| echo "Running loki-backoffice migrations..."; \ | ||
| GOOSE_DRIVER=$(GOOSE_DRIVER) GOOSE_DBSTRING="host=$(DB_HOST) port=$(DB_PORT) user=$(DB_USER) password=$(DB_PASSWORD) dbname=$(BACKOFFICE_DB_NAME) sslmode=disable" goose -dir $(BACKOFFICE_GOOSE_MIGRATION_DIR) up || echo "Note: Some loki-backoffice migrations might fail if tables already exist from schema"; \ | ||
| else \ | ||
| echo "Warning: Loki-backoffice migrations directory not found at $(BACKOFFICE_GOOSE_MIGRATION_DIR)"; \ | ||
| fi | ||
| @echo "Migrations completed" | ||
|
|
||
| .PHONY: certs\:generate | ||
| certs\:generate: | ||
| @echo "Generating JWT keys and mTLS certificates..." | ||
| ./generate-certs.sh "$(LOKI_REPO)" "$(LOKI_BACKOFFICE_REPO)" | ||
| @echo "Certificate generation completed successfully" | ||
|
|
||
| .PHONY: docker\:network | ||
| docker\:network: | ||
| @echo "Creating Docker network..." | ||
| docker network inspect $(NETWORK_NAME) >/dev/null 2>&1 || docker network create $(NETWORK_NAME) | ||
| @echo "Docker network ready" | ||
|
|
||
| .PHONY: docker\:start | ||
| docker\:start: | ||
| @echo "Starting services..." | ||
| cp loki-compose.override.yaml $(LOKI_REPO)/compose.override.yaml | ||
| cp loki-backoffice-compose.override.yaml $(LOKI_BACKOFFICE_REPO)/compose.override.yaml | ||
|
|
||
| cd $(LOKI_REPO) && docker compose up -d | ||
| cd $(LOKI_BACKOFFICE_REPO) && docker compose up -d | ||
|
|
||
| @echo "Services started" | ||
|
|
||
| .PHONY: check\:services | ||
| check\:services: | ||
| @echo "Waiting for services to be ready..." | ||
| @echo "Displaying initial container logs to help with debugging..." | ||
| @echo "Loki logs:" && docker logs loki | ||
| @echo "Loki-backoffice logs:" && docker logs loki-backoffice | ||
|
|
||
| @echo "Testing connection to services..." | ||
| @for i in $$(seq 1 5); do \ | ||
| echo "Attempt $$i/5:"; \ | ||
| if curl -s --max-time 5 http://localhost:8080/live 2>&1 | grep -q "alive"; then \ | ||
| echo "✅ Loki service is up"; \ | ||
| LOKI_UP=1; \ | ||
| else \ | ||
| echo "❌ Loki service not responding yet"; \ | ||
| LOKI_UP=0; \ | ||
| docker logs --tail 20 loki; \ | ||
| fi; \ | ||
| if curl -s --max-time 5 http://localhost:8081/live 2>&1 | grep -q "alive"; then \ | ||
| echo "✅ Loki-backoffice service is up"; \ | ||
| BACKOFFICE_UP=1; \ | ||
| else \ | ||
| echo "❌ Loki-backoffice service not responding yet"; \ | ||
| BACKOFFICE_UP=0; \ | ||
| docker logs --tail 20 loki-backoffice; \ | ||
| fi; \ | ||
| if [ "$$LOKI_UP" = "1" ] && [ "$$BACKOFFICE_UP" = "1" ]; then \ | ||
| break; \ | ||
| fi; \ | ||
| if [ $$i -eq 5 ]; then \ | ||
| echo "⚠️ Timed out waiting for services"; \ | ||
| echo "Full Loki logs:"; \ | ||
| docker logs loki; \ | ||
| echo "Full Loki-backoffice logs:"; \ | ||
| docker logs loki-backoffice; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| echo "Waiting for services to start (attempt $$i/5)... retrying in 3 seconds"; \ | ||
| sleep 3; \ | ||
| done | ||
|
|
||
| @echo "All services are ready!" | ||
|
|
||
| .PHONY: run | ||
| run: | ||
| @echo "Running integration tests..." | ||
| lua run.lua | ||
|
|
||
| .PHONY: cleanup | ||
| cleanup: | ||
| @echo "Cleaning up..." | ||
| cd $(LOKI_REPO) && docker compose down || true | ||
| cd $(LOKI_BACKOFFICE_REPO) && docker compose down || true | ||
|
|
||
| rm -f $(LOKI_REPO)/compose.override.yaml | ||
| rm -f $(LOKI_BACKOFFICE_REPO)/compose.override.yaml | ||
|
|
||
| docker network rm $(NETWORK_NAME) || true | ||
| @echo "Cleanup complete" | ||
|
|
||
| .PHONY: all | ||
| all: setup run cleanup | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| local framework = require("framework") | ||
| local auth = {} | ||
|
|
||
| local token_cache = { | ||
| admin = nil, | ||
| manager = nil, | ||
| user = nil | ||
| } | ||
|
|
||
| function auth.get_admin_token() | ||
| if token_cache.admin then | ||
| print("Using cached admin token") | ||
| return token_cache.admin | ||
| end | ||
|
|
||
| local token = framework.authenticate_with_smart_id("EE", "40504040001") | ||
| if not token then | ||
| error("Failed to get admin token") | ||
| end | ||
|
|
||
| token_cache.admin = token | ||
| return token | ||
| end | ||
|
|
||
| function auth.get_manager_token() | ||
| if token_cache.manager then | ||
| print("Using cached manager token") | ||
| return token_cache.manager | ||
| end | ||
|
|
||
| local token = framework.authenticate_with_smart_id("BE", "00010299944") | ||
| if not token then | ||
| error("Failed to get manager token") | ||
| end | ||
|
|
||
| token_cache.manager = token | ||
| return token | ||
| end | ||
|
|
||
| function auth.get_user_token() | ||
| if token_cache.user then | ||
| print("Using cached user token") | ||
| return token_cache.user | ||
| end | ||
|
|
||
| local token = framework.authenticate_with_smart_id("EE", "30303039914") | ||
| if not token then | ||
| error("Failed to get user token") | ||
| end | ||
|
|
||
| token_cache.user = token | ||
| return token | ||
| end | ||
|
|
||
| function auth.get_invalid_token() | ||
| return "invalid-token" | ||
| end | ||
|
|
||
| return auth |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.