Kaui core mountable engine. For Kaui the UI, see killbill-admin-ui-standalone.
| Kaui version | Kill Bill version |
|---|---|
| 0.14.y | 0.16.z |
| 0.15.y | 0.18.z (Rails 4) |
| 0.16.y | 0.18.z (Rails 5) |
| 1.x.y | 0.20.z (Rails 5) |
| 2.1.y | 0.22.z (Rails 5) |
| 2.2.y | 0.24.z (Rails 6) |
| 3.x.y | 0.24.z (Rails 7) |
Ruby 3.1.0+ or JRuby 10.0.6.0+ required.
Note: use Ruby, not JRuby, for running the app locally.
You can run Kaui locally by using the test/dummy app provided:
export RAILS_ENV=development DB_HOST=127.0.0.1 DB_USER=root DB_PASSWORD=root DB_PORT=3306
bundle install
bundle exec rails db:migrate
bundle exec rails s
The Kill Bill URL can be configured through the KILLBILL_URL environment variable, e.g.
KILLBILL_URL='http://killbill.acme:8080'
The Kaui gem comes with a kaui script to mount it in your existing Rails app.
Kaui expects the container app to define the current_user method, which returns the name of the logged-in user. This is used by Kill Bill for auditing purposes.
Migrations can be copied over to your app via:
bundle exec rake kaui:install:migrations
Finally, a Kill Bill server needs to be running for Kaui to fetch its information (see the Configuration section below). The default login credentials are admin/password. Users, Credentials, Roles and Permissions are passed through to Kill Bill. It uses Basic Auth by default, but the backend is pluggable (LDAP, ActiveDirectory, etc.).
rails t
Note: functional and integration tests require an instance of Kill Bill to test against.
In order to generate the Rubygems-friendly kaui script, you need to build the gem
and install it locally.
First, build the gem in the pkg directory:
rake build
Then, install and run it from a local directory:
mkdir foo
gem install pkg/kaui-*.gem -i foo
GEM_PATH=$PWD/foo:$GEM_PATH ./foo/bin/kaui /path/to/rails/app --path=$PWD --skip-bundle
Alternatively, you can run the kaui script under bin by setting your loadpath correctly:
ruby -Ilib bin/kaui /path/to/rails/app --path=$PWD --skip-bundle
KAUI has been enhanced to support multi-tenancy. In order to benefit from that mode, remove the properties KillBillClient.api_key and KillBillClient.api_secret from the config/initializers directory.
In multi-tenancy mode, there are two kinds of users:
- The multi-tenant admin user, which has the rights to configure the tenant information (creation of tenant, add allowed users for specific tenant, upload catalog, ...)
- The per-tenant admin user, which operates just a given tenant
Those roles and permissions are defined the same way other permissions are defined: The Shiro configuration (static config file, LDAP) in Kill Bill, will determine for each user its associated role, and the roles will have a set of available permissions. The new permissions have been created:
- TENANT_CAN_VIEW
- TENANT_CAN_CREATE
- OVERDUE_CAN_UPLOAD
- CATALOG_CAN_UPLOAD
The enforcement in KAUI is based on the CanCan gem.
KAUI has been enriched with new models and new screens to manage the multi-tenancy, and those are available for the multi-tenant admin user:
- The
kaui_tenantstable will list the available tenants (from KAUI point of view); note that this is redundant with the Kill Billtenantstable, and the reason is that theapi_secretneeds to be maintained in KAUI as well, so listing the existing tenants from Kill Bill would not work since that key is encrypted and cannot be returned. A new screen mounted on/admin_tenantsallows to configure new tenants. The view allows to create the new tenant in Kill Bill or simply updates the local KAUI config if the tenant already exists. - The
kaui_allowed_userstable along with the join tablekaui_allowed_user_tenantswill list all the users in the system that can access specific tenants. The join table is required since a given user could access multiple tenants (e.g multi-tenant admin user), and at the same time many users could access the same tenant. A new screen mounted on/admin_allowed_usersallows to configure the set of allowed users associated to specific tenants.
A web application whose users sign in with AWS Cognito can open Kaui for them without a second login, through POST /sso/cognito/exchange (POST /sso/aviate/exchange is kept as an alias). The feature is disabled (the endpoint answers 404) unless the Cognito issuer and at least one app client id are configured, either as system properties or as environment variables:
| System property | Environment variable | Description |
|---|---|---|
kaui.cognito.issuer |
KAUI_COGNITO_ISSUER |
https://cognito-idp.<region>.amazonaws.com/<user-pool-id> |
kaui.cognito.client_ids (or kaui.cognito.client_id) |
KAUI_COGNITO_CLIENT_IDS (or KAUI_COGNITO_CLIENT_ID) |
Accepted Cognito app client ids (comma-separated) |
kaui.cognito.login_url |
KAUI_COGNITO_LOGIN_URL |
Optional. Login page of the application the users come from (http or https), where they are sent when their Kill Bill session expires |
The client sends the Cognito ID token as Authorization: Bearer <token> and, optionally, target (a Kaui path such as /accounts). The response is {"redirectUrl": "..."} (including the context path Kaui is mounted at) and sets the Kaui session cookie. Two modes:
- basic:
kb_username(defaults to the email of the token) andkb_password. Kaui logs into Kill Bill with Basic auth; the tenant comes from thekaui_allowed_usersof that user (tenant_namedisambiguates). - bearer: no
kb_password, for users without Kill Bill credentials (requires the Cognito realm in Kill Bill). Kaui logs into Kill Bill with the Bearer token and the Kaui user is the principal reported by Kill Bill (e.g.cognito:alice@acme.com). The tenant comes fromtenant_api_keyandtenant_api_secret, which must match a tenant ofkaui_tenants(403otherwise); the user is then allowed on that tenant. If Kill Bill has no Cognito realm, the answer is401.
Users of the bearer mode have no password: when their Kill Bill session expires, Kaui sends them to kaui.cognito.login_url when it is set, and displays a "reopen Kaui from the application you came from" page otherwise, instead of the sign-in form (they have no Kill Bill password to type in it). The Tenants, Users and Roles settings screens are only listed for them (sidebar, home page), and only served if their Kill Bill permissions include *:*: otherwise they are sent back to the home page with a warning (403 for non-HTML requests).