-
Notifications
You must be signed in to change notification settings - Fork 119
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
index_name based apartment current tenant #320
Comments
Hi, also using an Apartment like implementation of Algolia. Consider storing: See #138 for the full explanation. You can then generate a secure search only API key on the back end which filters searches to that tenant only. It cannot be used for other tenants data. See https://www.algolia.com/doc/guides/security/api-keys/?language=php#generating-secured-api-keys I think this is the best way to do it, otherwise you will need to manage the API keys for your indices which will be N+1 for every tenant. I also think there is a limit to the total indices you are allowed on certain packages. |
There are 2 solutions:
In both case, make sure you use the Secured API Keys, not "standard" API keys. One tenant per App won't be possible because there are no API to create apps. I never used Aparment, can you share how you define the Index Name? I think it must be as string and can't be a method call. |
@julienbourdeau Apartment is a middleware for adding subdomains e.g. www.awesomeshop.commerce-platform.com. Similar to devise Apartment.current_tenant # awesomeshop This is basically what this would look like for apartment, as suggested in #78 (comment) Easily implemented as my fork shows https://github.com/simonireilly/algoliasearch-rails/pull/1/files. #341 might fix this anyway? The main issue is that you have the string being specific to the thread - so it needs to be a Per-tenant indicesYou can affix the index name with the current tenant from your application using: class Contact < ActiveRecord::Base
include AlgoliaSearch
algoliasearch per_tenant: Proc.new { Apartment.current_tenant } do
# index name will be "awesomeshop_Contact"
attribute :first_name, :last_name, :email
end
end |
This can probably be handled at the same time as #341 |
I am using https://github.com/influitive/apartment and I would expect index names to be generated based on the schema name as a prefix or suffix.
Example:
tenant_model
ormodel_tenant
.Apartment::Tenant.current
It always returns
public
even when its value is different.The text was updated successfully, but these errors were encountered: