Skip to content

refactor: remove multi-tenancy from authsec; extract to mt-plugin microservice - #20

Merged
apauthnull merged 14 commits into
mainfrom
non-multi-tenant
Apr 30, 2026
Merged

refactor: remove multi-tenancy from authsec; extract to mt-plugin microservice#20
apauthnull merged 14 commits into
mainfrom
non-multi-tenant

Conversation

@apauthnull

@apauthnull apauthnull commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

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

  • Unit tests pass (go test -short ./tests/unit/)
  • go vet ./... clean
  • Add label run-integration to this PR to trigger integration tests in CI

Checklist

  • Code follows the project's style guidelines
  • Self-reviewed the diff
  • No secrets or credentials committed
  • Updated documentation if needed (README, API_DOCS, CONTRIBUTING, CODE_OF_CONDUCT)
  • Added/updated tests for new behaviour (8 new test files in tests/unit/)

Description

Changes

Testing

  • Unit tests pass (go test ./...)
  • go vet ./... clean
  • Manual testing (describe below)

Checklist

  • Code follows the project's style guidelines
  • Self-reviewed the diff
  • No secrets or credentials committed
  • Updated documentation if needed
  • Added/updated tests for new behaviour

amanpd7 added 8 commits April 29, 2026 23:02
…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/)
@apauthnull apauthnull added the run-integration To run integration tests label Apr 29, 2026
@apauthnull
apauthnull requested a review from asifalix April 29, 2026 19:09
@apauthnull
apauthnull merged commit 4024f9e into main Apr 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-integration To run integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants