-
-
Notifications
You must be signed in to change notification settings - Fork 100
Enhanced Digest Authentication, JWT Authentication, Certificate Management & RFC Compliance #1470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mdaneri
wants to merge
89
commits into
Badgerati:develop
Choose a base branch
from
mdaneri:RFC-7616-Compliance
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ery Support - Added full support for RFC 7518 JWT algorithms: NONE, HS256, HS384, HS512, RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES384, ES512. - Introduced `-PrivateKey` parameter in `New-PodeAuthScheme` for RSA and ECDSA JWT signature verification. - Ensured JWT signature validation follows RFC 7518 standards. - Improved JWT validation for `exp` (expiration) and `nbf` (not before) claims. - Added support for passing Bearer tokens via query parameters (`-BearerLocation Query`) as per RFC 6750. - Updated `WWW-Authenticate` handling to correctly return headers on authentication failures for all authentication methods. - Ensured Pode authentication mechanisms align with industry security standards. - Updated documentation to reflect these enhancements.
remove Invoke-PodeJWTSign merge Invoke-PodeJWTSign in New-PodeJwtSignature
This was referenced Mar 2, 2025
Closed
Closed
Closed
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This pull request improves Pode’s authentication mechanisms by ensuring RFC compliance, fixing
WWW-Authenticateheaders on authentication failures, and improving request handling. Additionally, it enhances JWT authentication by supporting full RFC 7518 compliance and adds private key support for RSA and ECDSA algorithms. It also introduces support for bearer tokens in query parameters, following RFC 6750.Furthermore, this update adds new certificate management functions to enhance Pode's ability to generate, import, and manage certificates. These new functions allow better control over X.509 certificates, making it easier to secure endpoints, implement JWT authentication, and enforce certificate purposes.
Key Enhancements & Fixes
New Certificate Management Functions
New-PodeCertificateRequest, allowing users to generate Certificate Signing Requests (CSRs) for obtaining valid CA-signed certificates.New-PodeSelfSignedCertificate, which enables the creation of self-signed certificates with RSA or ECDSA keys for development and testing.Import-PodeCertificatefor importing X.509 certificates from PFX, PEM, or the Windows certificate store.Export-PodeCertificate, allowing certificates to be exported as PFX, PEM, or CER files with optional private key protection.Get-PodeCertificatePurpose, which retrieves the Enhanced Key Usage (EKU) attributes of a certificate, ensuring certificates are used correctly (e.g.,ServerAuth,ClientAuth,CodeSigning).ServerAuthfor HTTPS endpoints).JWT Authentication Updates (RFC 7518 Compliance)
NONE,HS256,HS384,HS512(HMAC)RS256,RS384,RS512(RSA)PS256,PS384,PS512(RSA-PSS)ES256,ES384,ES512(ECDSA)-PrivateKeyparameter inNew-PodeAuthSchemefor RSA and ECDSA verification.ConvertTo-PodeJwt -Authentication <Name>. Pode automatically applies the named scheme’s secret/certificate/algorithm to create a token. This keeps token generation and verification consistent.Update-PodeJwtConvertFrom-PodeJwtandUpdate-PodeJwtdon't need any parameters when used inside an authenticated routeBearer Token Support in Query Parameters (RFC 6750 Compliance)
Digest Authentication Updates (RFC 7616 Compliance)
MD5,SHA-1,SHA-256,SHA-384,SHA-512, andSHA-512/256.qop) enhancements: Implementsauth-intto include message integrity verification.WWW-Authenticateheader: Ensures theWWW-Authenticateheader is always returned on authentication failure, per RFC 7616.Fixes to
WWW-AuthenticateHeader for All Authentication MethodsThis update ensures that the
WWW-Authenticateheader is correctly returned when authentication fails, adhering to RFC standards:WWW-Authenticate: Basic realm="ExampleRealm"is included.WWW-Authenticate: Bearer error="invalid_token"when authentication fails.WWW-Authenticateconsistency on failed login attempts.WWW-Authenticate, even when authentication fails.New
$WebEvent.RawDataField$WebEvent.RawData, which captures the raw request body before parsing.auth-intin Digest Authentication and custom authentication mechanisms.Windows-Specific Limitations
auth-intis not supported natively.WWW-Authenticate.examples/Utilities/DigestClient.ps1for reference.Example Usage
Example: JWT Authentication with RSA
Example: Bearer Token in Query Parameter
Recommended Alternative:
Example: Digest Authentication with SHA-256 and
auth-intAdditional JWT Generation Example
Here’s a quick example of generating a signed JWT that aligns with an existing RSA-based scheme (i.e.,
ExampleJWT) usingConvertTo-PodeJwt -Authenticationin a login route:Example: Generating a CSR and Importing a Signed Certificate
Example: Creating a Self-Signed Certificate and Using It for HTTPS
Example: JWT Authentication with RSA
Example: Checking Certificate Purpose
Example: Exporting a Certificate as PFX
Testing
authandauth-intmodes.WWW-Authenticateis always present on authentication failure.$WebEvent.RawDatacorrectly captures raw request body content.References
PR Links:
Note on .NET 9 Issue and Reflection Workaround
This pull request includes a reflection-based workaround to access the RSA
KeySizefromSystem.Security.Cryptography.X509Certificates.RSACertificateExtensions.GetRSAPrivateKeyon Linux, due to an existing issue in .NET 9 where theKeySizeproperty is currently write-only.The issue has been reported to the .NET team here:
dotnet/runtime#112622
and Powershell team:
PowerShell/PowerShell#25038
Once the issue is resolved, this workaround can be revisited and potentially replaced with the official fix for improved maintainability and performance.