Skip to content

Conversation

clairekinde11
Copy link
Collaborator

@clairekinde11 clairekinde11 commented Sep 28, 2025

New code snippet and decrypt section for workflows.

Summary by CodeRabbit

  • Documentation
    • Added a new "Workflow encryption key" guide explaining concepts, setup, usage flow, key lifecycle (add/update/activate/deactivate/delete), and decryption guidance with a concrete example and configuration notes.
    • Removed the prior "Workflow encryption key" page and consolidated its content into the new, clearer guide to reduce duplication and improve accuracy.

clairekinde11 and others added 7 commits September 11, 2025 16:30
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Added comprehensive WorkflowPayloadDecryptor class
- Included AES-GCM decryption implementation
- Added ASP.NET Core controller example
- Included configuration management examples
- Added proper error handling and data models
New topic - accidentally deleted
Copy link
Contributor

coderabbitai bot commented Sep 28, 2025

Warning

Rate limit exceeded

@clairekinde11 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 29 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 30e196e and 2432a1b.

📒 Files selected for processing (1)
  • src/content/docs/workflows/bindings/secure-fetch-binding.mdx (1 hunks)

Walkthrough

Replaces the previous "Workflow encryption key" documentation with a new page encrypt-decrypt-workflows.mdx that describes workflow encryption keys, secureFetch usage, key management steps, and includes a .NET AES‑GCM decryption example and related UI guidance.

Changes

