Repository navigation
crypto: Add key type safeguards - #24014
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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24014 +/- ##
==========================================
+ Coverage 91.86% 91.87% +0.01%
==========================================
Files 1169 1170 +1
Lines 75451 75514 +63
Branches 4054 4054
==========================================
+ Hits 69310 69382 +72
+ Misses 6099 6090 -9
Partials 42 42
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-4a1fcaf2c13431c574b3f25352fc487635b9665b
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-4a1fcaf2c13431c574b3f25352fc487635b9665bAfterwards, run the upgrade commands from the latest release notes. |
Co-authored-by: Dewi Roberts <[email protected]> Signed-off-by: Connor Peshek <[email protected]>
kensternberg-authentik
left a comment
There was a problem hiding this comment.
I have misgivings:
- there's a big UX problem is hiding stuff the user might generate or upload without telling them why
- there's duplication-of-knowledge across the client and server, creating a maintenance headache
- there's something subtly wrong with how the filters are handled in the various drop-downs, but I can't put my finger on it. It's a DX problem, not a UX or functional one.
The "uploaded a weird key and now it's missing from an existing provider's form" thing is trying to compensate for a very silly user error; it's not even worth addressing, really, but it's just something that occurred to me.
The underlying functionality is solid. It does what it says. We can address these issues in a future PR, if we think we should. None of them block merging.
| */ | ||
|
|
||
| /** Signing a JWT. Bounded by the algorithms `JWTAlgorithms.from_private_key` can map to. */ | ||
| export const JWTSigningKeyTypes = [ |
There was a problem hiding this comment.
This information is also encoded in ./authentik/crypto/validators.py, creating a "two sources of truth" problem. Could JWTSigningKeyTypes be made available via the API, so that we have a single source of truth?
| KeyTypeEnum.Ec, | ||
| KeyTypeEnum.Ed25519, | ||
| KeyTypeEnum.Ed448, | ||
| ]; |
There was a problem hiding this comment.
Does this change keys that the user could have previously selected? Like, does it broaden the list of filtered keys? (I'm thinking, if someone had a provider with a weird key that's now not in the "allowed" list, they won't be able to edit that provider because now their chosen key won't show up in the drop-down field; it's been filtered out.)
There was a problem hiding this comment.
It could be possible that before someone selected a wrong cert, and would have been able to save it. but they most likely would have gotten a runtime error using one of the invalid certs. so this prevents them from ever selecting it. If they had selected a wrong cert before, they'd just select a new one now. Authentik self-signed cert always shows as a valid option because its a correct key type and has a private key, although it shouldn't be selected for something like encrypting messages to an SP. but it could be used to clear weird state and would be unlikely to be a problem in production
| ]; | ||
|
|
||
| /** Encrypting a JWT. `RSA-OAEP-256` is hardcoded, and has no non-RSA counterpart. */ | ||
| export const JWEEncryptionKeyTypes = [KeyTypeEnum.Rsa]; |
There was a problem hiding this comment.
So, the thing that bugs me here is that, now that we've got these distinctions, you've created mysteries. The user might upload an Ed448 key, then go look for it in OAuth2's Advanced Options section and, mysteriously, it isn't there, because we silently filter it out. This patch creates a situation where user-provided materials can just not show up where an naive user might expect them to, and without explanation as to why.
There was a problem hiding this comment.
This should be fixed when PR #24770 gets merged
| label=${msg("Signing Key")} | ||
| placeholder=${msg("Select a signing key...")} | ||
| certificate=${ifPresent(provider.signingKey)} | ||
| .allowedKeyTypes=${JWTSigningKeyTypes} |
There was a problem hiding this comment.
Lotta shotgun surgery going on here. Feels like there's a missing idiom. Not sure how to deal with it, but it bugs me.
| self.user = create_test_admin_user() | ||
| self.client.force_login(self.user) | ||
|
|
||
| def set_signing_key(self, cert: CertificateKeyPair): |
There was a problem hiding this comment.
I know the fixture cert is valid for a long time, but the more correct way would be from freezegun import freeze_time @freeze_time("2022-10-14T14:15:00Z")
Playwright e2e — ❌ Failed
Workflow run · HTML report hosting is gated off until the |
Details
What does this PR change?
Although there was some safeguarding on the front-end, this PR adds back-end safeguards as well as more front-end safeguards for selecting unsupported certificate types
Many certificates are limited on their use based on the libraries that we are using. Go has decided that they will not support ed448 for TLS, so we would need to use something besides the crypto/tls library. Our xml library does not support ed certs, so we would need to change that. Just want to log that we could support ed certificates in more locations, but there isn't much of a reason to due to PQ certs coming
Why is this change needed?
This helps prepare for when we add post quantum certificates, preventing people from selecting them as an option before they are supported, even though we will allow for generating, uploading, and storing them
Preferably PR #24013 is merged before this so that the filtering for ed448 is accurate
How was this tested?
Generating rsa, ecdsa, ed448, ed25519, and trying to select on the front-end (unusable certs properly filtered)
Generating certs and attempting to post to back-end (properly prevented)
Linked issues
Checklist
make all)make docs)