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

♻️ Changed credentials logic in sap_rfc to get credentials from KeyVault #866

Merged
merged 17 commits into from
Apr 5, 2024
Merged

♻️ Changed credentials logic in sap_rfc to get credentials from KeyVault #866

merged 17 commits into from
Apr 5, 2024

Conversation

adrian-wojcik
Copy link
Contributor

@adrian-wojcik adrian-wojcik commented Mar 6, 2024

Summary

Adding additional logic and parameters to sap_rfc connector in order to retrieve credentials from Azure KeyVault.

Importance

Because, it enhances security by securely storing and managing sensitive information, eliminating the need for local storage of such data. Secondly, making Azure Key Vault the primary data source introduces flexibility, enabling seamless updates and rotation of keys and secrets without requiring modifications to the application code, thereby enhancing security levels and facilitating configuration management.

Checklist

This PR:

  • follows the guidelines laid out in CONTRIBUTING.md
  • [] links relevant issue(s)
  • adds/updates tests (if appropriate)
  • adds/updates docstrings (if appropriate)
  • adds an entry in CHANGELOG.md

@adrian-wojcik adrian-wojcik changed the base branch from main to dev March 6, 2024 13:30
@adrian-wojcik adrian-wojcik requested a review from Rafalz13 March 6, 2024 13:31
@adrian-wojcik adrian-wojcik changed the title ♻️ Changed credentials logic to get credentials from KeyVault ♻️ Changed credentials logic in sap_rfc to get credentials from KeyVault Mar 6, 2024
Copy link
Contributor

@Rafalz13 Rafalz13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added few comments.

viadot/tasks/sap_rfc.py Outdated Show resolved Hide resolved
Comment on lines 62 to 64
saprfc_credentials_key (str, optional): Azure KV secret. Defaults to "SAP".
env (str, optional): SAP environment. Defaults to "PROD".
By default, they're taken from the local viadot config.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can modify the docstring because it is a key for the credentials - it can be taken from Azure Key Vault or local config. It depends on what is possible.

Please change for the source and flow as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in task and flow

@@ -97,6 +110,9 @@ def run(
multiple options are automatically tried. Defaults to None.
replacement (str, optional): In case of sep is on a columns, set up a new character to replace
inside the string to avoid flow breakdowns. Defaults to "-".
credentials (dict, optional): The credentials to use to authenticate with SAP.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
credentials (dict, optional): The credentials to use to authenticate with SAP.
credentials (dict, optional): The credentials to use to authenticate with SAP. Defaults to None.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed docstring to the old one from flow. And variable name from 'credentials' to 'sap_credentials'

Copy link
Contributor

@Rafalz13 Rafalz13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please modify docstrings and add tests.

viadot/tasks/sap_rfc.py Outdated Show resolved Hide resolved
viadot/flows/sap_rfc_to_adls.py Outdated Show resolved Hide resolved
viadot/flows/sap_rfc_to_adls.py Outdated Show resolved Hide resolved
viadot/tasks/sap_rfc.py Outdated Show resolved Hide resolved
Copy link

gitguardian bot commented Mar 18, 2024

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@adrian-wojcik adrian-wojcik requested a review from Rafalz13 March 18, 2024 13:04
Copy link
Contributor

@Rafalz13 Rafalz13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added few comments.

viadot/flows/sap_rfc_to_adls.py Outdated Show resolved Hide resolved
viadot/flows/sap_rfc_to_adls.py Outdated Show resolved Hide resolved
viadot/sources/sap_rfc.py Outdated Show resolved Hide resolved
viadot/sources/sap_rfc.py Outdated Show resolved Hide resolved
@adrian-wojcik adrian-wojcik requested a review from Rafalz13 April 2, 2024 06:11
@@ -67,6 +69,8 @@ def __init__(
...
)
sap_credentials (dict, optional): The credentials to use to authenticate with SAP. By default, they're taken from the local viadot config.
sap_credentials_key (str, optional): The key for sap credentials located in the local config for Azure Key Vault. Defaults to "SAP".
Copy link
Contributor

@Rafalz13 Rafalz13 Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a wrong suggestion here. Please change for the rest.

Suggested change
sap_credentials_key (str, optional): The key for sap credentials located in the local config for Azure Key Vault. Defaults to "SAP".
sap_credentials_key (str, optional): The key for sap credentials located in the local config or Azure Key Vault. Defaults to "SAP".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed back

@@ -97,6 +110,9 @@ def run(
multiple options are automatically tried. Defaults to None.
replacement (str, optional): In case of sep is on a columns, set up a new character to replace
inside the string to avoid flow breakdowns. Defaults to "-".
sap_credentials (dict, optional): The credentials to use to authenticate with SAP. By default, they're taken from the local viadot config.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case by default it is taken from KeyVault (lines 136-141). Default is None and it is taken from KeyVault here in task or local config on the 'source' level (SAPRFC class). Please take a look and adjust docstring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@adrian-wojcik adrian-wojcik requested a review from Rafalz13 April 4, 2024 08:05
@Rafalz13 Rafalz13 merged commit 624f5b8 into dyvenia:dev Apr 5, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants