refactor: remove multi-tenancy from authsec; extract to mt-plugin microservice - #20
Merged
Conversation
…roservice ## Description authsec is now a strict single-tenant service. All multi-tenant logic (per-tenant DB creation, tenant resolution, dynamic DB switching) has been extracted to the new mt-plugin gRPC microservice. authsec auto- detects mt-plugin via a 15s heartbeat; when unavailable, second admin registration returns HTTP 409. ## Changes - Delete tenant middleware stack (resolution, validation, context) - Delete services/tenant_db_service.go and database/tenant_db_service.go (moved to mt-plugin) - Delete internal/migration/template_builder.go (moved to mt-plugin) - Replace all GetConnectionDynamically() calls with config.DB (master) - Add internal/mtplugin/client.go — gRPC client with heartbeat and MTPluginClientIface - Add internal/mtplugin/proto/ — generated protobuf stubs - Move vault/ → internal/vault/ to match folder structure architecture - Add config.MTPluginClientIface + MT_PLUGIN_GRPC_ADDR env var - Strip CreateTenantDB and tenant migration handlers from migration_controller.go - Add single-tenant 409 guard in AdminRegister - Move Python scripts from tests/ to scripts/ - Delete stale artifacts (bash.exe.stackdump, test_results.html, vault_renewal_script.go) - Fix ValidateDomain regex to reject labels with trailing hyphens ## Testing - [x] Unit tests pass (`go test -short ./tests/unit/`) - [x] `go vet ./...` clean - [x] Add label `run-integration` to this PR to trigger integration tests in CI ## Checklist - [x] Code follows the project's style guidelines - [x] Self-reviewed the diff - [x] No secrets or credentials committed - [x] Updated documentation if needed (README, API_DOCS, CONTRIBUTING, CODE_OF_CONDUCT) - [x] Added/updated tests for new behaviour (8 new test files in tests/unit/)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
authsec is now a strict single-tenant service. All multi-tenant logic (per-tenant DB creation, tenant resolution, dynamic DB switching) has been extracted to the new mt-plugin gRPC microservice. authsec auto- detects mt-plugin via a 15s heartbeat; when unavailable, second admin registration returns HTTP 409.
Changes
Testing
go test -short ./tests/unit/)go vet ./...cleanrun-integrationto this PR to trigger integration tests in CIChecklist
Description
Changes
Testing
go test ./...)go vet ./...cleanChecklist