Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added encrypted credentials column in sap configuration #2208

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Unreleased
----------
* nothing unreleased

[4.23.13]
----------
* feat: added encrypted columns for user credentials for SAP config

[4.23.12]
----------
* feat: feat: added encrypted client id and secret for canvas integration
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "4.23.12"
__version__ = "4.23.13"
11 changes: 11 additions & 0 deletions enterprise/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,3 +475,14 @@ def mirror_id_and_secret_to_decrypted_fields(sender, instance, **kwargs): # py

if COURSE_ENROLLMENT_CHANGED is not None:
COURSE_ENROLLMENT_CHANGED.connect(course_enrollment_changed_receiver)


@receiver(pre_save, sender=SAPSuccessFactorsEnterpriseCustomerConfiguration)
def update_decrypted_credentials(sender, instance, **kwargs): # pylint: disable=unused-argument
"""
Ensure that the decrypted credentials have same values as unencrypted credentials.
"""
if instance.key != instance.decrypted_key:
instance.decrypted_key = instance.key
if instance.secret != instance.decrypted_secret:
instance.decrypted_secret = instance.secret
2 changes: 2 additions & 0 deletions integrated_channels/sap_success_factors/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class SAPSuccessFactorsEnterpriseCustomerConfigurationAdmin(DjangoObjectActions,
"sapsf_base_url",
"sapsf_company_id",
"key",
"decrypted_key",
"secret",
"decrypted_secret",
"sapsf_user_id",
"user_type",
"has_access_token",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2.23 on 2024-08-23 09:36

from django.db import migrations, models
import fernet_fields.fields


class Migration(migrations.Migration):

dependencies = [
('sap_success_factors', '0016_sapsuccessfactorslearnerdatatransmissionaudit_is_transmitted'),
]

operations = [
migrations.AddField(
model_name='sapsuccessfactorsenterprisecustomerconfiguration',
name='decrypted_key',
field=fernet_fields.fields.EncryptedCharField(blank=True, default='', help_text='The encrypted OAuth client identifier. It will be encrypted when stored in the database.', max_length=255, null=True, verbose_name='Encrypted Client ID'),
),
migrations.AddField(
model_name='sapsuccessfactorsenterprisecustomerconfiguration',
name='decrypted_secret',
field=models.CharField(blank=True, default='', help_text='The encrypted OAuth client secret. It will be encrypted when stored in the database.', max_length=255, null=True, verbose_name='Encrypted Client Secret'),
),
]
27 changes: 27 additions & 0 deletions integrated_channels/sap_success_factors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from logging import getLogger

from config_models.models import ConfigurationModel
from fernet_fields import EncryptedCharField

from django.db import models
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -80,6 +81,19 @@ class SAPSuccessFactorsEnterpriseCustomerConfiguration(EnterpriseCustomerPluginC
verbose_name="Client ID",
help_text=_("OAuth client identifier.")
)

decrypted_key = EncryptedCharField(
max_length=255,
verbose_name="Encrypted Client ID",
blank=True,
default='',
help_text=_(
"The encrypted OAuth client identifier."
" It will be encrypted when stored in the database."
),
null=True
)

sapsf_base_url = models.CharField(
max_length=255,
blank=True,
Expand Down Expand Up @@ -108,6 +122,19 @@ class SAPSuccessFactorsEnterpriseCustomerConfiguration(EnterpriseCustomerPluginC
verbose_name="Client Secret",
help_text=_("OAuth client secret.")
)

decrypted_secret = models.CharField(
max_length=255,
blank=True,
default='',
verbose_name="Encrypted Client Secret",
help_text=_(
"The encrypted OAuth client secret."
" It will be encrypted when stored in the database."
),
null=True
)

user_type = models.CharField(
max_length=20,
choices=USER_TYPE_CHOICES,
Expand Down
Loading