> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/sdks/backend-sdk/backend1n/release_notes/4.5.0_release_notes.md).

# 4.5.0

This Version adds support for PostgreSQL databases. Optional JWT authentication was also added, configurable from `config.json` or via environment variables `FACEPHI_BACKEND1N_REST_*`.

**There are no contract changes** in the endpoints. Nor has the previous MongoDB support been altered. The decision on which database technology the service will use will be made when it starts, based on the connection string:

```bash
# Accepted MongoDB prefixes.
# mongodb://
# mongodb+srv://
export DATABASE_CONNECT_STRING=mongodb://user:pass@localhost:32902/?directConnection=true&serverSelectionTimeoutMS=5000

# Accepted PostgreSQL prefixes.
# postgres://
# postgresql://
export DATABASE_CONNECT_STRING=postgresql://user:pass@localhost:32903/db_backend
```

## About the databases

In the case of MongoDB, the service itself will create a database named `db-backend`, if it does not already exist. It will host two collections:

* `media` to store images.
* `patterns` to store biometric patterns.

The PostgreSQL case differs slightly. A DB named `db_backend` must have been created beforehand by the system administrator. PostgreSQL makes it difficult to create databases from the client itself. An example of the prior commands the administrator should run would be:

```bash
sudo -u postgres psql -c "CREATE ROLE backend1n WITH LOGIN PASSWORD 'backend1n';"
sudo -u postgres psql -c "CREATE DATABASE db_backend OWNER backend1n;"
sudo -u postgres psql -d db_backend -c "GRANT ALL ON SCHEMA public TO backend1n;"
```

Inside the PostgreSQL DB, the service will create two tables, just as it did with MongoDB:

* `media` to store images.
* `patterns` to store biometric patterns.

> **Important:** The connection strings must include the user/password information or any additional information that allows the service access with read/write permissions.

## Added

* Optional JWT authentication, configurable from `config.json` or via environment variables `FACEPHI_BACKEND1N_REST_*`.
* Database support `PostgreSQL`.
* Coverage of integration tests for public and protected endpoints when JWT authentication is enabled.
* Coverage of integration tests for the MongoDB and PostgreSQL backends.