Cohort / File(s) Summary of Changes
Added: New docs page
src/content/docs/workflows/manage-workflows/encrypt-decrypt-workflows.mdx
New documentation page introducing workflow encryption keys, usage flow with secureFetch, steps to add/deploy/manage keys, and a concrete .NET AES‑GCM decryption example (Base64 payload format: nonce
Removed: Old docs page
src/content/docs/workflows/manage-workflows/workflow-encryption-key.mdx
Deleted the previous "workflow-encryption-key.mdx" page containing older guidance, front matter metadata, and step‑by‑step UI instructions for key operations.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as Workflow Client
  participant Kinde as Kinde Workflows
  participant Service as Backend Service

  rect rgb(236,248,255)
    Note over Client,Kinde: Client uses secureFetch (encryption enabled)
    Client->>Kinde: secureFetch(payload)
    Kinde->>Kinde: Encrypt body (AES‑GCM: nonce|tag|ciphertext) → Base64
    Kinde->>Service: POST encrypted payload
  end

  rect rgb(240,255,240)
    Service->>Service: Decode Base64, extract nonce/tag/ciphertext, decrypt with active key
    alt Decryption succeeds
      Service-->>Kinde: 2xx response
      Kinde-->>Client: Success
    else Decryption fails
      Service-->>Kinde: 4xx/5xx error
      Kinde-->>Client: Error
    end
  end

  Note over Kinde: Keys can be added/updated/activated/deactivated/deleted via Workflows UI
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • marcosmartini

Poem

I twitch my ears at keys anew,
Encrypt and hop where bytes go through.
Nonce and tag, a Base64 song,
AES‑GCM hums all night long.
I nibble bugs and then I sigh—workflows safe, carrot pie.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “Fix/decryption section for workflows” clearly refers to the primary change of updating the decryption section in the workflow documentation by adding a new code snippet and guidance, so it is related to the changeset; however, the unconventional slash and slightly imprecise phrasing reduce clarity regarding the exact scope of the update.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

cloudflare-workers-and-pages bot commented Sep 28, 2025

Deploying kinde-docs-preview with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2432a1b
Status: ✅  Deploy successful!
Preview URL: https://9dfea226.kinde-docs-preview.pages.dev
Branch Preview URL: https://fix-decryption-section-for-w.kinde-docs-preview.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d88d65d and c0da735.

📒 Files selected for processing (2)
  • src/content/docs/workflows/manage-workflows/encrypt-decrypt-workflows.mdx (1 hunks)
  • src/content/docs/workflows/manage-workflows/workflow-encryption-key.mdx (0 hunks)
💤 Files with no reviewable changes (1)
  • src/content/docs/workflows/manage-workflows/workflow-encryption-key.mdx

Comment on lines +67 to +172
using System;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;

public class WorkflowPayloadDecryptor
{
private readonly byte[] _encryptionKey;

public WorkflowPayloadDecryptor(string base64EncryptionKey)
{
_encryptionKey = Convert.FromBase64String(base64EncryptionKey);
}

public string DecryptPayload(string encryptedPayload)
{
try
{
// Step 1: Base64 decode the incoming payload
byte[] encryptedData = Convert.FromBase64String(encryptedPayload);

// Step 2: Parse the payload structure
// The payload contains: nonce (12 bytes) + tag (16 bytes) + ciphertext
const int nonceLength = 12;
const int tagLength = 16;

if (encryptedData.Length < nonceLength + tagLength)
{
throw new ArgumentException("Invalid encrypted payload structure");
}

// Extract components
byte[] nonce = new byte[nonceLength];
byte[] tag = new byte[tagLength];
byte[] ciphertext = new byte[encryptedData.Length - nonceLength - tagLength];

Array.Copy(encryptedData, 0, nonce, 0, nonceLength);
Array.Copy(encryptedData, nonceLength, tag, 0, tagLength);
Array.Copy(encryptedData, nonceLength + tagLength, ciphertext, 0, ciphertext.Length);

// Step 3: Decrypt using AES-GCM
using (var aesGcm = new AesGcm(_encryptionKey))
{
byte[] decryptedBytes = new byte[ciphertext.Length];
aesGcm.Decrypt(nonce, ciphertext, tag, decryptedBytes);

// Convert decrypted bytes to string
return Encoding.UTF8.GetString(decryptedBytes);
}
}
catch (Exception ex)
{
throw new InvalidOperationException("Failed to decrypt workflow payload", ex);
}
}
}

// Example usage in an ASP.NET Core controller
[ApiController]
[Route("api/[controller]")]
public class WorkflowController : ControllerBase
{
private readonly WorkflowPayloadDecryptor _decryptor;

public WorkflowController(IConfiguration configuration)
{
// Get the encryption key from configuration
string encryptionKey = configuration["KindeWorkflowEncryptionKey"];
_decryptor = new WorkflowPayloadDecryptor(encryptionKey);
}

[HttpPost("webhook")]
public async Task<IActionResult> HandleWorkflowWebhook()
{
try
{
// Read the encrypted payload from the request body
using var reader = new StreamReader(Request.Body);
string encryptedPayload = await reader.ReadToEndAsync();

// Decrypt the payload
string decryptedJson = _decryptor.DecryptPayload(encryptedPayload);

// Parse the decrypted JSON
var workflowData = JsonSerializer.Deserialize<WorkflowData>(decryptedJson);

// Process the decrypted data
// ... your business logic here ...

return Ok(new { message = "Workflow payload processed successfully" });
}
catch (Exception ex)
{
return BadRequest(new { error = "Failed to process workflow payload", details = ex.Message });
}
}
}

// Example data model for the decrypted payload
public class WorkflowData
{
public string UserId { get; set; }
public string EventType { get; set; }
public Dictionary<string, object> Data { get; set; }
}
```
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add the missing using directives so the sample compiles.

The C# snippet references StreamReader, ControllerBase, IConfiguration, Task<IActionResult>, and Dictionary<string, object>, but the code block only imports core namespaces. Without the matching using statements (System.IO, System.Collections.Generic, System.Threading.Tasks, Microsoft.AspNetCore.Mvc, Microsoft.Extensions.Configuration), readers copying the sample will hit compile errors. Please prepend the snippet with the full set of namespaces (or annotate them inline) so the example builds cleanly.

🤖 Prompt for AI Agents
In src/content/docs/workflows/manage-workflows/encrypt-decrypt-workflows.mdx
around lines 67 to 172, the C# sample is missing required using directives which
cause compile errors for StreamReader, Dictionary, Task<IActionResult>,
ControllerBase and IConfiguration; prepend the file’s code block with the
following usings: System.IO, System.Collections.Generic, System.Threading.Tasks,
Microsoft.AspNetCore.Mvc, and Microsoft.Extensions.Configuration (keeping the
existing System, System.Security.Cryptography, System.Text, and System.Text.Json
lines) so the sample compiles cleanly.

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.

1 participant