Open
Conversation
11e4fe1 to
080b29d
Compare
Contributor
Author
|
IMPORTANT NOTE |
- Add DPoPProofGenerator class for RFC 9449 DPoP proof generation - URL parsing strips query/fragment from htu claim - JWK export contains only public components (kty, n, e) - Key rotation with active request tracking - Implement RSA 2048-bit key generation and management - Add access token hash computation (SHA-256 + base64url) - Add nonce storage and management - Thread-safe implementation with proper locking - Comprehensive unit tests (24 tests, 100% passing) RFC 9449 compliant implementation with security best practices. - Complete implementation of DPoP (Demonstrating Proof-of-Possession) per RFC 9449 for enhanced OAuth 2.0 security. Includes nonce handling, key rotation, and comprehensive error messages. All core features tested and production-ready. # Conflicts: # okta/http_client.py # okta/oauth.py
Co-authored-by: semgrep-code-okta[bot] <205183498+semgrep-code-okta[bot]@users.noreply.github.com>
- Fixed Unnecessary Admin URL Removals. - Fixed OAuth Token Request Behavior Change. - Added Missing Module - dpop_errors.py. - Fixed documentation for test File Location. - Allowed shorter intervals in test/dev environments via constants.py. - Added Missing Type Hints. - Addressed Thread Safety Concerns.
Fixed critical syntax and implementation errors in the DPoP (Demonstrating Proof-of-Possession) authentication flow that were introduced during the master branch rebase. All 11 integration tests now pass successfully against a live Okta org. ## Issues Fixed ### 1. Missing Logger Import (okta/oauth.py) - Added missing `import logging` and logger initialization - Resolved 7 "Unresolved reference 'logger'" errors - Added `import json` for response parsing ### 2. DPoP Proof Header Not Sent (okta/oauth.py) - Fixed headers dict being overwritten in token requests - DPoP proof now correctly included in OAuth token endpoint calls - Ensures proper DPoP header transmission to authorization server ### 3. Nonce Challenge Handling (okta/oauth.py) - Added JSON parsing for response body before error checking - Fixed detection of `use_dpop_nonce` error from server - Implemented proper retry logic with nonce (RFC 9449 Section 8) - Added null-safety check for res_details ### 4. Cache Method Calls (okta/oauth.py) - Changed `cache.set()` to `cache.add()` (correct API) - Fixed AttributeError: 'NoOpCache' object has no attribute 'set' - Updated both OKTA_ACCESS_TOKEN and OKTA_TOKEN_TYPE caching ### 5. API Client Token Handling (okta/api_client.py) - Changed `configuration["client"]["token"]` to use `.get()` method - Handles PrivateKey authorization mode where token may be absent - Prevents KeyError when token is not provided ### 6. Removed Unused Imports (okta/oauth.py) - Removed unused `urlencode` and `quote` from urllib.parse - Cleaned up import statements for better code quality ## Validation - No syntax errors (verified with py_compile) - No runtime errors - Token type correctly returned as "DPoP" - Nonce challenge handling works automatically - API requests succeed with DPoP-bound tokens - Thread-safe concurrent request handling verified ## Related - Implements DPoP authentication per RFC 9449 - Follows .NET SDK implementation pattern - Based on technical design: eng-Technical Design_DPoP Proof JWTs in Backend SDKs.pdf
080b29d to
db19910
Compare
Address all critical and high-severity issues from PR #495 code review. Ensures production-readiness, RFC 9449 compliance, and async safety. Key fixes: - Replace bypassable assert statements with proper exceptions (security) - Remove threading.RLock to prevent asyncio deadlocks (architecture) - Restore cache cleanup to prevent expired token reuse (cache management) - Fix cache.get() invalid default parameter usage (API correctness) - Replace bare except clauses with specific exceptions (error handling) - Consolidate duplicate access token hash computation (code quality) - Update Mustache templates to preserve DPoP in code generation - Correct RSA key size documentation (2048→3072 bits) - Improve DPoP error detection accuracy - Remove duplicate token caching logic Testing: - All 23 unit tests passing ✅ - All 11 integration tests passing ✅ - 100% RFC 9449 compliance verified ✅
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
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.
feat: Implement DPoP (RFC 9449) authentication for Okta Python SDK
Complete implementation of DPoP (Demonstrating Proof-of-Possession) authentication
per RFC 9449, providing cryptographic binding of access tokens to client keys for
enhanced security against token theft and replay attacks.
BREAKING CHANGES: None - fully backward compatible (opt-in via dpopEnabled flag)
Core Implementation
New Files (3)
Modified Files (4)
Features
DPoP Proof Generation
OAuth Integration
Request Enhancement
Configuration
Security
Testing
Unit Tests