🔥 feat: Add TLSConfig to ListenConfig#4024
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds a new public Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer/Test
participant Listen as Listen()
participant Decision as TLS Decision
participant TLSCfg as TLSConfig (base)
participant File as Cert Files
participant Auto as AutoCertManager
participant Apply as applyClientCert
Dev->>Listen: Start listener with ListenConfig
Listen->>Decision: Determine TLS source
Decision-->>TLSCfg: if TLSConfig provided -> clone tls.Config
Decision-->>File: else if CertFile & CertKeyFile -> load pair + set GetCertificate
Decision-->>Auto: else if AutoCertManager -> use manager.GetCertificate + NextProtos
Decision->>Listen: return tls.Config
Listen->>Apply: if CertClientFile present -> applyClientCert(tls.Config, CertClientFile)
Apply-->>Listen: client CA appended / error
Listen->>Dev: Listener started (or error)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @gaby, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the TLS configuration options by introducing a dedicated Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4024 +/- ##
==========================================
+ Coverage 91.23% 91.29% +0.05%
==========================================
Files 119 119
Lines 11007 11057 +50
==========================================
+ Hits 10042 10094 +52
Misses 610 610
+ Partials 355 353 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new TLSConfig option in ListenConfig, enabling more flexible TLS configuration, particularly for external certificate providers. The implementation includes adding the field, handling configuration conflicts, and refactoring existing TLS logic. The changes are well-supported by comprehensive documentation updates and new tests. Overall, this is a solid contribution. I have a few suggestions to further improve documentation clarity and error handling.
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: d068ec4 | Previous: 7104ad1 | Ratio |
|---|---|---|---|
Benchmark_FiberHandlerFunc/No_Content |
5778 ns/op 33039 B/op 8 allocs/op |
3805 ns/op 33048 B/op 8 allocs/op |
1.52 |
Benchmark_FiberHandlerFunc/No_Content - ns/op |
5778 ns/op |
3805 ns/op |
1.52 |
Benchmark_FiberHandlerFunc/1MB |
6006 ns/op 33069 B/op 8 allocs/op |
3816 ns/op 33059 B/op 8 allocs/op |
1.57 |
Benchmark_FiberHandlerFunc/1MB - ns/op |
6006 ns/op |
3816 ns/op |
1.57 |
Benchmark_FiberHandlerFunc/5MB |
5795 ns/op 33155 B/op 8 allocs/op |
3857 ns/op 33125 B/op 8 allocs/op |
1.50 |
Benchmark_FiberHandlerFunc/5MB - ns/op |
5795 ns/op |
3857 ns/op |
1.50 |
This comment was automatically generated by workflow using github-action-benchmark.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a significant enhancement to the TLS configuration by adding a TLSConfig field to ListenConfig. This provides greater flexibility, allowing users to supply TLS certificates from various sources like in-memory data or external providers. The implementation is robust, with clear validation for conflicting settings and good refactoring of the existing TLS setup logic. The documentation has been updated comprehensively with clear examples and explanations of the new feature and its precedence. The added unit tests effectively cover the new functionality.
I have one suggestion to improve the robustness of the client certificate handling by checking the return value of AppendCertsFromPEM to ensure certificates are actually loaded from the provided file.
Overall, this is an excellent contribution that improves the flexibility and usability of Fiber's TLS configuration.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request significantly enhances the TLS configuration options by introducing a dedicated TLSConfig field to the ListenConfig struct. This change provides greater flexibility for users to supply TLS certificates from various sources, such as in-memory PEM data or environment variables, and integrates seamlessly with external certificate providers. The update also includes robust validation to prevent incompatible TLS settings and clear documentation with practical examples to guide users. The refactoring of client certificate handling into a dedicated function improves code modularity and readability. Comprehensive test cases have been added to ensure the correctness of the new features and conflict checks. Overall, this is a well-implemented and well-documented enhancement.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request significantly enhances the TLS configuration options by introducing a dedicated TLSConfig field to the ListenConfig struct. This change provides greater flexibility for users to supply TLS certificates from various sources, such as in-memory PEM data or environment variables, and integrates seamlessly with external certificate providers. The update also includes robust validation to prevent incompatible TLS settings and clear documentation with practical examples to guide users. The implementation correctly handles precedence, ensuring that TLSConfig takes priority over other TLS-related fields, and includes comprehensive test cases to verify the new functionality and error conditions.
|
@simonnix We plan on using TLSConfig as provided, else we will use existing fields. I just removed the logic to merge them since that was adding complexity. |
|
Hi @gaby, I'm fine with that, having Just thinking about it (I'm not an Express.js user, I just looked it up) but, are you moving to just offer Is that your idea? I'm fine with it, just asking. |
@simonnix Priority is TLSConfig, but we are leaving the other fields since we are in Edit: net/http server uses TLSConfig too. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This is an excellent pull request that significantly enhances Fiber's TLS configuration capabilities. The introduction of the TLSConfig field is a great addition, providing much-needed flexibility for advanced use cases like external certificate providers and in-memory certificates. The implementation is robust, correctly handling configuration precedence and safely cloning the tls.Config to prevent side effects. The accompanying documentation updates are thorough and clear, with plenty of useful examples. The tests are comprehensive, covering new functionality, error conditions, and precedence logic. I have one minor suggestion to improve the documentation's clarity by removing a redundant section.
Description
Replaces #4019 and #4021