flexisip-account-manager/flexiapi
2021-09-16 14:19:45 +02:00
..
app Complete README to add selinux rule about sendmail 2021-09-09 16:18:50 +02:00
bootstrap Update the dependencies 2021-01-05 15:35:51 +01:00
config Add a toggle to disable public account registration 2021-08-02 15:54:35 +02:00
database Add missing unique constraints to the Accounts, Passwords and Aliases tables 2021-09-16 14:19:45 +02:00
public Some small UI fixes in the UI panel 2021-07-29 15:50:07 +02:00
resources Save the removed accounts in a "tombstones" table to prevent them to be recreated 2021-09-07 15:52:21 +02:00
routes Add a permanent provisioning URL, authenticated 2021-08-04 16:49:14 +02:00
storage Remove the db.sqlite 2020-09-14 11:24:59 +02:00
tests Save the removed accounts in a "tombstones" table to prevent them to be recreated 2021-09-07 15:52:21 +02:00
.editorconfig Import a new API, build with Laravel 2020-02-03 15:20:48 +01:00
.env.example Complete README to add selinux rule about sendmail 2021-09-09 16:18:50 +02:00
.gitattributes Import a new API, build with Laravel 2020-02-03 15:20:48 +01:00
.gitignore Complete the documentation regarding how DotEnv configuration is handled 2020-09-14 16:41:47 +02:00
.styleci.yml Import a new API, build with Laravel 2020-02-03 15:20:48 +01:00
artisan Import a new API, build with Laravel 2020-02-03 15:20:48 +01:00
composer.json Add a create and edit feature for accounts in the Admin panel 2021-07-29 08:48:11 +00:00
composer.lock Add a warning in the README regarding the memory limit of the database migration 2021-09-13 17:07:26 +02:00
composer.phar Allow the account creation admin API endpoint to set a specific domain if EVERYONE_IS_ADMIN is set to true 2021-08-19 11:39:53 +02:00
COPYING Add COPYING 2020-09-14 11:24:59 +02:00
package.json Import a new API, build with Laravel 2020-02-03 15:20:48 +01:00
phpunit.xml Remove totally the SQLite support 2021-06-03 11:31:54 +02:00
README.md Add a warning in the README regarding the memory limit of the database migration 2021-09-13 17:07:26 +02:00
server.php Import a new API, build with Laravel 2020-02-03 15:20:48 +01:00
webpack.mix.js Import a new API, build with Laravel 2020-02-03 15:20:48 +01:00

FlexiAPI

FlexiAPI brings a web panel and a REST API to manage and handle Flexisip accounts related features.

DotEnv configuration

FlexiAPI relies on DotEnv to be configured. This configuration can be accessed using the existing .env file that can be itself overwritten by an environnement variables.

Thoses variables can then be set using Docker-Compose, a bash script or a web-server for example.

If you're installing FlexiAPI from the RPM package you can find the configuration file at /etc/flexisip-account-manager/flexiapi.env.

Manual setup

Clone the repository, install the dependencies and generate a key.

composer install --no-dev
php artisan key:generate

Then configure the database connection in the .env file (from the .env.example one). And migrate the tables. The migration MUST be run on an empty database.

php artisan migrate

You can also run the test suit using phpunit.

To know more about the web server configuration part, you can directly visit the official Laravel installation documentation.

Configure the .env file

Complete all the other variables in the .env file or by overwritting them in your Docker or web-server configuration:

  • The OVH SMS connector
  • SMTP configuration
  • App name, SIP domain…

Multi instances environement

FlexiAPI can also handle multi domains setup.

Multiple virtualhosts option

In your web server configuration create several virtualhosts that are pointing to the same FlexiAPI instance. Using the environnement variables you can then configure FlexiAPI per instance.

With Apache, use the mod_env module.

SetEnv APP_NAME "VirtualHost One"

On nginx use fastcgi_param to pass the parameter directly to PHP.

location ~ [^/]\.php(/|$) {
    …
    include /etc/nginx/fastcgi_params;
    fastcgi_param  APP_NAME     "VirtualHost Two";
}

Warning

Do not create a cache of your configuration (using artisan config:cache) if you have a multi-environnement setup. The cache is always having the priority on the variables set in the configuration files.

Multiple .env option

To do so, configure several web servers virtualhosts and set a specific APP_ENV environnement variable in each of them.

Note that if APP_ENV is not set FlexiAPI will directly use the default .env file.

