-
Notifications
You must be signed in to change notification settings - Fork 1.6k
improvement(kubernetes-auth): k8s auth validation and errors #5002
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
base: main
Are you sure you want to change the base?
Conversation
…g for Axios requests - Added a new file for error handlers to manage Axios network and HTTP errors, providing detailed error messages. - Updated existing functions to utilize the new error handling methods, improving error reporting for Kubernetes authentication processes. - Introduced validation functions for Kubernetes host connectivity and token reviewer JWT permissions, enhancing the robustness of the authentication service.
…uth service - Removed unnecessary comments related to validation of Kubernetes host connectivity and token reviewer JWT permissions, streamlining the code for better readability.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Greptile OverviewGreptile SummaryThis PR adds validation for Kubernetes authentication configuration by introducing connectivity checks and token permission validation. The implementation includes:
Key improvements:
Issues found:
Confidence Score: 4/5
Important Files ChangedFile Analysis
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 6 comments
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-validators.ts
Outdated
Show resolved
Hide resolved
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-validators.ts
Outdated
Show resolved
Hide resolved
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-validators.ts
Outdated
Show resolved
Hide resolved
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-validators.ts
Outdated
Show resolved
Hide resolved
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-validators.ts
Outdated
Show resolved
Hide resolved
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-error-handlers.ts
Show resolved
Hide resolved
…es connectivity checks - Integrated blockLocalAndPrivateIpAddresses function to validate Kubernetes host connectivity and token reviewer JWT permissions, enhancing security by preventing local and private IP address usage.
…st connectivity failure
|
@greptileai re-review the code and update the first comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 2 comments
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
Outdated
Show resolved
Hide resolved
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
Outdated
Show resolved
Hide resolved
…bernetes auth service - Implemented logic to decrypt the Kubernetes CA certificate if not provided, ensuring secure handling of sensitive data. - Updated function calls to use the effective CA certificate for Kubernetes host connectivity validation and token reviewer JWT permissions.
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-fns.ts
Outdated
Show resolved
Hide resolved
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
Outdated
Show resolved
Hide resolved
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
Show resolved
Hide resolved
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
Outdated
Show resolved
Hide resolved
…sername parsing - Replaced UnauthorizedError with BadRequestError for invalid Kubernetes service account username format, improving clarity in error reporting. - Adjusted the logic for determining the effective gateway ID in the identity Kubernetes auth service to ensure correct fallback behavior.
…idation and error handling - Introduced a new GatewayRequestExecutor to support both API and Gateway modes for Kubernetes connectivity validation. - Updated validateKubernetesHostConnectivity and validateTokenReviewerPermissions functions to handle requests through the gateway. - Improved error handling and logging for connectivity issues and permission validations, providing clearer context for failures. - Refactored existing validation logic to accommodate the new gateway functionality, ensuring backward compatibility.
… requests - Replaced UnauthorizedError with BadRequestError in handleAxiosHttpError for improved clarity in error reporting related to token review requests.
Context
This PR adds validation to the Kubernetes URL and token when adding a Kubernetes auth to a machine identity. It also adds more detailed error messages and centralizes error handling.
https://linear.app/infisical/issue/ENG-4209/improve-kubernetes-auth-error-handling-and-validation-steps
Steps to verify the change
Type
Checklist
type(scope): short description(scope is optional, e.g.,fix: prevent crash on syncorfix(api): handle null response).