Configuring pREST
The prestd configuration is via an environment variable or toml file. Starting from version v1.2.0
it will be possible to use prestd
without any environment variable or the toml file, but the configurations used will be the described in the default column bellow.
Environment variables
var | default | description |
---|---|---|
|
| version used for environment variables, v2 introduces better naming for SSL pg connection |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| host used to connect |
|
| user used to connect |
|
| password used to connect |
|
| database name used to connect |
|
| |
| cloud factor, when declaring this variable all the previous connection fields are overwritten | |
| require | v2 of configuration envs, is the postgres connection SSL mode |
| v2 of configuration envs, is the postgres connection SSL certificate | |
| v2 of configuration envs, is the postgres connection SSL key | |
| v2 of configuration envs, is the postgres connection SSL root certificate | |
|
| Serving multiple databases over the same API with |
| false | embedded cache system |
| 10 | TTL in minute (time to live) |
| ./ | path where the cache file will be created |
| .cache.prestd.db | suffix of the name of the file that is created |
| ||
| HS256 | (Deprecrated) Not used |
| URL of .wellknown config of IDP used to fetch the JWKS used to verify token signature. Ignored if PREST_JWT_JWKS is set | |
| JWKS used to verify token signature. If set, PREST_JWT_WELLKNOWNURL is ignored | |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| SSL mode used to connect to postgres, not related to server SSL |
| SSL certificate used to connect to postgres, not related to server SSL | |
| SSL key used to connect to postgres, not related to server SSL | |
| SSL root certificate used to connect to postgres, not related to server SSL | |
|
| path to plugin storage |
|
| expose data setting enables you to configure if you want users to be able to reach listing endpoints, read more here |
|
| expose the tables listing, read more here |
|
| expose the schemas listing, read more here |
|
| expose the databases listing, read more here |
|
| changes how pREST encodes data from the database, can be set also to |
TOML
Optionally the prestd can be configured by TOML file.
You can follow this sample and create your own prest.toml
file and put this on the same folder that you run prestd
command.
Authorization
JWT
JWT middleware is enabled by default. To disable JWT need to set default to false. Enabling debug mode will also disable it.
The algorithm used is the one contained in the header of the token. The token is then validated with the provided key or JWKS.
The supported signing algorithms are described in the documentation of the JWK package.
They include the following algorithms:
The HMAC signing method:
HS256
,HS384
,HS512
The RSA signing method:
RS256
,RS384
,RS512
The ECDSA signing method:
ES256
,ES384
,ES512
The RSA signing method:
RS256
,RS384
,RS512
The ECDSA signing method:
ES256
,ES384
,ES512
The RSA signing method:
RS256
,RS384
,RS512
The ECDSA signing method:
ES256
,ES384
,ES512
Instead of the key, you could provide the URL of a .well-known OpenID configuration or the JWKS directly through PREST_JWT_WELLKNOWNURL or PREST_JWT_JWKS as environment variables or by using the TOML configuration file:
prestd will parse the JWKS to find the corresponding key from the token and fail if it does not find it.
White list
By default the endpoints /auth
do not require JWT, the whitelist option serves to configure which endpoints will not ask for jwt token
Auth
pREST has support in jwt token generation based on two fields (example user and password), being possible to use an existing table from your database to login configuring some parameters in the configuration file (or environment variable), by default this feature is disabled.
Name | Description |
---|---|
| Boolean field that activates or deactivates token generation endpoint support |
| Type that will receive the login, support for body and http basic authentication |
| Type of encryption used in password field, support for |
| Table name we will consult (query) |
| User field that will be consulted - if your software uses email just abstract name username (at prestd code level it was necessary to define an internal standard) |
| Password field that will be consulted |
to validate all endpoints with generated jwt token must be activated jwt option
Expose Data
The expose data setting enables you to configure if you want users to be able to reach listing endpoints, such as:
/databases
/schemas
/tables
An example of a configuration file disabling all listings:
If you want to disable just the database listing:
Name | Description |
---|---|
| Set this as |
| Set this as |
| Set this as |
| Set this as |
Default values for Exposure Settings
Name | Default Value |
---|---|
enabled |
|
databases |
|
schemas |
|
tables |
|
SSL
There are 4 options to set on ssl mode:
Name | Description | Comment |
---|---|---|
| Always SSL, is the default value | skips SSL verification step |
| SSL off | also used when prestd is started without a |
| Always SSL | verifies that the certificate presented is signed by a trusted CA |
| Always SSL | verifies that the certificate presented is signed by a trusted CA and the server host name matches the one in the certificate |
Debug Mode
Set environment variable PREST_DEBUG
or debug=true
on top of prest.toml file.
Single mode - multi database (PostgreSQL)
Serving multiple databases over the same API with prestd
is doable, but it is not currently supported. Thus it was introduced by default the single
configuration, it can be disabled by the following config in the toml
file:
Since v1.1.2
it is a lot safer to use multiple databases, but not yet in the ideal state of security that we want, so use it in your own risk.
CORS support
Cross-Origin Resource Sharing
Read the specific topic where we talk about CROS here.
Health check endpoint
If you need to setup a health check on your deployment (ECS/EKS or others), you can use /_health
as a provider of this information.
The server will return 503 whenever a pREST is not working properly.
Last updated