Skip to content

Commit

Permalink
Don't emit audit events for illegitimate SAML/OIDC requests
Browse files Browse the repository at this point in the history
Just like #51614 did for GitHub SSO, we suppress login failed
events for attempts where the specified connector does not exist.
  • Loading branch information
zmb3 committed Feb 21, 2025
1 parent 69730fd commit b17b24f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/auth/auth_with_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -3495,7 +3495,15 @@ func (a *ServerWithRoles) CreateOIDCAuthRequest(ctx context.Context, req types.O

oidcReq, err := a.authServer.CreateOIDCAuthRequest(ctx, req)
if err != nil {
emitSSOLoginFailureEvent(a.CloseContext(), a.authServer.emitter, events.LoginMethodOIDC, err, req.SSOTestFlow)
if trace.IsNotFound(err) {
// This flow is triggered via an unauthenticated endpoint, so it's not unusual to see
// attempts to hit this API with an invalid connector ID. These are not legitimate SSO
// attempts, so avoid cluttering the audit log with them.
log.WithField("connector", req.ConnectorID).Infoln("rejecting invalid OIDC auth request")

} else {
emitSSOLoginFailureEvent(a.CloseContext(), a.authServer.emitter, events.LoginMethodOIDC, err, req.SSOTestFlow)
}
return nil, trace.Wrap(err)
}

Expand Down Expand Up @@ -3649,7 +3657,14 @@ func (a *ServerWithRoles) CreateSAMLAuthRequest(ctx context.Context, req types.S

samlReq, err := a.authServer.CreateSAMLAuthRequest(ctx, req)
if err != nil {
emitSSOLoginFailureEvent(a.CloseContext(), a.authServer.emitter, events.LoginMethodSAML, err, req.SSOTestFlow)
if trace.IsNotFound(err) {
// This flow is triggered via an unauthenticated endpoint, so it's not unusual to see
// attempts to hit this API with an invalid connector ID. These are not legitimate SSO
// attempts, so avoid cluttering the audit log with them.
log.WithField("connector", req.ConnectorID).Infoln("rejecting invalid SAML auth request")
} else {
emitSSOLoginFailureEvent(a.CloseContext(), a.authServer.emitter, events.LoginMethodSAML, err, req.SSOTestFlow)
}
return nil, trace.Wrap(err)
}

Expand Down

0 comments on commit b17b24f

Please sign in to comment.