Skip to content
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

ADR 024: mTLS for 2FA #573

Merged
merged 24 commits into from
Mar 22, 2024
Merged

ADR 024: mTLS for 2FA #573

merged 24 commits into from
Mar 22, 2024

Conversation

StephenCathcart
Copy link
Contributor

@StephenCathcart StephenCathcart commented Mar 11, 2024

Enables mutual TLS for 2-factor authentication.

Static client certificate provider:

password := "thepassword1"
provider, err := auth.NewStaticClientCertificateProvider(auth.ClientCertificate{
	CertFile: "path/to/cert.pem",
	KeyFile:  "path/to/key.pem",
	Password: &password,
})
if err != nil {
	log.Fatalf("Failed to load certificate: %v", err)
}
_, _ = neo4j.NewDriverWithContext("bolt://localhost:7687", neo4j.BasicAuth("neo4j", "password", ""), func(config *config.Config) {
	config.ClientCertificateProvider = provider
})

Rotating client certificate provider:

password := "thepassword1"
provider, err := auth.NewRotatingClientCertificateProvider(auth.ClientCertificate{
	CertFile: "path/to/cert.pem",
	KeyFile:  "path/to/key.pem",
	Password: &password,
})
if err != nil {
	log.Fatalf("Failed to load certificate: %v", err)
}
_, _ = neo4j.NewDriverWithContext("bolt://localhost:7687", neo4j.BasicAuth("neo4j", "password", ""), func(config *config.Config) {
	config.ClientCertificateProvider = provider
})
// Some time later we update the certificate
provider.UpdateCertificate(auth.ClientCertificate{
	CertFile: "path/to/new_cert.pem",
	KeyFile:  "path/to/new_key.pem",
	Password: &password,
})

@StephenCathcart
Copy link
Contributor Author

neo4j/auth/cert.go Show resolved Hide resolved
@robsdedude robsdedude self-requested a review March 13, 2024 10:55
neo4j/auth/cert_examples_test.go Show resolved Hide resolved
neo4j/auth/cert_test.go Show resolved Hide resolved
neo4j/auth/cert_examples_test.go Show resolved Hide resolved
neo4j/auth/cert.go Outdated Show resolved Hide resolved
neo4j/auth/cert.go Show resolved Hide resolved
neo4j/auth/cert.go Show resolved Hide resolved
neo4j/auth/cert_examples_test.go Outdated Show resolved Hide resolved
neo4j/auth/cert_test.go Show resolved Hide resolved
neo4j/config/driver.go Outdated Show resolved Hide resolved
neo4j/internal/connector/connector.go Outdated Show resolved Hide resolved
StephenCathcart and others added 4 commits March 13, 2024 13:56
Co-authored-by: Robsdedude <dev@rouvenbauer.de>
Co-authored-by: Robsdedude <dev@rouvenbauer.de>
@StephenCathcart StephenCathcart marked this pull request as ready for review March 18, 2024 16:59
Copy link
Member

@robsdedude robsdedude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚂 🔐

testkit-backend/backend.go Outdated Show resolved Hide resolved
@StephenCathcart StephenCathcart merged commit 55358a7 into neo4j:5.0 Mar 22, 2024
5 checks passed
@StephenCathcart StephenCathcart deleted the feat/mtls branch March 22, 2024 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants