Package: kiwitcms-tenants
IntroductionThis package provides multi-tenant support for Kiwi TCMS and is a wrapper
arounddjango-tenants.
You can use it to host different organizations on the same application server or host
multiple product instances used by different teams. Each tenant is able to see
only the information created by themselves.InstallationIMPORTANT:multi-tenancy is backed by PostgreSQL schemas! It will not work
with a different database backend.WARNING:current tenant is decided based on the FQDN by which you
are accessing Kiwi TCMS!The following changes need to be introduced into a downstream Docker image or
your Python virtualenv where the main Kiwi TCMS instance is hosted:pip install kiwitcms-tenantsthen make sureKIWI_TENANTS_DOMAINENV variable is specified !!!
The rest of the settings are installed intotcms_settings_dir/multi_tenant.pyand Kiwi TCMS will pick them up automatically!First boot configurationWhen starting your multi-tenant Kiwi TCMS instance for the first time you also
need to create information about the so called public tenant. That is the
default tenant on which your application runs:./manage.py initial_setupYour tenant will be available athttps://public.$KIWI_TENANTS_DOMAIN!
Other tenants can also be created via the web interface as well.DNS configurationYou need wildcard DNS resolution to be configured for*.tenants.example.org!If using AWS Route 53 create an A record withName==*.tenantsfor theexample.orgdomain and point it to the IP address of your Kiwi TCMS instance.Once DNS has been configured you should be able to query for various domains with
tools likedigandnslookup:$ dig public.tenant.kiwitcms.org
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-12.P2.el7 <<>> public.tenant.kiwitcms.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58543
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;public.tenant.kiwitcms.org.    IN      A

;; ANSWER SECTION:
public.tenant.kiwitcms.org. 36  IN      A       100.24.231.234

;; Query time: 35 msec
;; SERVER: 10.38.5.26#53(10.38.5.26)
;; WHEN: Tue Nov 19 14:04:09 EET 2019
;; MSG SIZE  rcvd: 71


$ nslookup linux.tenant.kiwitcms.org
Server:         10.38.5.26
Address:        10.38.5.26#53

