Skip to content

Commit

Permalink
Issue #3: accept long api keys in a textarea (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
herbdool authored Dec 9, 2024
1 parent efc71b2 commit e1573ba
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions key.install
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,18 @@ function key_update_1000() {
db_drop_table('key_config');
}
}

/**
* Use textarea for authentication keys stored in config.
*/
function key_update_1002() {
$config_names = config_get_names_with_prefix('key.key.');
foreach ($config_names as $name) {
$config = config($name);
if ($config->get('key_type') == 'authentication' && $config->get('key_provider') == 'config' && $config->get('key_input') == 'text_field') {
$config->set('key_input', 'textarea_field');
$config->save();
}
}

}
2 changes: 1 addition & 1 deletion plugins/key_provider/config.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

$plugin = array(
'label' => t('Configuration'),
'description' => t('The Configuration key provider stores the key in configuration in the database.'),
'description' => t('The Configuration key provider stores the key in configuration, which is likely web-accessible (and should not be).'),
'storage method' => 'config',
'key value' => array(
'accepted' => TRUE,
Expand Down
2 changes: 1 addition & 1 deletion plugins/key_type/authentication.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ $plugin = array(
'description' => t('Use for a password or API key. (A generic key type that does not belong to any other defined key type.)'),
'group' => 'authentication',
'key value' => array(
'plugin' => 'text_field',
'plugin' => 'textarea_field',
),
);
2 changes: 1 addition & 1 deletion tests/key.test
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class KeyBasicAdminTest extends BackdropWebTestCase {
'key_type_settings' => array(),
'key_provider' => 'config',
'key_provider_settings' => array('key_value' => $original_key_value),
'key_input' => 'text_field',
'key_input' => 'textarea_field',
'key_input_settings' => array(),
);

Expand Down

0 comments on commit e1573ba

Please sign in to comment.