@@ -169,6 +169,7 @@ func validateFactors(db *storage.Connection, user *models.User, newFactorName st
169169
170170func (a * API ) enrollPhoneFactor (w http.ResponseWriter , r * http.Request , params * EnrollFactorParams ) error {
171171 ctx := r .Context ()
172+ config := a .config
172173 user := getUser (ctx )
173174 session := getSession (ctx )
174175 db := a .db .WithContext (ctx )
@@ -208,7 +209,7 @@ func (a *API) enrollPhoneFactor(w http.ResponseWriter, r *http.Request, params *
208209 if terr := tx .Create (factor ); terr != nil {
209210 return terr
210211 }
211- if terr := models .NewAuditLogEntry (r , tx , user , models .EnrollFactorAction , r .RemoteAddr , map [string ]interface {}{
212+ if terr := models .NewAuditLogEntry (config . AuditLog , r , tx , user , models .EnrollFactorAction , r .RemoteAddr , map [string ]interface {}{
212213 "factor_id" : factor .ID ,
213214 "factor_type" : factor .FactorType ,
214215 }); terr != nil {
@@ -230,6 +231,7 @@ func (a *API) enrollPhoneFactor(w http.ResponseWriter, r *http.Request, params *
230231func (a * API ) enrollWebAuthnFactor (w http.ResponseWriter , r * http.Request , params * EnrollFactorParams ) error {
231232 ctx := r .Context ()
232233 user := getUser (ctx )
234+ config := a .config
233235 session := getSession (ctx )
234236 db := a .db .WithContext (ctx )
235237
@@ -242,7 +244,7 @@ func (a *API) enrollWebAuthnFactor(w http.ResponseWriter, r *http.Request, param
242244 if terr := tx .Create (factor ); terr != nil {
243245 return terr
244246 }
245- if terr := models .NewAuditLogEntry (r , tx , user , models .EnrollFactorAction , r .RemoteAddr , map [string ]interface {}{
247+ if terr := models .NewAuditLogEntry (config . AuditLog , r , tx , user , models .EnrollFactorAction , r .RemoteAddr , map [string ]interface {}{
246248 "factor_id" : factor .ID ,
247249 "factor_type" : factor .FactorType ,
248250 }); terr != nil {
@@ -311,7 +313,7 @@ func (a *API) enrollTOTPFactor(w http.ResponseWriter, r *http.Request, params *E
311313 return terr
312314 }
313315
314- if terr := models .NewAuditLogEntry (r , tx , user , models .EnrollFactorAction , r .RemoteAddr , map [string ]interface {}{
316+ if terr := models .NewAuditLogEntry (config . AuditLog , r , tx , user , models .EnrollFactorAction , r .RemoteAddr , map [string ]interface {}{
315317 "factor_id" : factor .ID ,
316318 }); terr != nil {
317319 return terr
@@ -435,7 +437,7 @@ func (a *API) challengePhoneFactor(w http.ResponseWriter, r *http.Request) error
435437 return terr
436438 }
437439
438- if terr := models .NewAuditLogEntry (r , tx , user , models .CreateChallengeAction , r .RemoteAddr , map [string ]interface {}{
440+ if terr := models .NewAuditLogEntry (config . AuditLog , r , tx , user , models .CreateChallengeAction , r .RemoteAddr , map [string ]interface {}{
439441 "factor_id" : factor .ID ,
440442 "factor_status" : factor .Status ,
441443 }); terr != nil {
@@ -467,7 +469,7 @@ func (a *API) challengeTOTPFactor(w http.ResponseWriter, r *http.Request) error
467469 if terr := factor .WriteChallengeToDatabase (tx , challenge ); terr != nil {
468470 return terr
469471 }
470- if terr := models .NewAuditLogEntry (r , tx , user , models .CreateChallengeAction , r .RemoteAddr , map [string ]interface {}{
472+ if terr := models .NewAuditLogEntry (config . AuditLog , r , tx , user , models .CreateChallengeAction , r .RemoteAddr , map [string ]interface {}{
471473 "factor_id" : factor .ID ,
472474 "factor_status" : factor .Status ,
473475 }); terr != nil {
@@ -672,7 +674,7 @@ func (a *API) verifyTOTPFactor(w http.ResponseWriter, r *http.Request, params *V
672674
673675 err = db .Transaction (func (tx * storage.Connection ) error {
674676 var terr error
675- if terr = models .NewAuditLogEntry (r , tx , user , models .VerifyFactorAction , r .RemoteAddr , map [string ]interface {}{
677+ if terr = models .NewAuditLogEntry (config . AuditLog , r , tx , user , models .VerifyFactorAction , r .RemoteAddr , map [string ]interface {}{
676678 "factor_id" : factor .ID ,
677679 "challenge_id" : challenge .ID ,
678680 "factor_type" : factor .FactorType ,
@@ -811,7 +813,7 @@ func (a *API) verifyPhoneFactor(w http.ResponseWriter, r *http.Request, params *
811813
812814 err = db .Transaction (func (tx * storage.Connection ) error {
813815 var terr error
814- if terr = models .NewAuditLogEntry (r , tx , user , models .VerifyFactorAction , r .RemoteAddr , map [string ]interface {}{
816+ if terr = models .NewAuditLogEntry (config . AuditLog , r , tx , user , models .VerifyFactorAction , r .RemoteAddr , map [string ]interface {}{
815817 "factor_id" : factor .ID ,
816818 "challenge_id" : challenge .ID ,
817819 "factor_type" : factor .FactorType ,
@@ -855,6 +857,7 @@ func (a *API) verifyPhoneFactor(w http.ResponseWriter, r *http.Request, params *
855857
856858func (a * API ) verifyWebAuthnFactor (w http.ResponseWriter , r * http.Request , params * VerifyFactorParams ) error {
857859 ctx := r .Context ()
860+ config := a .config
858861 user := getUser (ctx )
859862 factor := getFactor (ctx )
860863 db := a .db .WithContext (ctx )
@@ -910,7 +913,7 @@ func (a *API) verifyWebAuthnFactor(w http.ResponseWriter, r *http.Request, param
910913 var token * AccessTokenResponse
911914 err = db .Transaction (func (tx * storage.Connection ) error {
912915 var terr error
913- if terr = models .NewAuditLogEntry (r , tx , user , models .VerifyFactorAction , r .RemoteAddr , map [string ]interface {}{
916+ if terr = models .NewAuditLogEntry (config . AuditLog , r , tx , user , models .VerifyFactorAction , r .RemoteAddr , map [string ]interface {}{
914917 "factor_id" : factor .ID ,
915918 "challenge_id" : challenge .ID ,
916919 "factor_type" : factor .FactorType ,
@@ -991,6 +994,7 @@ func (a *API) VerifyFactor(w http.ResponseWriter, r *http.Request) error {
991994func (a * API ) UnenrollFactor (w http.ResponseWriter , r * http.Request ) error {
992995 var err error
993996 ctx := r .Context ()
997+ config := a .config
994998 user := getUser (ctx )
995999 factor := getFactor (ctx )
9961000 session := getSession (ctx )
@@ -1009,7 +1013,7 @@ func (a *API) UnenrollFactor(w http.ResponseWriter, r *http.Request) error {
10091013 if terr := tx .Destroy (factor ); terr != nil {
10101014 return terr
10111015 }
1012- if terr = models .NewAuditLogEntry (r , tx , user , models .UnenrollFactorAction , r .RemoteAddr , map [string ]interface {}{
1016+ if terr = models .NewAuditLogEntry (config . AuditLog , r , tx , user , models .UnenrollFactorAction , r .RemoteAddr , map [string ]interface {}{
10131017 "factor_id" : factor .ID ,
10141018 "factor_status" : factor .Status ,
10151019 "session_id" : session .ID ,
0 commit comments