Let ExecuteActionsEmail set a custom action-token lifespan - #103
Merged
github-actions[bot] merged 1 commit intoSep 14, 2026
Merged
github-actions[bot] merged 1 commit into
github-actions[bot] merged 1 commit into
Conversation
…espan Helper.ExecuteActionsEmail never set gocloak.ExecuteActionsEmail's Lifespan field, so every caller got Keycloak's own 12-hour default for admin-triggered action tokens -- far longer than intended for something like a password-reset link, and inconsistent with the much shorter lifespan Keycloak's self-service action-token flow already defaults to. Add a lifespanSeconds parameter, threaded into gocloak's Lifespan field (already supported server-side, just never set by this wrapper) only when it's genuinely positive. gocloak's Lifespan is *int with `omitempty`, which only checks pointer-nilness, not the pointee's value -- a naive `&lifespanSeconds` would send a literal lifespan=0 for a zero/uninitialized argument, minting an already-expired action token with no error surfaced anywhere. Guarding on lifespanSeconds > 0 instead leaves the field unset (nil) for that case, falling back to Keycloak's own realm default -- the same behavior this method had before Lifespan existed at all. Existing callers must now pass an explicit value -- there's exactly one today (cubecmp's admin-triggered reset-password routes, paired change in that repo). Signed-off-by: Shawn Hsu <shawn.hsu@bigstack.co> Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Eandalf-Bigstack
approved these changes
Sep 14, 2026
github-actions
Bot
deleted the
shawn.hsu/issue-1086/execute-actions-email-lifespan
branch
September 14, 2026 06:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind feature
What this PR does / why we need it
Helper.ExecuteActionsEmailnever setgocloak.ExecuteActionsEmail'sLifespanfield, so every caller got Keycloak's own 12-hour default for admin-triggered action tokens — far longer than intended for something like a password-reset link, and inconsistent with the much shorter lifespan Keycloak's self-service action-token flow already defaults to.Adds a
lifespanSecondsparameter, threaded into gocloak'sLifespanfield (already supported server-side, just never set by this wrapper) — but only when it's genuinely positive.gocloak.ExecuteActionsEmail.Lifespanis*intwithomitempty, which only checks pointer-nilness, not the pointee's value — a naive&lifespanSecondswould send a literallifespan=0for a zero/uninitialized argument, minting an already-expired action token with no error surfaced anywhere in the call chain. Guarding onlifespanSeconds > 0instead leaves the field unset (nil) for that case, falling back to Keycloak's own realm default — the same behavior this method had beforeLifespanexisted at all.This is a breaking signature change to an exported method (
ExecuteActionsEmail(realm, userID string, actions []string) error→ExecuteActionsEmail(realm, userID string, actions []string, lifespanSeconds int) error). The one current caller (cubecmp's admin-triggered reset-password routes) is updated in a companion PR, pinned to this branch's commit — see cubecmp issue #1086.Which issue(s) this PR fixes
Refs bigstack-oss/cubecmp#1086
Special notes for your reviewer
Additional documentation