multi-tenant | Spring Boot Spring JPA Hibernate Postgresql | Object-Relational Mapping library
kandi X-RAY | multi-tenant Summary
kandi X-RAY | multi-tenant Summary
Spring Boot + Spring JPA + Hibernate + Postgresql
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Returns the identifier for the current tenant
- Gets the current tenant
- Clears the tenant context
- Clear current tenant
- Create datasources
- The EntityManagerFactory bean
- Load data source
- Creates Jpa transaction manager
- Creates a new sample order
- Set the current tenant
- The main entry point
- Select any data source
- Return data source for specified tenant id
- The entity manager bean
- Add a MultiTenantInterceptors to the InterceptorRegistry
multi-tenant Key Features
multi-tenant Examples and Code Snippets
Community Discussions
Trending Discussions on multi-tenant
QUESTION
I used to fetch data from db and make available in all View through ServiceProvider, But now, I am using stancl/tenancy for multi-tenant system. And I need to pass some global data to all view files, writing the fetch data in ServiceProvider returns data from central database only. So, how can I fetch data from tenant DB to all view files globally before requesting any other requests?
...ANSWER
Answered 2021-Jun-09 at 11:41Service Providers run before the tenant is identified and can therefore not be used to make configurations like sharing data to all views.
Instead, you can make a custom tenancy bootstrapper by creating a class that implements the Stancl\Tenancy\Contracts\TenancyBootstrapper
interface.
QUESTION
There is a warning on the Firebase best practices documentation against using Firebase with multi-tenant applications: https://firebase.google.com/docs/projects/learn-more#multi-tenancy
This is what I am most concerned about: "Multi-tenancy can lead to serious configuration and data privacy concerns problems, including unintended issues with analytics aggregation, shared authentication, overly-complex database structures, and difficulties with security rules."
There is also plenty of official Google documentation supporting the use of Firebase for multi-tenancy, for instance: https://cloud.google.com/identity-platform/docs/multi-tenancy-authentication .
Do you know why they would have these conflicting recommendations and examples? Does use of Google Identity Platform fix the core security deficits mentioned in the warning?
I am re-posting this question, with additional clarification in the title, and a few edits/removals from the body, to specify that I am only looking for why this widely used product has this particular warning in its official documentation. I have removed most subjective content. I have no opinion on this that is relevant to the question - I am only looking to understand the warning. It seemed there was one good answer before the previous question was closed, so I will link that here for reference: Why is Google Firebase not recommended by Google in their own documentation for multi-tenant applications?
...ANSWER
Answered 2021-Jun-02 at 06:00That does make sense if you manage 2 separate applications which have no relation with each other. Let's say you have an app that manages a school's information and other one is a restaurant management app. Now in this case I don't see any event that the school app might need access to restaurant data.
If you use the same project, then all the firebase services (auth, database, analytics, etc) will be shared among them. It'll be hard for you to separate analytics for each of the app. As the database is shared, you'll have to explicitly separate data of both apps by separating the path in db. (/apps/school for school, /apps/restaurant for restaurant).
That being said, any user registered on the school app can login on restaurant app without creating a new account there as you are sharing the same project among them.
Now if your client pays you a the Firebase costs every month, you cannot distinguish between how much should the school client pay. Now even if both the apps are your, the complexity will increase significantly if you go on using it.
https://firebase.google.com/docs/projects/learn-more#multi-tenancy <-- this explains how "Firebase Projects" works and https://cloud.google.com/identity-platform/docs/multi-tenancy-authentication explains about "Google Identity Kit" multi-tenant auth. So that's not a Firebase-only thing.
QUESTION
There is a warning on the Firebase best practices documentation against using Firebase with multi-tenant applications: https://firebase.google.com/docs/projects/learn-more#multi-tenancy
This is what I am most concerned about: "Multi-tenancy can lead to serious configuration and data privacy concerns problems, including unintended issues with analytics aggregation, shared authentication, overly-complex database structures, and difficulties with security rules." Identity Platform looks like it should cover everything except analytics aggregation and database structures, but I can control analytics logging and my database structure is simple enough, being divided cleanly by tenant. My application is one common application, but has tenanted client data and users (managed via Google Identity Platform).
There is also plenty of official Google documentation supporting the use of Firebase for multi-tenancy: https://cloud.google.com/identity-platform/docs/multi-tenancy-authentication . There are also dozens of examples out there for how to set up multi-tenancy with Firebase and Google Identity Provider.
Do you know why they would have these conflicting recommendations and examples? Does use of Google Identity Platform fix the core security deficits mentioned in the warning? It has me strongly considering abandoning Firebase, which would be a shame given the features it gives me.
...ANSWER
Answered 2021-May-28 at 07:44The recommendation is not bind to Firebase, or GCP, or Google. It's generic. If you put all your data in the same bag, with only a logical isolation, it's only logical, not strong as different projects.
Thus, it's easy to make a mistake and to use, delete, update, make the mess, in all the tenant data. In case of attacks, leak, major bug, you can reduce the blast radius by having several small tenant.
It's a tradeoff between more management to perform (because you have a lot of tenant) and a higher risk (multi-tenant project, the crash is dramatic). It also depends on your application type and context. It's a recommendation, not an obligation!
QUESTION
I'm using a schema interceptor to configure my schema. It's a multi-tenant application, so I build the schema according to the tenant's configuration. I'm mapping that configuration to SDL language (schema-first approach) and then I add it to the schema builder (schemaBuilder.AddDocumentFromString(...)
).
As said on the documentation (here), "Schema-first does currently not support filtering!". But that is the only approach I can use right now, so I'm trying to find a workaround.
What I've tried:
Manually create the input filter types and add the filtering to the server (something like this):
...ANSWER
Answered 2021-Jun-01 at 16:34Filter support for schema-first is coming with version 12. You then do not even have to specify everything since we will provide schema building directives.
QUESTION
I'm building a multi-tenant rails application, similar to Shopify. Whenever a customer registers an Account
, they will have a subdomain created at customer.myapp.com
. This subdomain returns a view with data related to their account (including a /admin area).
Now in some cases, customers would like to use their own custom domain, instead of the subdomain created for them. How do I need to adjust my rails routes and controllers to return a view with data related to the customers account, based on not just the subdomain but on either the custom domain OR the subdomain?
This is how I've set up my config/routes.rb
for handling subdomains:
ANSWER
Answered 2021-Jun-01 at 11:35Okay, so this is what I came up with in the meantime.
First of all I left my config/routes.rb
as described above. Everything seemed to be working as intended there.
Then I adjusted app/constraints/subdomain_required.rb
to not only check for the subdomain but also the domain part of the request:
QUESTION
We have a setup where we are running 6 PgBouncer processes and our performance benchmarks degrade linearly with time. The longer PgBouncer has been running, the longer the connections to Postgres exist results in slower response times for the benchmark. We have a multi-tenant schema separated database with 2000+ relations. We are configured for Transaction Mode pooling right now. Over time, we see the memory footprint of each Postgres process climb and climb and climb, and again, this results in poorer performance.
We have tried to be more aggressive in cleaning up idle connections with the following settings:
...ANSWER
Answered 2021-May-27 at 16:31The issue is resolved.
The application was extremely chatty and even with server_idle_timeout set as low as 5 seconds, the connections were not getting recycled on the Postgres side.
The issue we had was that server_lifetime was accidentally commented when we thought it was active and once we changed that, we could clearly see that Postgres connections were getting recycled every 2 minutes (based on our settings).
The increased memory of each connection over time especially for long-lived connections was only taking into consideration private memory and not shared memory. What we observed was the longer the connection was alive, the more memory it consumed. We tried setting things like DISCARD ALL for reset_query and it had no impact on memory consumption. Based on my research online, we were not the only to ones to face this challenge with pooling connections.
Thanks for the comments and the help. Our solution in the end was to leverage server_lifetime in pgBouncer to control the number of long-lived connections on Postgres.
-Mayan
QUESTION
Does Firestore have any support for a multi-tenant app? I am creating a service which will have multiple clients and need to be able to separate each client's data completely from every other client.
...ANSWER
Answered 2021-May-26 at 12:23Firestore in Native mode has no (built-in) support for multitenancy.
Firestore in Datastore mode has support for multitenancy via namespaces. However, Firestore in Datastore mode loses the real-time updates feature, which is a highly desirable feature for many developers/projects.
One workaround for this limitation is to use a (collection/document) hierarchy in the Native-mode Firestore that looks something like this:
- tenants (collection)
- Tenant-01 (document representing a particular tenant; can contain basic details like name etc.)
- users (sub-collection)
- assets (sub-collection)
- locations (sub-collection)
- Tenant-02
- users (sub-collection)
- assets (sub-collection)
- locations (sub-collection)
- Tenant-01 (document representing a particular tenant; can contain basic details like name etc.)
However, there still remains the limitation that you cannot know the resource usage on a per-tenant basis. This matters particularly when there's a noisy neighbour: a single tenant that is using far more resources than the average. As the service provider your total bill is rising, but there's no easy way to know which client (tenant) is causing the higher costs.
See also:
QUESTION
I developed a web accounting application using vanilla PHP as backend and jquery and vanilla javascript as frontend. Every client will have one database. The single database contains all client's database connection strings and login credentials for clients. Whenever a client logs in using a login credential client gets the connection string from the master database where all database connections are stored. Based on login credentials my backend will connect to their database. They will work on their database.
How can i achieve this scenario using laravel 8? i tried several solutions like, Dynamic database connection in Laravel, Create Dynamic Database Connection in Laravel, Laravel 5.8 dynamic database connection not being set in model, laravel 5.4 dynamic database connection, Configure database connections on the fly in Laravel
these all solutions recommend using configure file or .env file. as you can see in my scenario i can't setup every client's database connection in database config array because my client's database connections are dynamic and there are lots of database connections.
so what you guys will suggest to overcome this scenario?
and i don't want to use Multi-Tenant setup its just overkill and i do want is grab connection string while logging and use that connection string to connect user's specific database. so its kind a dynamic!
...ANSWER
Answered 2021-May-19 at 05:56- Add connection to config/database.php (You may copy and edit the name.) ex. copy and change name to "mysql_user"
- Make middleware
- Check auth in middleware and get credentials
- Set config in middleware
QUESTION
Our application has a multi-tenant architecture where we have multiple different websites deployed using a single codebase. Is there a way to edit the application name (ie. show Sign in to with Google
instead of Sign in to with Google
) without needing to create a separate project in Google Console for each website?
If editing the app name is impossible, is there a way to just show Sign in with Google
instead?
ANSWER
Answered 2021-May-17 at 19:06I don't think Google allows you to do that, basically due to some legal/UX concerns. Take below UX as an example.
- Users go to website1, and see prompt for "App Name 1". Then grant it.
- Users go to website2, and see prompt for "App Name 2". And it'd be a big surprise, to some of them, that the permission has arleady been granted. Users may think 1)Google granted it without user's consent, or 2) someone had stolen his credentials and granted it, etc.
In summary, you need to make a decision first:
- if you think end users should treat your different origins as different apps, you should create different projects for them(, so that their UX are isolated from each others).
- if you think users should treat your different origins as a single app, then using same app name is not an issue at all.
QUESTION
I have found two different ways to, first, get the next invoice number and, then, save the invoice in a multi-tenant database where, of course, each tenant will have his own invoices with different incremental numbers.
- My first (and actual) approach is this (works fine):
- Add a new record to the invoices tables. No matter the invoice number yet (for example, 0, or empty)
- I get the unique ID of THAT created record after insert
- Now I do a
"SELECT table where ID = $lastcreatedID **FOR UPDATE**"
- Here I get the latest saved invoice number with
"SELECT @A:=MAX(NUMBER)+1 FROM TABLE WHERE......"
- Finally I update the previously saved record with that invoice number with an
"UPDATE table SET NUMBER = $mynumber WHERE ID = $lastcreatedID"
This works fine, but I don't know if the "for update" is really needed or if this is the correct way to do this in a multi-tenant DB, due to performance, etc.
- The second (and simpler) approach is this (and works too, but I don't know if it is a secure approach):
INSERT INTO table (NUMBER,TENANT) SELECT COALESCE(MAX(NUMBER),0)+1,$tenant FROM table WHERE....
- That's it
Both methods are working, but I would like to know the differences between them regarding speed, performance, if it may create duplicates, etc.
Or... is there any better way to do this?
I'm using MySQL and PHP. The application is an invoice/sales cloud software that will be used by a lot of customers (tenants).
Thanks
...ANSWER
Answered 2021-May-12 at 17:56Both the approaches do work, but each with its own demerits in high traffic situations.
The first approach runs 3 queries for every invoice you create, putting extra load on your server.
The second approach can lead to duplicates in events where two invoices are generated with very little time difference (such that the SELECT query return same max number for both invoices).
Both the approaches may lead to problems in high traffic conditions.
Two solutions to the problems are listed below:
Use generated columns: Mysql supports generated columns, which are basically derived using other column values for each row. Refer this
Calculate invoice number on the fly: Since you're using the primary key as part of the invoice, let the DB handle generating unique primary keys, and then generate invoice numbers on the fly in your business logic using the id for each invoice.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install multi-tenant
You can use multi-tenant like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the multi-tenant component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page