-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Update tool dependencies and fix new lint issues #36702
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
silverwind
merged 9 commits into
go-gitea:main
from
silverwind:silverwind/update-tool-deps
Feb 26, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d69a2f8
Update tool dependencies and fix new lint issues
silverwind 94eb57c
Use PublicKey.Bytes() instead of deprecated X/Y fields for JWK encoding
silverwind 2b7c33f
Use PublicKey.Bytes() instead of deprecated X/Y fields for JWK encoding
silverwind 5d87d6d
Validate SEC 1 encoding and derive curve from signing algorithm in ToJWK
silverwind d999c49
Simplify ECDSA ToJWK by removing unnecessary SEC 1 validation
silverwind d5ddf17
Remove dead staticcheck linter exclusion
silverwind b7b472b
Merge branch 'main' into silverwind/update-tool-deps
silverwind ab8dec0
Merge branch 'main' into silverwind/update-tool-deps
silverwind 6ad6093
Merge branch 'main' into silverwind/update-tool-deps
silverwind 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
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,61 @@ | ||
| // Copyright 2026 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package oauth2_provider | ||
|
|
||
| import ( | ||
| "crypto/ecdsa" | ||
| "crypto/elliptic" | ||
| "crypto/rand" | ||
| "encoding/base64" | ||
| "math/big" | ||
| "testing" | ||
|
|
||
| "github.com/golang-jwt/jwt/v5" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestECDSASigningKeyToJWK(t *testing.T) { | ||
| for _, tc := range []struct { | ||
| curve elliptic.Curve | ||
| signingMethod jwt.SigningMethod | ||
| expectedAlg string | ||
| expectedCrv string | ||
| coordLen int | ||
| }{ | ||
| {elliptic.P256(), jwt.SigningMethodES256, "ES256", "P-256", 32}, | ||
| {elliptic.P384(), jwt.SigningMethodES384, "ES384", "P-384", 48}, | ||
| {elliptic.P521(), jwt.SigningMethodES512, "ES512", "P-521", 66}, | ||
| } { | ||
| t.Run(tc.expectedCrv, func(t *testing.T) { | ||
| privKey, err := ecdsa.GenerateKey(tc.curve, rand.Reader) | ||
| require.NoError(t, err) | ||
|
|
||
| signingKey, err := newECDSASingingKey(tc.signingMethod, privKey) | ||
| require.NoError(t, err) | ||
|
|
||
| jwk, err := signingKey.ToJWK() | ||
| require.NoError(t, err) | ||
|
|
||
| assert.Equal(t, "EC", jwk["kty"]) | ||
| assert.Equal(t, tc.expectedAlg, jwk["alg"]) | ||
| assert.Equal(t, tc.expectedCrv, jwk["crv"]) | ||
| assert.NotEmpty(t, jwk["kid"]) | ||
|
|
||
| // Verify coordinates are the correct fixed length per RFC 7518 / SEC 1 | ||
| xBytes, err := base64.RawURLEncoding.DecodeString(jwk["x"]) | ||
| require.NoError(t, err) | ||
| assert.Len(t, xBytes, tc.coordLen) | ||
|
|
||
| yBytes, err := base64.RawURLEncoding.DecodeString(jwk["y"]) | ||
| require.NoError(t, err) | ||
| assert.Len(t, yBytes, tc.coordLen) | ||
|
|
||
| // Verify the decoded coordinates reconstruct the original public key point | ||
| pubKey := privKey.Public().(*ecdsa.PublicKey) | ||
| assert.Equal(t, 0, new(big.Int).SetBytes(xBytes).Cmp(pubKey.X)) | ||
| assert.Equal(t, 0, new(big.Int).SetBytes(yBytes).Cmp(pubKey.Y)) | ||
| }) | ||
| } | ||
| } |
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
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
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.