Repository navigation
web/elements: show certs that can't be selected as grayed out - #24770
Conversation
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your 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)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your 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-a2e1dd72c8cb355ac18a4434ce7f778089efdb63Afterwards, run the upgrade commands from the latest release notes. |
| optionDisabled = (item: CertificateKeyPair): boolean => this.#unusableReason(item) !== null; | ||
|
|
||
| renderDescription = (item: CertificateKeyPair): SlottedTemplateResult => | ||
| this.#unusableReason(item) ?? nothing; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Always love situations like that lol. Fixed
| const unusable: CertificateKeyPair[] = []; | ||
|
|
||
| for (const item of results) { | ||
| (this.#unusableReason(item) ? unusable : usable).push(item); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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", | ||
| }); | ||
| } |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
As far as I can tell, this issue has not been addressed.
There was a problem hiding this comment.
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([ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I altered this to use promise.allSettled
| role="option" | ||
| value=${value} | ||
| class="ak-select-item" | ||
| aria-disabled=${ifDefined(disabled || undefined)} |
There was a problem hiding this comment.
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.
| 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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Consider moving this outside and below the button object, then linking it to the button by aria-describedby.
|
🍒 Cherry-pick to |

Details
What does this PR change?
Why is this change needed?
How was this tested?
Linked issues
Closes #24738
Checklist
make all)make docs)