Skip to content

crypto: Add key type safeguards - #24014

Merged
PeshekDotDev merged 16 commits into
mainfrom
crypto/key-type-safeguards
Sep 10, 2026
Merged

PeshekDotDev merged 16 commits into
mainfrom
crypto/key-type-safeguards

Conversation

@PeshekDotDev

@PeshekDotDev PeshekDotDev commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

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

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

@netlify

netlify Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit bb82a17
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6aa258755cb82a0008c46788
😎 Deploy Preview https://deploy-preview-24014--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 Jul 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit bb82a17
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6aa258754b222c00085ab787
😎 Deploy Preview https://deploy-preview-24014--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 Jul 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit bb82a17
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6aa258754b222c00085ab785
😎 Deploy Preview https://deploy-preview-24014--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 Jul 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.82540% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.87%. Comparing base (e5abbfc) to head (4a1fcaf).
⚠️ Report is 72 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
authentik/crypto/validators.py 91.66% 2 Missing ⚠️
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              
Flag Coverage Δ
conformance 33.76% <55.55%> (+<0.01%) ⬆️
e2e 38.43% <44.44%> (-0.01%) ⬇️
integration 30.46% <44.44%> (-0.01%) ⬇️
rust 42.92% <ø> (ø)
unit 93.43% <96.82%> (+0.01%) ⬆️
unit-migrate 93.45% <96.82%> (+0.01%) ⬆️

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.

@github-actions

github-actions Bot commented Jul 14, 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-4a1fcaf2c13431c574b3f25352fc487635b9665b
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-4a1fcaf2c13431c574b3f25352fc487635b9665b

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

@PeshekDotDev
PeshekDotDev marked this pull request as ready for review July 14, 2026 12:37
@PeshekDotDev
PeshekDotDev requested review from a team as code owners July 14, 2026 12:37
Comment thread authentik/crypto/validators.py Resolved
Comment thread authentik/providers/ldap/api.py Resolved
@BeryJu BeryJu changed the title Crypto: Add key type safegaurds crypto: Add key type safegaurds Jul 14, 2026
Comment thread website/docs/sys-mgmt/certificates.md Resolved
Co-authored-by: Dewi Roberts <[email protected]>
Signed-off-by: Connor Peshek <[email protected]>
@PeshekDotDev PeshekDotDev changed the title crypto: Add key type safegaurds crypto: Add key type safeguards Jul 14, 2026

@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.

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 = [

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 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?

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.

I dont think easily

KeyTypeEnum.Ec,
KeyTypeEnum.Ed25519,
KeyTypeEnum.Ed448,
];

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.

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.)

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 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];

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.

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.

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.

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}

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.

Lotta shotgun surgery going on here. Feels like there's a missing idiom. Not sure how to deal with it, but it bugs me.

@PeshekDotDev PeshekDotDev added the backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 label Aug 5, 2026
self.user = create_test_admin_user()
self.client.force_login(self.user)

def set_signing_key(self, cert: CertificateKeyPair):

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.

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")

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 :D

@BeryJu BeryJu 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 backend wise with 1 nit

@github-project-automation github-project-automation Bot moved this from Todo to In Progress in authentik Core Sep 10, 2026
@PeshekDotDev
PeshekDotDev enabled auto-merge (squash) September 10, 2026 17:35
@PeshekDotDev PeshekDotDev removed the backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 label Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Playwright e2e — ❌ Failed

Result Count
✅ Passed 38
❌ Failed 4
⚠️ Flaky 2
⏭️ Skipped 4

Workflow run · HTML report hosting is gated off until the authentik-playwright-artifacts S3 bucket is provisioned (vars.PLAYWRIGHT_S3_ENABLED). Until then, download the playwright-report artifact from the run page.

@PeshekDotDev
PeshekDotDev merged commit e8ef4c0 into main Sep 10, 2026
143 of 144 checks passed
@PeshekDotDev
PeshekDotDev deleted the crypto/key-type-safeguards branch September 10, 2026 17:49
@github-project-automation github-project-automation Bot moved this from In Progress to Done in authentik Core Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants