Setup configuration

This library has an optional integration with django-setup-configuration, see the documentation for more information on how to run setup_configuration. To make use of this, you must install the setup-configuration dependency group:

pip install commonground-api-common[setup-configuration]

Loading JWTSecrets from a YAML file

class vng_api_common.contrib.setup_configuration.steps.JWTSecretsConfigurationStep

Configure credentials for Applications that need access

This library provides a ConfigurationStep to configure the client credentials.

To add this step to your configuration steps, add django_setup_configuration to INSTALLED_APPS and add the following setting:

SETUP_CONFIGURATION_STEPS = [
    ...
    "vng_api_common.contrib.setup_configuration.steps.JWTSecretsConfigurationStep"
    ...
]

The YAML file that is passed to setup_configuration must set the vng_api_common_credentials_config_enable flag to true to enable the step. Any number of identifier and secret pairs can be defined under vng_api_common_credentials.items

You can use the following example YAML and adapt it to your needs:

vng_api_common_credentials_config_enable: true
vng_api_common_credentials:

  # REQUIRED: true
  items:
    -

      # DESCRIPTION: Client ID to identify external API's and applications that access
      # this API.
      # REQUIRED: true
      identifier: open-notificaties-prod

      # DESCRIPTION: Secret belonging to the client ID.
      # REQUIRED: true
      secret: modify-this

Loading Applicaties from a YAML file

class vng_api_common.contrib.setup_configuration.steps.ApplicatieConfigurationStep

Configure Applicaties used for authorization.

Note

The values of client_ids must match the values of the identifier field(s) in the vng_api_common_credentials namespace. To give proper access to an application, you need to load the credentials (identifier and secret) and the Applicatie (client_ids, uuid, label and permissions)

This library also provides a ConfigurationStep to configure the applicaties.

To add this step to your configuration steps, add django_setup_configuration to INSTALLED_APPS and add the following setting:

SETUP_CONFIGURATION_STEPS = [
    ...
    "vng_api_common.contrib.setup_configuration.steps.ApplicatieConfigurationStep"
    ...
]

The YAML file that is passed to setup_configuration must set the vng_api_common_applicaties_config_enable flag to true to enable the step. Any number of Applicaties can be defined under vng_api_common_applicaties.items

You can use the following example YAML and adapt it to your needs:

vng_api_common_applicaties_config_enable: true
vng_api_common_applicaties:

  # REQUIRED: true
  items:
    -

      # DESCRIPTION: Comma separated list of consumer identifiers (client_ids)
      # REQUIRED: true
      client_ids:
        - open-notificaties-prod

      # DESCRIPTION: Unique resource identifier (UUID4)
      # DEFAULT VALUE: "713a02ff-4e7e-4474-9fc7-0d9705e77da1"
      # REQUIRED: false
      uuid: 371312eb-cf88-4ee4-86f1-f1693dd8286d

      # DESCRIPTION: A human readable representation of the application, for end users.
      # REQUIRED: true
      label: Open Notificaties (productie)

      # DESCRIPTION: If all authorizations are given to this applicatie, no individual
      # permissions have to be configured. Only enable this if you fully trust the
      # consumer.
      # DEFAULT VALUE: false
      # REQUIRED: false
      heeft_alle_autorisaties: false