-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1062: Force encryption on all elements
- Loading branch information
Showing
7 changed files
with
160 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# OS2Forms Encrypt module | ||
|
||
This module extends and modifies upon [Webform Encrypt](https://www.drupal.org/project/webform_encrypt) | ||
to provide encryption of webform element values in the database. | ||
|
||
## Modifications from the base Webform Encrypt module | ||
|
||
### Encryption time | ||
|
||
Any computed elements, e.g. Computed Twig, may cause issues as | ||
their values are attempted computed after encryption. If any calculations | ||
are done this could result in runtime TypeErrors. | ||
|
||
This is handled by modifying the time at which decryption is made, in | ||
`WebformOs2FormsEncryptSubmissionStorage`. | ||
|
||
### Permissions | ||
|
||
The Webform Encrypt module introduces a `view encrypted values` permission. | ||
This permission should be granted to roles that need to view encrypted values. | ||
|
||
**Note**, that in Drupal 9 and newer drush commands are ran as an | ||
anonymous user. This means the anonymous user needs this permission, if | ||
at any point they need values from submissions to do their job. | ||
|
||
### Configurable per element | ||
|
||
The Webform Encrypt module allows configuration on element level. That is, | ||
webform builders can actively enable and disable for each element. | ||
|
||
We want all elements to be encrypted whenever encryption is enabled. | ||
This is done by `os2forms_encrypt_webform_presave` and `os2forms_encrypt_form_alter` in | ||
`os2forms_encrypt.module`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
services: | ||
os2forms_encrypt.encryptor: | ||
class: Drupal\os2forms_encrypt\Helper\Os2FormsEncryptor | ||
arguments: ['@encryption', '@entity_type.manager'] | ||
arguments: ['@encryption', '@entity_type.manager', '@config.factory'] | ||
|
||
os2forms_encrypt.form_helper: | ||
class: Drupal\os2forms_encrypt\Helper\FormHelper | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Drupal\os2forms_encrypt\Helper; | ||
|
||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
class FormHelper | ||
{ | ||
|
||
/** | ||
* Removes 'element_encrypt' element from element forms. | ||
* | ||
* @param array $form | ||
* The form. | ||
* @param FormStateInterface $form_state | ||
* The form state. | ||
* @param string $form_id | ||
* The form id. | ||
* | ||
* @return void | ||
*/ | ||
public function formAlter(array &$form, FormStateInterface $form_state, string $form_id) { | ||
if ('webform_ui_element_form' === $form_id) { | ||
if (isset($form['element_encrypt'])) { | ||
unset($form['element_encrypt']); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters