Skip to main content
Version Next

Database Access Rules Configuration

Given an already created instance (Database Instance Initialization), PostgreSQL provides mechanisms to restrict data access. This is the first level of security for the PostgreSQL instance, determining whether a connection will be allowed.

Client authentication is controlled by the pg_hba.conf configuration file, also stored in the cluster's data directory (hba stands for host-based authentication). A default pg_hba.conf file is installed when the database instance is initialized.

When configuring Access Rules, it is possible to specify the connection type, the name(s) of the Database(s), the user(s) or group(s) identification, the subnet or authorized host, and the authentication method.

Prerequisites
Command Syntax
Terminal input
    pgsmart db config [Flags]

Flags

  • -D, --pgdata=<path> [Default: data]. => PostgreSQL instance Data Directory.
  • -M, --pgversion=(11|12|13|14|15). => PostgreSQL major version.
  • -a, --agent=<agent>. => Alias, hostname, or IP of the server where the desired PgSmart Agent is installed.
  • -h, --help. => Help
Non-Interactive Configuration

Non-interactive execution is disabled for this operation.

Interactive Configuration
Terminal input
        pgsmart db config

Configuring Access Rules for the Database Instance

  1. Select the PgSmart Agent (or Register a new Agent).

  2. Select Configurações das instâncias from the options menu.

  3. Select the Data Directory of the PostgreSQL instance for which you want to configure the access rules.

  4. Select the Regras de Acesso option.

When selecting the Access Rules option, the following operations will be available:

  • Listar: Allows viewing existing access rules.
  • Criar: Allows creating a new access rule.
  • Alterar: Allows modifying an access rule.
  • Duplicar: Allows duplicating an access rule.
  • Remover: Allows removing an access rule.

List Access Rules

  1. Select the Listar operation.

    The list of current Access Rules will be displayed.

    Figure 1 - Access Rules - List
    Figure 1 - Access Rules - List

Create an Access Rule

  1. Select the Criar operation.

  2. Select the Type of Access Rule.

  3. Specify which databases will be included in the new Access Rule. (Default: all - any localhost connection will match any database.)

  4. Specify the users or groups to be included in the new Access Rule (Default: all - everyone).

  5. Specify the subnet or authorized host.

  6. Select the authentication method.

  7. Confirm the creation of the new Access Rule.

  8. Confirm the Reload to apply the new Access Rules.

    Figure 2 - Access Rules - Create
    Figure 2 - Access Rules - Create

Modify an Access Rule

  1. Select the Alterar operation.

    When selecting this action, PgSmart will display a list of valid access rules.

  2. Select the rule you want to modify.

  3. Adjust the desired item(s) in the presented sequence of options, confirming each item with [Enter].

  4. Confirm the modification of the Access Rule.

  5. Confirm the Reload of the PostgreSQL instance.

    Figure 3 - Access Rules - Modify
    Figure 3 - Access Rules - Modify

Remove an Access Rule

  1. Select the Remover operation.

    When selecting this action, PgSmart will display a list of valid access rules.

  2. Select the Access Rule you wish to remove.

  3. Confirm the removal.

  4. Confirm the Reload of the PostgreSQL instance.

    Figure 4 - Access Rules - Remove
    Figure 4 - Access Rules - Remove

Duplicate an Access Rule

  1. Select the Duplicar operation.

When selecting this action, PgSmart will display a list of valid access rules.

  1. Select the rule you wish to duplicate.

  2. Adjust each option for the new rule, confirming each item with [Enter].

  3. Confirm the duplication of the Access Rule.

  4. Confirm the Reload of the PostgreSQL instance.

Figure 5 - Access Rules - Duplicate
Figure 5 - Access Rules - Duplicate
Final Notes
note
  • To apply actions to Access Rules, it is necessary to perform the Reload of the PostgreSQL instance.

  • This option is provided by PgSmart at the time of operation confirmation.

  • If Reload is not confirmed, the configuration will remain in the file until the instance reload is executed.