-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
WebAuthn CredentialID field needs to be increased in size #20530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
6543
merged 15 commits into
go-gitea:main
from
zeripath:fix-20457-increase-webauthn-credential-field
Jul 30, 2022
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
835cf4c
WebAuthn CredentialID field needs to be increased in size
zeripath 8b0716b
Merge remote-tracking branch 'origin/main' into fix-20457-increase-we…
zeripath 46fced8
Move to use webauthnCredential CredentialID as bytes
zeripath 919d517
fix test
zeripath 248b5ce
i hate our linter
zeripath 72cd759
of course MSSQL has to be difficult
zeripath 25388aa
i hate our linter
zeripath 3eb1d13
and change the lookup function
zeripath da04731
and change the lookup function
zeripath 9f15fed
separate the out the droptablecolumns into another migration
zeripath 0e675c9
Update models/migrations/v223.go
zeripath 7926dac
Update webauthn.go
zeripath 197c197
nit
6543 ebfa23a
Merge branch 'main' into fix-20457-increase-webauthn-credential-field
6543 550160c
Merge branch 'main' into fix-20457-increase-webauthn-credential-field
6543 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package migrations | ||
|
||
import ( | ||
"code.gitea.io/gitea/modules/timeutil" | ||
|
||
"xorm.io/xorm" | ||
"xorm.io/xorm/schemas" | ||
) | ||
|
||
func increaseCredentialIDTo1640(x *xorm.Engine) error { | ||
// Create webauthnCredential table | ||
type webauthnCredential struct { | ||
ID int64 `xorm:"pk autoincr"` | ||
Name string | ||
LowerName string `xorm:"unique(s)"` | ||
UserID int64 `xorm:"INDEX unique(s)"` | ||
CredentialID string `xorm:"INDEX VARCHAR(1640)"` // CredentialID is at most 1023 bytes as per spec released 20 July 2022 -> 1640 base32 encoding | ||
PublicKey []byte | ||
AttestationType string | ||
AAGUID []byte | ||
SignCount uint32 `xorm:"BIGINT"` | ||
CloneWarning bool | ||
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` | ||
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` | ||
} | ||
if err := x.Sync2(&webauthnCredential{}); err != nil { | ||
return err | ||
} | ||
|
||
switch x.Dialect().URI().DBType { | ||
case schemas.MYSQL: | ||
_, err := x.Exec("ALTER TABLE webauthn_credential MODIFY COLUMN credential_id VARCHAR(1640)") | ||
if err != nil { | ||
return err | ||
} | ||
case schemas.ORACLE: | ||
_, err := x.Exec("ALTER TABLE webauthn_credential MODIFY credential_id VARCHAR(1640)") | ||
if err != nil { | ||
return err | ||
} | ||
case schemas.MSSQL: | ||
// This column has an index on it. I could write all of the code to attempt to change the index OR | ||
// I could just use recreate table. | ||
sess := x.NewSession() | ||
if err := sess.Begin(); err != nil { | ||
_ = sess.Close() | ||
return err | ||
} | ||
|
||
if err := recreateTable(sess, new(webauthnCredential)); err != nil { | ||
_ = sess.Close() | ||
return err | ||
} | ||
if err := sess.Commit(); err != nil { | ||
_ = sess.Close() | ||
return err | ||
} | ||
if err := sess.Close(); err != nil { | ||
return err | ||
} | ||
case schemas.POSTGRES: | ||
_, err := x.Exec("ALTER TABLE webauthn_credential ALTER COLUMN credential_id TYPE VARCHAR(1640)") | ||
if err != nil { | ||
return err | ||
} | ||
default: | ||
// SQLite doesn't support ALTER COLUMN, and it already makes String _TEXT_ by default so no migration needed | ||
// nor is there any need to re-migrate | ||
} | ||
return nil | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.