1

I'm starting to build a new webapp, it currently has an AuthenticationProvider which checks a user and password match what's in a database table. Its session based.

Currently micronaut just seems to use the public schema (I'm on postgres).

I've tried enabling a subdomain tenant resolver in my application.yml:

  data:
    multi-tenancy:
      mode: SCHEMA
      tenantresolver:
        subdomain:
          enabled: true

But I can't tell that it's doing anything. If I visit subdomain.localhost to test it a session cookie seems to appear tied to that subdomain, but any user from the public schema can authenticate against it. I assume my AuthenticationProvider needs to become tenant aware somehow?

If I then have another tenant sign up, who isn't authenticated at the point of registering, how would a schema get populated for them using micronaut data before they come to authenticate? Thanks.

rich
  • 18,987
  • 11
  • 75
  • 101
  • I'm starting to think micronaut doesn't really have support for this and I need to look elsewhere. Annoying, it was probably the very last feature I was looking for from it. – rich Apr 15 '23 at 17:06
  • What is your stack? There are some examples https://github.com/micronaut-projects/micronaut-data/tree/master/doc-examples/jdbc-multitenancy-schema-example-java – Denis Apr 27 '23 at 17:11

1 Answers1

0

In case it helps anyone else, I had two issues:

  • Nginx was in front of micronaut and needed proxy_set_header Host $host; setting, else it was taking the subdomain from host.docker.internal which was always consistent and not from abc.myhost.com or xyz.myhost.com etc.
  • tenantresolver in application.yml should be under multitenancy which sits on the same level as data.
rich
  • 18,987
  • 11
  • 75
  • 101