Skip to content

Commit

Permalink
fix: webauthn logspam (#6181)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsHenry35 authored Mar 10, 2024
1 parent 8222284 commit bdfc159
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions internal/bootstrap/data/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func initUser() {
PwdHash: model.TwoHashPwd(adminPassword, salt),
Role: model.ADMIN,
BasePath: "/",
Authn: "[]",
}
if err := op.CreateUser(admin); err != nil {
panic(err)
Expand All @@ -53,6 +54,7 @@ func initUser() {
BasePath: "/",
Permission: 0,
Disabled: true,
Authn: "[]",
}
if err := db.CreateUser(guest); err != nil {
utils.Log.Fatalf("[init user] Failed to create guest user: %v", err)
Expand All @@ -62,6 +64,7 @@ func initUser() {
}
}
hashPwdForOldVersion()
updateAuthnForOldVersion()
}

func hashPwdForOldVersion() {
Expand All @@ -80,3 +83,19 @@ func hashPwdForOldVersion() {
}
}
}

func updateAuthnForOldVersion() {
users, _, err := op.GetUsers(1, -1)
if err != nil {
utils.Log.Fatalf("[update authn for old version] failed get users: %v", err)
}
for i := range users {
user := users[i]
if user.Authn == "" {
user.Authn = "[]"
if err := db.UpdateUser(&user); err != nil {
utils.Log.Fatalf("[update authn for old version] failed update user: %v", err)
}
}
}
}
1 change: 1 addition & 0 deletions server/handles/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func CreateUser(c *gin.Context) {
}
req.SetPassword(req.Password)
req.Password = ""
req.Authn = "[]"
if err := op.CreateUser(&req); err != nil {
common.ErrorResp(c, err, 500, true)
} else {
Expand Down

0 comments on commit bdfc159

Please sign in to comment.