Non-authoritative answer:
Name:   linux.tenant.kiwitcms.org
Address: 100.24.231.234All sub-domains should resolve to the same IP address!Migrating Single-Tenant to Multi-TenantSeeMigrating Single-Tenant to Multi-Tenantsection in the official django-tenants documentation! It has been contributed by the Kiwi TCMS
team and that was the procedure we’ve used to migrate the previous demo website (ST) to
its new MT version!Changelogv2.6.0 (14 Jan 2024)Update django-tenants from 3.5.0 to 3.6.1Update pylint-django from 2.5.3 to 2.5.5Start building and testing with Python 3.11Start testing with psycopg3v2.5.2 (24 Oct 2023)Addtrackers_integrationintotenant_groups.models.Group.relevant_appsto allow per-tenant assignment for permissions around personal API
tokens, seehttps://github.com/kiwitcms/trackers-integration/pull/44v2.5.1 (12 May 2023)Update to django-tenants==3.5.0Replaceform_errors_to_list()which was removed in Kiwi TCMS v12.2v2.5.0 (10 Feb 2023)Update to django-tenants==3.4.8Bug fix on Create Tenant page for Kiwi TCMS v11.7 or laterv2.4.0 (15 Nov 2022)Allow customization of tenant logo in navigation (Ivajlo Karabojkov)Add CodeQL workflow for GitHub code scanningFix make messages commandv2.3.2 (31 Oct 2022)Update django-tenants from 3.4.5 to 3.4.7Don’t add users to TenantGroup onemptytenantAdjust redirects from Tenant admin page to avoid confusionUpdate docs for initial configurationAdd more assertions into testv2.3.1 (10 Sep 2022)Don’t accessrequest.tenantif such attribute does not exist. FixesKIWI-TCMS-K2v2.3.0 (02 Sep 2022)Don’t grantauth.view_permissions even on publicly readable tenantsHonorsettings.DEFAULT_GROUPSinstead of hard-coding. Invited users and
users authorized via the Admin panel will be added to tenant groups which
matchsettings.DEFAULT_GROUPS(“Tester” by default) if such tenant groups
exist. If the setting is an empty list or there are no tenant groups matching
the specific names configured then authorized users will be left without
group associations. It will be up to a Kiwi TCMS administrator to
manually assign permissions and tenant groups for each user.v2.2.1 (30 Aug 2022)Fix a bug in thecreate_oss_tenant()helper functionv2.2.0 (14 Aug 2022)Update django-tenants from 3.4.2 to 3.4.4Show tenant information in navigation (Ivajlo Karabojkov)Allow editing Tenant.name to make it easier for admins to customize the
text shown in navigation!Internal updates around testing and CIv2.1.1 (27 Apr 2022)Don’t crash if user can’t change tenant groups. FixesKIWI-TCMS-J8v2.1.0 (27 Apr 2022)Addrefresh_tenant_permissionscommand which will be executed automatically
byrefresh_permissionsv2.0.1 (19 Apr 2022)Fix URL is help messagev2.0.0 (18 Apr 2022)Define per-tenantGroupmodel and add an authentication backend which will
consume permissions from tenant-groups. Closes #104Issue #104Add pre-commit CI config & apply automatic fixesv1.11.0 (24 Jan 2022)Add System check forKIWI_TENANTS_DOMAINenvironment variable. ClosesIssue #140v1.10.0 (19 Jan 2022)Update django-tenants from 3.4.1 to 3.4.2,
will help with migration to Django 4v1.9.0 (10 Jan 2022)Update django-tenants from 3.3.4 to 3.4.1Update expected error message for testsFix code coverage uploadsv1.8.0 (16 Oct 2021)Update django-tenants from 3.3.2 to 3.3.4. Fixes a bug for cloning tenants
when DB username contains a dashUse f-strings b/c pylint really loves themv1.7.0 (03 Sep 2021)Faster tenant creation withclone_tenant. FixesIssue #127Requires a schema with nameemptyto be present!Fix pylint warningsMigrate from Travis CI to GitHub Actionsv1.6.0 (18 Jun 2021)Update django-tenants from 3.3.1 to 3.3.2More robust tenant domain detection to avoid bugs in the case where
public tenant’s domain doesn’t use a prefix (e.g. matches KIWI_TENANT_DOMAIN)v1.5.0 (04 Jun 2021)Database: RenameTenant.on_trial->Tenant.publicly_readableAllow unauthorized users to access publicly readable tenantsUpdate django-tenants from 3.3.0 to 3.3.1Update translation stringsTested with Kiwi TCMS v10.1ConvertNewTenantFormto inherit fromModelFormv1.4.4 (12 May 2021)Update django-tenants from 3.2.1 to 3.3.0Tested with Kiwi TCMS v10.0Tested with Python 3.8v1.4.3 (25 Jan 2021)Add missing csrf_token in NewTenantFormv1.4.2 (23 Dec 2020)Fix a bug with how we override captcha field in user registration formFix invitation email subjectv1.4 (23 Dec 2020)Tested with Kiwi TCMS v8.9Add warning forowner_idin READMEReplace ModelChoiceField with UserField. FixesIssue #114Support user invitions for tenant. FixesIssue #116v1.3.1 (09 Sep 2020)Replace deprecated import to silence warnings with Django 3.1v1.3 (26 Aug 2020)Tested with Kiwi TCMS v8.6Update django-tenants from 3.1.0 to 3.2.1Don’t pin dependencies in devel.txtv1.2.1 (24 Jul 2020)Filter out AuthorizedUsersChangeForm even on errorsTested with Kiwi TCMS v8.5v1.2 (20 Jun 2020)Update django-tenants from 3.0.3 to 3.1.0Improvements in tests and minor updates to make linters happyTested with Kiwi TCMS v8.4v1.1.1 (27 Apr 2020)Do not shipTENANT_APPSb/c it is distributed with Kiwi TCMS v8.3v1.1 (25 Apr 2020)Bring back an improved HTML placeholder for schema_nameProperly validate input values for schema/domain namesv1.0.3 (24 Apr 2020)Always lower case schema_name to make sure it can actually be
used as a valid hostnamev1.0.2 (24 Apr 2020)Update django-tenants from 3.0.1 to 3.0.3Show valid schema_name pattern as help text in UIRemove schema_name placeholder text because it was misleadingv1.0.1 (18 Mar 2020)Slightly adjust default values for settingsTENANT_APPSandMULTITENANT_RELATIVE_MEDIA_ROOTto match Kiwi TCMS and installations
prior to turning this package into a plugin. This will avoid dusrupting
existing deployments!v1.0 (15 Mar 2020)Turn into proper Kiwi TCMS plugin and install settings overrides undertcms_settings_dir/(compatible with Kiwi TCMS v8.2 or later)does not needMENU_ITEMSandROOT_URLCONFoverride anymoredoes not need to loadtcms_tenantsinINSTALLED_APPSmanuallyonly need to specifyKIWI_TENANTS_DOMAINenv variable!Requiretcms_tenants.add_tenantpermission forNewTenantViewReimplementNewTenantViewasFormViewRefactorredirect_to()to class based viewAdd tests for admin.py. Closes #5Issue #5Replacedatetime.nowwithtimezone.nowfor better support of
installations with enabled timezone configEnable pylint. ClosesIssue #17Enable flake8v0.5.1 (17 Feb 2020)Update django-tenants from 3.0.0 to 3.0.1. FixesIssue #60v0.5 (16 Jan 2020)Bump django-tenants from 2.2.3 to 3.0.0Tested successfully against Kiwi TCMS v7.3 with Django 3.0v0.4.7 (11 Dec 2019)Settcms_tenants.tests.LoggedInTestCase.tenant.owner.passwordto
“password” so it can be reused by downstream testsv0.4.6 (11 Dec 2019)New translations for SlovenianReplace ugettext_lazy with gettext_lazy for Django 3.0Start shippingtcms_tenants.teststo be used by other multi-tenant
add-on packagesConfirmed working against Kiwi TCMS v7.2v0.4.5 (24 Nov 2019)Document how to configure multi-tenancyDocument ST to MT migrationAdd helper methodcreate_oss_tenant()Internal updates toTENANT_APPSwhile testingv0.4.4 (29 Oct 2019)New translations for Russianv0.4.3 (18 May 2019)AddTenant.organizationfieldWhen creating tenant set site.name to tenant.domain.domainv0.4.0 (12 May 2019)Allow overriding create tenant form URL via additional
context variable namedform_action_urlv0.3.0 (08 May 2019)Send email when a new tenant is createdAdd middleware which can be used to block unpaid tenantsRewrite middleware without deprecatedMiddlewareMixin, Refers toIssue #17Add more testsv0.2.0 (05 May 2019)Removedjango.contrib.contenttypesfromTENANT_APPSMake it easier to overrideNewTenantViewUseDateTimeFieldinstead ofDateFieldShow first primary domain in AdminMassive speed up testsPylint fixesv0.1.10 (03 May 2019)Bring backtenant_urltemplate tag with optionalschema_nameparameterv0.1.9 (03 May 2019)Fix failing testsv0.1.8 (03 May 2019)Fix packaging for missing migrations directoryAdd view which facilitates GitHub login & redirects.
Callers are supposed to perform OAuth login via public tenant and then
redirect to this view which will send the browser to the actual tenant!
This will resolve problems withredirect_urimismatch that we’re
seeing from GitHub b/c you can only specify one redirect uripylint fixesRemove unusedtemplatetags/directoryv0.1.6 (28 April 2019)Tenant object now has an ownerv0.1.5 (24 April 2019)Update django-tenants to 2.2.3New translations for SlovenianDon’t shiptest_project/files in wheel packagev0.1.4 (15 April 2019)Update to django-tenants 2.2.0 for Django 2.2 supportv0.1.3 (10 April 2019)Rename settingTCMS_TENANTS_DOMAINtoKIWI_TENANTS_DOMAINv0.1.2 (04 April 2019) - initial releaseSupport creating of tenants via web interfaceSupport for deleting tenants only by super-userSupport for authorizing other users to access the current tenantMiddleware which returns 403 Forbidden when non-authorized user
tries to access a tenantSupport for overriding thetcms_tenants/new.htmltemplate to
provide SLA, terms and conditions, etc.