Skip to content

web/elements: show certs that can't be selected as grayed out - #24770

Merged
PeshekDotDev merged 4 commits into
mainfrom
show-unallowed-certs
Sep 10, 2026
Merged

PeshekDotDev merged 4 commits into
mainfrom
show-unallowed-certs

Conversation

@PeshekDotDev

Copy link
Copy Markdown
Contributor

Details

What does this PR change?

Why is this change needed?

How was this tested?

Linked issues

Closes #24738


Checklist

  • The project has been linted, built, and tested (make all)
  • The documentation has been updated and formatted (make docs)

@PeshekDotDev PeshekDotDev self-assigned this Aug 4, 2026
@PeshekDotDev
PeshekDotDev requested a review from a team as a code owner August 4, 2026 22:56
@netlify

netlify Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit a2e1dd7
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6aa2651085ce3500088179bb
😎 Deploy Preview https://deploy-preview-24770--authentik-storybook.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 Aug 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit a2e1dd7
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6aa26510cc0e480008e09e4a
😎 Deploy Preview https://deploy-preview-24770--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 Aug 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit a2e1dd7
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6aa265108bd3440008f92050
😎 Deploy Preview https://deploy-preview-24770--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.

@codecov

codecov Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.86%. Comparing base (06d90d0) to head (a2e1dd7).
⚠️ Report is 401 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24770      +/-   ##
==========================================
+ Coverage   91.49%   91.86%   +0.37%     
==========================================
  Files        1150     1169      +19     
  Lines       72626    75451    +2825     
  Branches     3875     4054     +179     
==========================================
+ Hits        66446    69311    +2865     
+ Misses       6145     6098      -47     
- Partials       35       42       +7     
Flag Coverage Δ
conformance 33.75% <ø> (-0.94%) ⬇️
e2e 38.44% <ø> (-0.92%) ⬇️
integration 30.46% <ø> (-0.80%) ⬇️
rust 42.92% <ø> (+4.03%) ⬆️
unit 93.41% <ø> (+1.25%) ⬆️
unit-migrate 93.44% <ø> (+0.28%) ⬆️

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

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

@PeshekDotDev

Copy link
Copy Markdown
Contributor Author
Screenshot 2026-08-04 at 6 08 02 PM

@github-actions

github-actions Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-a2e1dd72c8cb355ac18a4434ce7f778089efdb63
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-a2e1dd72c8cb355ac18a4434ce7f778089efdb63

Afterwards, run the upgrade commands from the latest release notes.

@PeshekDotDev PeshekDotDev added the backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 label Aug 5, 2026
optionDisabled = (item: CertificateKeyPair): boolean => this.#unusableReason(item) !== null;

renderDescription = (item: CertificateKeyPair): SlottedTemplateResult =>
this.#unusableReason(item) ?? nothing;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Line 368 of SearchSelect.ts shows that renderDescription() should return a null, rather than nothing. nothing isn't nullish, so renderMenuItems will still render the description block, it'll just be empty. That takes up space on the page and makes scrolling through the valid options take longer. Return null here for consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Always love situations like that lol. Fixed

const unusable: CertificateKeyPair[] = [];

for (const item of results) {
(this.#unusableReason(item) ? unusable : usable).push(item);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CryptoAPI is paginated, and clamps to 20 by default. SearchSelect can only handle a single API page of selectable items, which is its own unsolved problem. If you have 20 verification certificates and three signing ones, it's possible you'll get a SearchSelect of 20 unusable items and not be able to pick a certificate you want.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made a filtered call and then a second call after that fills up the rest if usable is under 20. Let me know what you think

# Conflicts:
#	web/src/elements/forms/SearchSelect/ak-search-select-view.ts

@kensternberg-authentik kensternberg-authentik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

On the server, there is a difference between key_data__exact="" (this certificate has no key) and key_data__exact=None, the latter of which is a rare case where the database has been able to correlate the algorithm with its known set. While rare, this seems wrong; maybe you need a third error type for this distinction?

return msg("This certificate is not a valid option here: unsupported key type.", {
id: "crypto.certificate-search.unsupported-key-type.description",
});
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I'm reading this right, this re-implements the code in crypto/api.py:CertificateKeyPairFilter. I don't suppose there's a way to move all this logic entirely into the server and deliver a richer data set from cryptoCertificatekeypairsList()?

}
if (this.allowedKeyTypes?.length) {
args.keyType = this.allowedKeyTypes;
restrictions.keyType = this.allowedKeyTypes;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CryptoAPI is paginated, and clamps to 20 by default. SearchSelect can only handle a single API page of selectable items, which is its own unsolved problem. If you have 20 verification certificates and three signing ones, it's possible you'll get a SearchSelect of 20 unusable items and not be able to pick a certificate you want.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As far as I can tell, this issue has not been addressed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It has been. I verified twice in the browser with manual testing


// The API only returns one page of results, so ask it for the usable keypairs directly.
// Otherwise, a page full of unusable ones could push the usable ones out of the list.
const [{ results: usable }, { results: all }] = await Promise.all([

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Promise.all is a code smell these days. If one of these requests succeeds and the other fails (unlikely, I know, but weirder things have happened), this will crash silently, leaving the page in a weird state. Consider using AllSettled and unpacking the result by hand instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This might be a good place to put a { results: unusable } with the adjustments wanted on line 129 instead. I know enough about DRF to know that you can invert the filter and provide extra fields in the serializer (like your "reason" fields), although I don't know how OpenAPI feels about that ... the last time I tried things got weird.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I altered this to use promise.allSettled

role="option"
value=${value}
class="ak-select-item"
aria-disabled=${ifDefined(disabled || undefined)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Put the aria-disabled expression on the button in addition to having it here. The button gets focus, not the list item. Having it here tells the listener what to skip; having it on the button will let someone using accessibility aids hear that the object is disabled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

currentElement.classList.add("ak-highlight-item");
// This is currently a radio emulation; "selected" is true here.
// If this were a checkbox emulation (i.e. multi), "checked" would be appropriate.
currentElement.setAttribute("aria-selected", "true");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't check if the item is disabled. Disabled rows can still be accessed via the keyboard (which is good, because you want a disabled user to be able to access the row and see/hear the reason for why it's disabled), but now the row can be selected via the keyboard. Don't let the code set aria-selected when the certificate isn't selectable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider moving this outside and below the button object, then linking it to the button by aria-describedby.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@github-project-automation github-project-automation Bot moved this from Todo to In Progress in authentik Core Sep 3, 2026
@PeshekDotDev
PeshekDotDev merged commit 75b8cc6 into main Sep 10, 2026
144 checks passed
@PeshekDotDev
PeshekDotDev deleted the show-unallowed-certs branch September 10, 2026 17:35
@github-project-automation github-project-automation Bot moved this from In Progress to Done in authentik Core Sep 10, 2026
@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.8 created: #26027

@mo74m3ed mo74m3ed left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Labels

backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Show filtered certificates as grayed out instead of not showing

3 participants