Skip to content

[Hold][WIP] Workflow Endpoint: how to encrypt secrets #670

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Paul-Cornell
Copy link
Collaborator

@Paul-Cornell Paul-Cornell commented Jun 23, 2025

Work in progress. Still waiting for renamed "retrieve" endpoint, and certificate signing.

For now, see:

Copy link
Contributor

@awalker4 awalker4 left a comment

Choose a reason for hiding this comment

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

Added some comments! I can add a commit to this branch to update the code samples once the new certificate flow is ready. Some other thoughts:

  • I think the pattern of showing redacted on the encrypted text is a bit noisy. It's instructive to show the ---BEGIN PUBLIC KEY--- headers and such, but the other text will always be garbled nonsense, so there's nothing to "hide". Maybe just ellipses?
{
    "encrypted_aes_key": "x3+......9zD",
    "aes_iv": "k2N......g==",
    "encrypted_value": "gM1......A2m",
    "type": "rsa_aes"
}

typically required when creating [source connectors](/api-reference/workflow/sources/overview) or
[destination connectors](/api-reference/workflow/destinations/overview) that work with specific third-party services.

Instead of programmatically sending a secret to Unstructured in plain text, which presents a security risk,
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
Instead of programmatically sending a secret to Unstructured in plain text, which presents a security risk,
There are inherent risks to sending plaintext secrets over a network. For stronger security, you may choose to use Unstructured's process for encrypting secrets locally as follows:

For now our stance is that this is more secure but it isn't backwards incompatible (except for GDrive). We'll also need to confirm that SecretReference is accepted by all connectors before pushing this approach too broadly.

Instead of programmatically sending a secret to Unstructured in plain text, which presents a security risk,
you must instead follow Unstructured's process for more securely sending the secret as follows:

1. Call Unstructured to get the Privacy Enhanced Mail (PEM) version of the public key for your Unstructured user account.
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
1. Call Unstructured to get the Privacy Enhanced Mail (PEM) version of the public key for your Unstructured user account.
1. Call Unstructured to get the RSA public key associated with your Unstructured user account.

The pem detail is probably too in the weeds. For the security minded folks who are doing this, the file format goes without saying. "RSA public key" is the right level of detail.

you must instead follow Unstructured's process for more securely sending the secret as follows:

1. Call Unstructured to get the Privacy Enhanced Mail (PEM) version of the public key for your Unstructured user account.
2. Use this PEM to encrypt your plain-text secret locally.
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
2. Use this PEM to encrypt your plain-text secret locally.
2. Use this key to encrypt your plaintext secret locally.


- [Google Drive source connector](/api-reference/workflow/sources/google-drive)

Unstructured plans to add this requirement to other source and destination connectors in the future.
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
Unstructured plans to add this requirement to other source and destination connectors in the future.
Unstructured plans to support this workflow with other source and destination connectors in the future.

import GetStartedSimpleAPIOnly from '/snippets/general-shared-text/get-started-simple-api-only.mdx';

While you can use a REST API client such as `curl` or Postman to complete most of the following steps, you can only use Python to
complete the step of encrypting the plain-text secret locally. Otherwise, both approaches are shown for the other steps.
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
complete the step of encrypting the plain-text secret locally. Otherwise, both approaches are shown for the other steps.
complete the step of encrypting the plaintext secret locally. Otherwise, both approaches are shown for the other steps.


import GetStartedSimpleAPIOnly from '/snippets/general-shared-text/get-started-simple-api-only.mdx';

While you can use a REST API client such as `curl` or Postman to complete most of the following steps, you can only use Python to
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
While you can use a REST API client such as `curl` or Postman to complete most of the following steps, you can only use Python to
While you can use a REST API client such as `curl` or Postman to complete most of the following steps, you can only use Python or another encryption language library to

- `UNSTRUCTURED_API_URL`, set to the Workflow Endpoint API URL for your Unstructured user account.
- `UNSTRUCTURED_API_KEY`, set to the API key for your Unstructured user account.

## Step 1: Get the PEM version of the public key
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
## Step 1: Get the PEM version of the public key
## Step 1: Get the RSA public key

</Accordion>
</AccordionGroup>

## Step 4: Use the registered secret's ID and encryption type
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
## Step 4: Use the registered secret's ID and encryption type
## Step 4: Use the registered secret's reference ID

@awalker4
Copy link
Contributor

awalker4 commented Jul 12, 2025

See this notebook for an updated flow once https://github.com/Unstructured-IO/platform-api/pull/544 is merged. The response from GET /users/secrets/encryption-certificate can be passed directly into the encrypt function that is now copied into the SDK. The result from this can likewise go straight to the store_secret function.

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