diff options
author | zeripath <art27@cantab.net> | 2022-02-16 21:03:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-16 21:03:58 +0000 |
commit | 3a29a23cdc2823bbce30f5ab99ad01d72208de64 (patch) | |
tree | 11f1a2e0e5e5c0f9617a7e29500940327e339800 /models/migrations/v208.go | |
parent | f48771ae78b5e5b3caa60c55b3253229ea804ab5 (diff) | |
download | gitea-3a29a23cdc2823bbce30f5ab99ad01d72208de64.tar.gz gitea-3a29a23cdc2823bbce30f5ab99ad01d72208de64.zip |
Attempt to fix the webauthn migration again - part 3 (#18770)
v208.go is seriously broken as it misses an ID() check. We need to no-op and remigrate all of the u2f keys.
See #18756
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'models/migrations/v208.go')
-rw-r--r-- | models/migrations/v208.go | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/models/migrations/v208.go b/models/migrations/v208.go index 724b174187..2875406121 100644 --- a/models/migrations/v208.go +++ b/models/migrations/v208.go @@ -5,46 +5,10 @@ package migrations import ( - "encoding/base32" - "encoding/base64" - "xorm.io/xorm" ) func useBase32HexForCredIDInWebAuthnCredential(x *xorm.Engine) error { - // Create webauthnCredential table - type webauthnCredential struct { - ID int64 `xorm:"pk autoincr"` - CredentialID string `xorm:"INDEX VARCHAR(410)"` - } - if err := x.Sync2(&webauthnCredential{}); err != nil { - return err - } - - var start int - regs := make([]*webauthnCredential, 0, 50) - for { - err := x.OrderBy("id").Limit(50, start).Find(®s) - if err != nil { - return err - } - - for _, reg := range regs { - credID, _ := base64.RawStdEncoding.DecodeString(reg.CredentialID) - reg.CredentialID = base32.HexEncoding.EncodeToString(credID) - - _, err := x.Update(reg) - if err != nil { - return err - } - } - - if len(regs) < 50 { - break - } - start += 50 - regs = regs[:0] - } - + // noop return nil } |