From c138193ade8275a5f5da034dd6dd6290f7e6cdd6 Mon Sep 17 00:00:00 2001 From: Andrew Lytvynov Date: Thu, 4 Dec 2025 14:27:08 -0800 Subject: [PATCH] Allow opting out of Slack notifications for some access configs Some access requests could be noisy, allow suppressing slack notifications for those. --- hallpass.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/hallpass.go b/hallpass.go index 3f4bf11..900e511 100644 --- a/hallpass.go +++ b/hallpass.go @@ -242,6 +242,7 @@ type accessTypeConfig struct { Attr string // e.g. "custom:jitToPII" (posture attribute key) Max timeDurationString Default timeDurationString + Silent bool // when true, skip Slack notifications for access requests } type accessTypes struct { @@ -532,15 +533,17 @@ func (s *Server) authorize(ctx context.Context, li lookupInfo, req authorizeRequ if err != nil { return fmt.Errorf("SetPostureAttribute: %v", err) } - if err := SendSlack(ctx, string(s.webhookURL()), SlackNotification{ - Who: li.Who, - NodeID: li.NodeID, - NodeName: li.NodeName, - AccessType: at.Name, - AccessDuration: req.Duration.String(), - Reason: req.Reason, - }); err != nil { - return fmt.Errorf("SendSlack: %v", err) + if !at.Silent { + if err := SendSlack(ctx, string(s.webhookURL()), SlackNotification{ + Who: li.Who, + NodeID: li.NodeID, + NodeName: li.NodeName, + AccessType: at.Name, + AccessDuration: req.Duration.String(), + Reason: req.Reason, + }); err != nil { + return fmt.Errorf("SendSlack: %v", err) + } } return nil }