feat: complete lab 7 grade 4 security controls and report

This commit is contained in:
Dmitrii Grishko
2026-11-15 21:58:27 +03:00
parent c5e3ac3aff
commit c69d735692
52 changed files with 1124 additions and 129 deletions
+13 -2
View File
@@ -2,6 +2,8 @@ package repositories
import (
"context"
"crypto/tls"
"os"
"errors"
"messenger/src/backend/telemetry"
@@ -20,12 +22,21 @@ type JobBroker struct {
}
func NewJobBroker(ctx context.Context, address string) (*JobBroker, error) {
connection, err := amqp.DialConfig(address, amqp.Config{
config := amqp.Config{
Heartbeat: 10 * time.Second,
Dial: func(network, address string) (net.Conn, error) {
return (&net.Dialer{Timeout: 5 * time.Second}).DialContext(ctx, network, address)
},
})
}
if os.Getenv("BROKER_MTLS") == "1" {
cert, err := tls.LoadX509KeyPair("/run/broker/client.crt", "/run/broker/client.key")
if err != nil {
return nil, errors.New("RabbitMQ client certificate unavailable")
}
config.TLSClientConfig = &tls.Config{MinVersion: tls.VersionTLS12, Certificates: []tls.Certificate{cert}}
config.SASL = []amqp.Authentication{&amqp.ExternalAuth{}}
}
connection, err := amqp.DialConfig(address, config)
if err != nil {
return nil, errors.New("RabbitMQ connection unavailable")
}