Add support for using Key module to store API Key more securely

Created on 5 June 2024, 6 months ago

Problem/Motivation

We use the Key module to store authentication outside of the config, this feature adds support for using it in place of the key in config.

Proposed resolution

If the Key module is installed the api_key textfield in the admin is replace by the Key modules key_select element.

When the api_key is then used in calls to Mailgun\Mailgun:create it is first (if Key module installed) retrieved from the key entity.

Remaining tasks

There are two different methods in the code that are making calls to Mailgun\Mailgun:create, \Drupal\mailgun\MailgunFactory::create and \Drupal\mailgun\MailgunHandler::validateMailgunApiKey. Ideally there should be a single method that is making the create call - I guess logically it should be the MailgunFactory class?

User interface changes

If the Key module is installed the admin form shows Key's select field in place of the textfield.

The same config name is used 'api_key' and the code will fallback to just passing the api_key through if a Key entity cannot be loaded - this will allow the module to be updated for someone with the Key module but not suddenly stop the Mailgun API from connecting.

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom altcom_neil

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024