Feat/ldap tls verify - #4105
Feat/ldap tls verify#4105hungz wants to merge 5 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughLDAP TLS configuration now supports explicit CA bundles and verification controls. Legacy and provider settings are updated. LDAPS login uses centralized TLS configuration with validation errors and test coverage. ChangesLDAP TLS verification
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant LDAPLogin
participant ldapTLSConfig
participant LdapProvider
participant CertificatePool
participant LDAPServer
LDAPLogin->>ldapTLSConfig: Request TLS configuration
ldapTLSConfig->>LdapProvider: Evaluate ShouldVerifyTLS()
ldapTLSConfig->>CertificatePool: Load system roots and configured CA bundle
LDAPLogin->>LDAPServer: Dial LDAPS with tls.Config
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
api/login.go (1)
58-62: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueConsider setting an explicit
MinVersionon the LDAPStls.Config.Static analysis flags the missing
MinVersion. Go's client default is already TLS 1.2, so this isn't an active vulnerability, but making it explicit avoids relying on implicit defaults. Note: forcingtls.VersionTLS13(as the tool literally suggests) could break enterprise LDAP/AD servers that only support TLS 1.2, sotls.VersionTLS12is the safer explicit floor.🔒 Proposed fix
cfg := &tls.Config{ // `#nosec` G402 -- opt-out is deliberate and documented above. InsecureSkipVerify: !provider.ShouldVerifyTLS(), + MinVersion: tls.VersionTLS12, }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/login.go` around lines 58 - 62, Update ldapTLSConfig to set tls.Config.MinVersion explicitly to tls.VersionTLS12, preserving the existing InsecureSkipVerify behavior and compatibility with LDAP servers supporting TLS 1.2.Source: Linters/SAST tools
util/LdapProvider.go (1)
21-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDoc comment references a non-existent
TLSVerifyfield.
LdapProviderhas noTLSVerifyfield — onlyTLSSkipVerify.ShouldVerifyTLS()(Line 47) actually overridesTLSSkipVerifywhenTLSCACertFileis set. The schema doc for this same field (config.schema.yaml, providertls_ca_cert_file) correctly says "forces verification on"; this comment should match.✏️ Proposed wording fix
// TLSCACertFile is a PEM bundle used to verify the LDAP server's // certificate, in addition to the system trust store. Set this when the - // server uses a self-signed or internal-CA cert. Setting it implies - // TLSVerify. + // server uses a self-signed or internal-CA cert. Setting it forces + // certificate verification on (overrides TLSSkipVerify). TLSCACertFile string `json:"tls_ca_cert_file"`🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@util/LdapProvider.go` around lines 21 - 25, Update the TLSCACertFile doc comment in LdapProvider to reference the existing TLSSkipVerify behavior accurately: state that setting TLSCACertFile forces TLS certificate verification on, matching ShouldVerifyTLS() and the schema wording, and remove the non-existent TLSVerify reference.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@api/login.go`:
- Around line 58-62: Update ldapTLSConfig to set tls.Config.MinVersion
explicitly to tls.VersionTLS12, preserving the existing InsecureSkipVerify
behavior and compatibility with LDAP servers supporting TLS 1.2.
In `@util/LdapProvider.go`:
- Around line 21-25: Update the TLSCACertFile doc comment in LdapProvider to
reference the existing TLSSkipVerify behavior accurately: state that setting
TLSCACertFile forces TLS certificate verification on, matching ShouldVerifyTLS()
and the schema wording, and remove the non-existent TLSVerify reference.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: eaf269e5-4aa3-4f33-b72f-3a7c495833d8
📒 Files selected for processing (7)
api/login.goapi/login_ldap_tls_test.goconfig.schema.yamldocsutil/LdapProvider.goutil/LdapProvider_test.goutil/config.go
fix issue #749
Summary by CodeRabbit
New Features
Bug Fixes
Documentation