diff options
| author | James Elliott <james-d-elliott@users.noreply.github.com> | 2021-11-29 14:09:14 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-29 14:09:14 +1100 |
| commit | bc3b0fda357cb8a3c0e592cfac0c1a9365ab78ef (patch) | |
| tree | 547ae181489e6792d035d74bba27d4704b9fe3e6 /internal/storage/sql_provider.go | |
| parent | d45dac39b9e3694602642113d22d40640adc1675 (diff) | |
feat(regulator): enhance authentication logs (#2622)
This adds additional logging to the authentication logs such as type, remote IP, request method, redirect URL, and if the attempt was done during a ban. This also means we log attempts that occur when the attempt was blocked by the regulator for record keeping purposes, as well as record 2FA attempts which can be used to inform admins and later to regulate based on other factors.
Fixes #116, Fixes #1293.
Diffstat (limited to 'internal/storage/sql_provider.go')
| -rw-r--r-- | internal/storage/sql_provider.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/internal/storage/sql_provider.go b/internal/storage/sql_provider.go index 9ff5dad2b..5b876f4cf 100644 --- a/internal/storage/sql_provider.go +++ b/internal/storage/sql_provider.go @@ -355,8 +355,10 @@ func (p *SQLProvider) LoadU2FDevice(ctx context.Context, username string) (devic // AppendAuthenticationLog append a mark to the authentication log. func (p *SQLProvider) AppendAuthenticationLog(ctx context.Context, attempt models.AuthenticationAttempt) (err error) { - if _, err = p.db.ExecContext(ctx, p.sqlInsertAuthenticationAttempt, attempt.Time, attempt.Successful, attempt.Username); err != nil { - return fmt.Errorf("error inserting authentiation attempt: %w", err) + if _, err = p.db.ExecContext(ctx, p.sqlInsertAuthenticationAttempt, + attempt.Time, attempt.Successful, attempt.Banned, attempt.Username, + attempt.Type, attempt.RemoteIP, attempt.RequestURI, attempt.RequestMethod); err != nil { + return fmt.Errorf("error inserting authentication attempt: %w", err) } return nil |