FlexiAPI will then try to load a custom configuration file with the following name .env.$APP_ENV. So for the previous example .env.foobar.

You can then configure your instances with specific values.

INSTANCE_COPYRIGHT="FooBar - Since 1997"
INSTANCE_INTRO_REGISTRATION="Welcome on the FooBar Server"
INSTANCE_CUSTOM_THEME=true
…

Custom theme

If you set INSTANCE_CUSTOM_THEME to true, FlexiAPI will try to load a CSS file located in public/css/$APP_ENV.style.css. If the file doesn't exists it will fallback to public/css/style.css.

We advise you to copy the style.css file and rename it to make your custom CSS configurations for your instance.

Flexisip Push notifications pusher

The API endpoint POST /tokens uses the flexisip_pusher binary delivered by the Flexisip project (and related package). You must configure the APP_FLEXISIP_PUSHER_PATH environement variable to point to the correct binary.

APP_FLEXISIP_PUSHER_PATH=/opt/belledonne-communications/bin/flexisip_pusher

This binary will be executed under "web user" privileges. Ensure that all the related files required by flexisip_pusher can be accessed using this user account.

/var/opt/belledonne-communications/log/flexisip/flexisip-pusher.log // Write permissions
/etc/flexisip/apn/*pem // Read permissions

systemd restrictions

To retrieve the devices configuration, FlexiAPI connects to the UNIX socket opened by Flexisip. The socket is located in the /tmp directory. If you have issues connecting to that socket, please ensure that your PHP process have access to it (user, rights).

The systemd service PrivateTmp setting might restrict that access.

SELinux restrictions

If you are running on a CentOS/RedHat machine, please ensure that SELinux is correctly configured.

Allow the webserver user to write in the storage/ directory:

chcon -R -t httpd_sys_rw_content_t storage/

If your database is located on a remote machine, you should also allow your webserver user to connect to remote hosts:

semanage port -a -t http_port_t -p tcp 3306 // Open remote connections on the MySQL port for example
setsebool -P httpd_can_network_connect 1 // Allow remote network connected
setsebool -P httpd_can_network_connect_db 1 // Allow remote database connection

If you are planning to send emails using your account manager:

setsebool -P httpd_can_sendmail 1 // Allow email to be sent

Usage

For the web panel, a generale documentation is available under the \documentation page. For the REST API, the /api page contains all the required documentation to authenticate and request the API.

Console commands

FlexiAPI is shipped with several console commands that you can launch using the artisan executable available at the root of this project.

Migrate an old database

FlexiAPI needs an empty database to run its migration. The following console command allow you to import simultanously an exisiting Flexisip database and the old FlexiAPI SQLite database file (if you have one) in the new one. To do so, please specify the new database configuration in the .env file and run the following command.

The migration script requires at least 300mb of memory to run. You should edit the memory_limit in the php.ini file to increase it.

php artisan db:import {old_dbname} {old_sqlite_file_path?} --username={old_username} --password={old_password}

Several other parameters are also available to customize the migration process, you can list them all using the command documentation.

php artisan -h db:import

Clear Expired Nonces for DIGEST authentication

This will remove the nonces stored that were not updated after x minutes.

php artisan digest:expired-nonces-clear {minutes}

Remove the unconfirmed accounts

This request will remove the accounts that were not confirmed after x days. In the database an unconfirmed account is having the activated attribute set to false.

php artisan accounts:clear-unconfirmed {days} {--apply} {--and-confirmed}

The base request will not delete the related accounts by default. You need to add --apply to remove them.

Remove deleted accounts tombstones

This request will remove the deleted accounts tombstones created after x days.

php artisan accounts:clear-accounts-tombstones {days} {--apply}

The base request will not delete the related tombstones by default. You need to add --apply to remove them.

Set an account admin

This command will set the admin role to any available Flexisip account (the external Flexisip database need to be configured beforehand). You need to use the account DB id as a parameter in this command.

php artisan accounts:set-admin {account_id}

Once one account is declared as administrator, you can directly configure the other ones using the web panel.

Provisioning

FlexiAPI is providing endpoints to provision Liblinphone powered devices. You can find more documentation about it on the /api#provisioning documentation page.

Provisioning hooks

The XML returned by the provisioning endpoint can be completed using hooks.

To do so, copy and rename the provisioning_hooks.php.example file into provisioning_hooks.php in the configuration directory and complete the functions in the file. The functions already contains example codes to show you how the XML can be enhanced or completed.