Skip to content

Commit c9f1ed5

Browse files
authored
Merge pull request #499 from supabase/j0_add_ip_address_field
Add IP Address field to audit log
2 parents bfaa68e + 7568953 commit c9f1ed5

17 files changed

+38
-36
lines changed

api/admin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (a *API) adminUserUpdate(w http.ResponseWriter, r *http.Request) error {
175175
}
176176
}
177177

178-
if terr := models.NewAuditLogEntry(tx, instanceID, adminUser, models.UserModifiedAction, map[string]interface{}{
178+
if terr := models.NewAuditLogEntry(tx, instanceID, adminUser, models.UserModifiedAction, "", map[string]interface{}{
179179
"user_id": user.ID,
180180
"user_email": user.Email,
181181
"user_phone": user.Phone,
@@ -270,7 +270,7 @@ func (a *API) adminUserCreate(w http.ResponseWriter, r *http.Request) error {
270270
}
271271

272272
err = a.db.Transaction(func(tx *storage.Connection) error {
273-
if terr := models.NewAuditLogEntry(tx, instanceID, adminUser, models.UserSignedUpAction, map[string]interface{}{
273+
if terr := models.NewAuditLogEntry(tx, instanceID, adminUser, models.UserSignedUpAction, "", map[string]interface{}{
274274
"user_id": user.ID,
275275
"user_email": user.Email,
276276
"user_phone": user.Phone,
@@ -323,7 +323,7 @@ func (a *API) adminUserDelete(w http.ResponseWriter, r *http.Request) error {
323323
adminUser := getAdminUser(ctx)
324324

325325
err := a.db.Transaction(func(tx *storage.Connection) error {
326-
if terr := models.NewAuditLogEntry(tx, instanceID, adminUser, models.UserDeletedAction, map[string]interface{}{
326+
if terr := models.NewAuditLogEntry(tx, instanceID, adminUser, models.UserDeletedAction, "", map[string]interface{}{
327327
"user_id": user.ID,
328328
"user_email": user.Email,
329329
"user_phone": user.Phone,

api/audit.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func (a *API) adminAuditLog(w http.ResponseWriter, r *http.Request) error {
1717
ctx := r.Context()
1818
instanceID := getInstanceID(ctx)
1919
// aud := a.requestAud(ctx, r)
20-
2120
pageParams, err := paginate(r)
2221
if err != nil {
2322
return badRequestError("Bad Pagination Parameters: %v", err)

api/external.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func (a *API) internalExternalProviderCallback(w http.ResponseWriter, r *http.Re
245245
return nil
246246
}
247247

248-
if terr := models.NewAuditLogEntry(tx, instanceID, user, models.UserSignedUpAction, map[string]interface{}{
248+
if terr := models.NewAuditLogEntry(tx, instanceID, user, models.UserSignedUpAction, "", map[string]interface{}{
249249
"provider": providerType,
250250
}); terr != nil {
251251
return terr
@@ -259,7 +259,7 @@ func (a *API) internalExternalProviderCallback(w http.ResponseWriter, r *http.Re
259259
return internalServerError("Error updating user").WithInternalError(terr)
260260
}
261261
} else {
262-
if terr := models.NewAuditLogEntry(tx, instanceID, user, models.LoginAction, map[string]interface{}{
262+
if terr := models.NewAuditLogEntry(tx, instanceID, user, models.LoginAction, "", map[string]interface{}{
263263
"provider": providerType,
264264
}); terr != nil {
265265
return terr
@@ -347,7 +347,7 @@ func (a *API) processInvite(ctx context.Context, tx *storage.Connection, userDat
347347
return nil, internalServerError("Database error updating user").WithInternalError(err)
348348
}
349349

350-
if err := models.NewAuditLogEntry(tx, instanceID, user, models.InviteAcceptedAction, map[string]interface{}{
350+
if err := models.NewAuditLogEntry(tx, instanceID, user, models.InviteAcceptedAction, "", map[string]interface{}{
351351
"provider": providerType,
352352
}); err != nil {
353353
return nil, err

api/invite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (a *API) Invite(w http.ResponseWriter, r *http.Request) error {
5555
}
5656
}
5757

58-
if terr := models.NewAuditLogEntry(tx, instanceID, adminUser, models.UserInvitedAction, map[string]interface{}{
58+
if terr := models.NewAuditLogEntry(tx, instanceID, adminUser, models.UserInvitedAction, "", map[string]interface{}{
5959
"user_id": user.ID,
6060
"user_email": user.Email,
6161
}); terr != nil {

api/logout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (a *API) Logout(w http.ResponseWriter, r *http.Request) error {
2121
}
2222

2323
err = a.db.Transaction(func(tx *storage.Connection) error {
24-
if terr := models.NewAuditLogEntry(tx, instanceID, u, models.LogoutAction, nil); terr != nil {
24+
if terr := models.NewAuditLogEntry(tx, instanceID, u, models.LogoutAction, "", nil); terr != nil {
2525
return terr
2626
}
2727
return models.Logout(tx, instanceID, u.ID)

api/magic_link.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (a *API) MagicLink(w http.ResponseWriter, r *http.Request) error {
7676
}
7777

7878
err = a.db.Transaction(func(tx *storage.Connection) error {
79-
if terr := models.NewAuditLogEntry(tx, instanceID, user, models.UserRecoveryRequestedAction, nil); terr != nil {
79+
if terr := models.NewAuditLogEntry(tx, instanceID, user, models.UserRecoveryRequestedAction, "", nil); terr != nil {
8080
return terr
8181
}
8282

api/mail.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (a *API) GenerateLink(w http.ResponseWriter, r *http.Request) error {
7373
var terr error
7474
switch params.Type {
7575
case "magiclink", "recovery":
76-
if terr = models.NewAuditLogEntry(tx, instanceID, user, models.UserRecoveryRequestedAction, nil); terr != nil {
76+
if terr = models.NewAuditLogEntry(tx, instanceID, user, models.UserRecoveryRequestedAction, "", nil); terr != nil {
7777
return terr
7878
}
7979
user.RecoveryToken = crypto.SecureToken()
@@ -96,7 +96,7 @@ func (a *API) GenerateLink(w http.ResponseWriter, r *http.Request) error {
9696
return terr
9797
}
9898
}
99-
if terr = models.NewAuditLogEntry(tx, instanceID, adminUser, models.UserInvitedAction, map[string]interface{}{
99+
if terr = models.NewAuditLogEntry(tx, instanceID, adminUser, models.UserInvitedAction, "", map[string]interface{}{
100100
"user_id": user.ID,
101101
"user_email": user.Email,
102102
}); terr != nil {

api/otp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (a *API) SmsOtp(w http.ResponseWriter, r *http.Request) error {
117117
}
118118

119119
err = a.db.Transaction(func(tx *storage.Connection) error {
120-
if err := models.NewAuditLogEntry(tx, instanceID, user, models.UserRecoveryRequestedAction, nil); err != nil {
120+
if err := models.NewAuditLogEntry(tx, instanceID, user, models.UserRecoveryRequestedAction, "", nil); err != nil {
121121
return err
122122
}
123123
smsProvider, terr := sms_provider.GetSmsProvider(*config)

api/reauthenticate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (a *API) Reauthenticate(w http.ResponseWriter, r *http.Request) error {
4949
}
5050

5151
err = a.db.Transaction(func(tx *storage.Connection) error {
52-
if terr := models.NewAuditLogEntry(tx, instanceID, user, models.UserReauthenticateAction, nil); terr != nil {
52+
if terr := models.NewAuditLogEntry(tx, instanceID, user, models.UserReauthenticateAction, "", nil); terr != nil {
5353
return terr
5454
}
5555
if email != "" {

api/recover.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (a *API) Recover(w http.ResponseWriter, r *http.Request) error {
4646
}
4747

4848
err = a.db.Transaction(func(tx *storage.Connection) error {
49-
if terr := models.NewAuditLogEntry(tx, instanceID, user, models.UserRecoveryRequestedAction, nil); terr != nil {
49+
if terr := models.NewAuditLogEntry(tx, instanceID, user, models.UserRecoveryRequestedAction, "", nil); terr != nil {
5050
return terr
5151
}
5252
mailer := a.Mailer(ctx)

0 commit comments

Comments
 (0)