Skip to content

stages/prompt: add ability to set separate labels and values for choices - #16693

Merged
BeryJu merged 19 commits into
goauthentik:mainfrom
ErikAhlund:feature/prompt-object-choices
Oct 15, 2025
Merged

BeryJu merged 19 commits into
goauthentik:mainfrom
ErikAhlund:feature/prompt-object-choices

Conversation

@ErikAhlund

@ErikAhlund ErikAhlund commented Sep 10, 2025 •

Copy link
Copy Markdown
Contributor

Details

Fixes #5197

This PR adds support for custom label and values in the select and radio components of the PromptStage by modifying the select object to accept an array of objects with value and label properties, while maintaining backward compatibility with string arrays. Key changes include:

Updated PromptStage.ts to handle both array of strings and array of { value: string, label: string } for select and radio inputs.

Added unit tests in authentik/stages/prompt/tests.py to verify new functionality and edge cases. (Further tests might be needed)

Updated relevant documentation to reflect the new option format in website/docs/add-secure-apps/flows-stages/stages/prompt/index.md

Please let me know if additional changes or tests are needed!


Checklist

  • [ x ] Local tests pass (ak test authentik/)
  • [ x ] The code has been formatted (make lint-fix)

If an API change has been made

  • [ x ] The API schema has been updated (make gen-build)

If changes to the frontend have been made

  • [ x ] The code has been formatted (make web)

If applicable

  • [ x ] The documentation has been updated
  • [ x ] The documentation has been formatted (make docs)

Value and label are set turned to a string.
This will make choices into a Array<{ [key: string]: any; }> | null which at some point it should be a defined interface.
Label and Value are used for Dropdown and RadioButtonGroup. Strings are still accepted.
Also fixed wrong choice example in previous docs changes
Choice can of course be anything, we shouldn't assume it's string or dict
Same as before, choice can be anything. We check if it's explicitely a dict
@ErikAhlund
ErikAhlund requested review from a team as code owners September 10, 2025 12:52
@netlify

netlify Bot commented Sep 10, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit d003ffe
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/68ef9df7f8c26c00083c911b
😎 Deploy Preview https://deploy-preview-16693--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Sep 10, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit d003ffe
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/68ef9df71a3f4e0008ddcbb3
😎 Deploy Preview https://deploy-preview-16693--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Sep 10, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook canceled.

Name Link
🔨 Latest commit d003ffe
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/68ef9df7bdc2b2000825feb1

@ErikAhlund ErikAhlund changed the title stages/prompt: add value/label to choices web/stages/prompt: use value/label to choices website/docs: add config info for choices stages/prompt: add value/label to choices website/docs: add info for dict choices Sep 10, 2025
Comment thread authentik/stages/prompt/stage.py Resolved
ErikAhlund and others added 4 commits September 19, 2025 14:28
Co-authored-by: macmoritz <[email protected]>
Signed-off-by: Erik Ahlund <[email protected]>
choices are now a list of PromptChoiceSerializer instead of a generic DictField.
The PromptChallenge also forces the use of value/label object.
The front end can now safely use choices as an array of PromptChoice instead of it being either a string or an object.
@codecov

codecov Bot commented Sep 23, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.87%. Comparing base (bd0944f) to head (d003ffe).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
authentik/stages/prompt/stage.py 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16693      +/-   ##
==========================================
- Coverage   92.98%   92.87%   -0.11%     
==========================================
  Files         868      868              
  Lines       47833    47863      +30     
==========================================
- Hits        44476    44455      -21     
- Misses       3357     3408      +51     
Flag Coverage Δ
e2e 45.22% <15.15%> (-0.12%) ⬇️
integration 23.10% <15.15%> (-0.08%) ⬇️
unit 91.06% <93.93%> (-0.01%) ⬇️
unit-migrate 91.11% <93.93%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tanberry tanberry added the status/reviewing thanks for opening, we're taking a look label Sep 24, 2025
@BeryJu BeryJu self-assigned this Oct 7, 2025
@ErikAhlund

Copy link
Copy Markdown
Contributor Author

@BeryJu @tanberry Is there anything I can do to help this PR move along? It's already been a month since I created it, am I missing something?

@BeryJu BeryJu changed the title stages/prompt: add value/label to choices website/docs: add info for dict choices stages/prompt: add ability to set separate labels and values for choices Oct 15, 2025
@BeryJu BeryJu added area:frontend Features or issues related to the browser, TypeScript, Node.js, etc area:backend area:docs Features or issues related to Docusaurus and removed status/reviewing thanks for opening, we're taking a look labels Oct 15, 2025

@dominic-r dominic-r left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm for docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend area:docs Features or issues related to Docusaurus area:frontend Features or issues related to the browser, TypeScript, Node.js, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stages/prompt: Add custom value to RadioButtonGroup and Dropdown

6 participants