Skip to content

Update pre MFA workflow example#25

Open
chris-saunders-rocketlab wants to merge 2 commits into
kinde-starter-kits:mainfrom
chris-saunders-rocketlab:pre-mfa
Open

Update pre MFA workflow example#25
chris-saunders-rocketlab wants to merge 2 commits into
kinde-starter-kits:mainfrom
chris-saunders-rocketlab:pre-mfa

Conversation

@chris-saunders-rocketlab
Copy link
Copy Markdown

@chris-saunders-rocketlab chris-saunders-rocketlab commented Feb 10, 2026

Add missing import;
Define MFAPolicy constant as MFAPolicy and MFAEnforcementPolicy are differing string unions;
Add kinde.mfa binding;

Explain your changes

Simple update primarily to add the kinde.mfa binding which is required to use setEnforcementPolicy.

Also adds a missing import (createKindeAPI) and defines a constant for MFAPolicy since the MFAPolicy and MFAEnforcementPolicy types from the infrastructure library are actually differing string unions which will save time for anyone not too familiar with typescript.

Happy to add a PR in infrastructure for the last one but I figured this would do for an example workflow.

Checklist

Summary by CodeRabbit

  • New Features
    • Enhanced MFA policy management with a new configurable "kinde.mfa" setting for administrators and improved policy decision handling that preserves existing grace-period behavior.

Add missing import;
Define MFAPolicy constant as MFAPolicy and MFAEnforcementPolicy are differing string unions;
Add kinde.mfa binding;
@chris-saunders-rocketlab chris-saunders-rocketlab requested a review from a team as a code owner February 10, 2026 03:15
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Adds an MFAPolicy mapping for standardized MFA enforcement values, imports createKindeAPI from @kinde/infrastructure, and registers a new public binding "kinde.mfa" in workflowSettings. MFA policy decisions now reference the mapping instead of string literals.

Changes

Cohort / File(s) Summary
MFA policy, import, and binding
preMFA/gracePeriodWorkflow.ts
Introduce MFAPolicy mapping (Required -> "required", Skip -> "skip"), add createKindeAPI import, and add public binding "kinde.mfa" to workflowSettings. MFA logic now uses the mapping for policy selection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇 I hopped through code with a twitch and a grin,
Mapped MFA choices so clarity could win,
A new binding placed, tidy and spry,
Policies aligned beneath the sky,
Graceful hops forward—ready to fly! ✨

🚥 Pre-merge checks | ✅ 3
✅ 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 accurately describes the main change in the pull request - updating the pre-MFA workflow example with necessary imports, type mappings, and bindings.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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
Copy Markdown

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
preMFA/gracePeriodWorkflow.ts (1)

51-55: ⚠️ Potential issue | 🟡 Minor

MFA_GRACE_PERIOD_IN_MS silently becomes NaN when the env var is missing.

If MFA_GRACE_PERIOD_IN_HOURS is not set, getEnvironmentVariable returns undefined, and Number(undefined) is NaN. The grace-period comparison then always evaluates to false, so MFA is always required — a safe default, but this fails silently and could confuse operators debugging why the grace period "isn't working."

Consider adding an early guard with a log to surface the misconfiguration.

🛡️ Proposed guard
- const MFA_GRACE_PERIOD_IN_MS =
-   Number(getEnvironmentVariable("MFA_GRACE_PERIOD_IN_HOURS")?.value) *
-   60 *
-   60 *
-   1000;
+ const gracePeriodHours = Number(
+   getEnvironmentVariable("MFA_GRACE_PERIOD_IN_HOURS")?.value
+ );
+
+ if (isNaN(gracePeriodHours)) {
+   console.log(
+     "MFA_GRACE_PERIOD_IN_HOURS is not set or invalid — MFA will always be required"
+   );
+   setEnforcementPolicy("required");
+   return;
+ }
+
+ const MFA_GRACE_PERIOD_IN_MS = gracePeriodHours * 60 * 60 * 1000;
🧹 Nitpick comments (1)
preMFA/gracePeriodWorkflow.ts (1)

11-14: Tighten the type of MFAPolicy to preserve compile-time key safety.

The {[key: string]: MFAEnforcementPolicy} index signature means MFAPolicy.Typo silently evaluates to undefined at runtime without a TypeScript error. Using as const (with a satisfies check if you want the MFAEnforcementPolicy constraint) retains both literal types and key safety.

♻️ Suggested tighter typing
-const MFAPolicy: {[key: string]: MFAEnforcementPolicy} = {
-  Required: "required",
-  Skip: "skip"
-}
+const MFAPolicy = {
+  Required: "required",
+  Skip: "skip",
+} as const satisfies Record<string, MFAEnforcementPolicy>;

Use as const to tighten type for MFAPolicy
@chris-saunders-rocketlab chris-saunders-rocketlab changed the title pre-mfa Update pre MFA workflow example Feb 10, 2026
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