chore: updating go to 1.24 (#726)
* chore: updating go to 1.24 * fixup! chore: updating go to 1.24 * fixup! fixup! chore: updating go to 1.24 * fix device test (drop read error) * drop older go versions * drop unrelated formatter changes --------- Co-authored-by: Iraq Jaber <IraqJaber@gmail.com> Co-authored-by: Tim Möhlmann <tim+github@zitadel.com>
This commit is contained in:
parent
efd6fdad7a
commit
2c64de821d
5 changed files with 16 additions and 27 deletions
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
@ -18,7 +18,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
go: ['1.21', '1.22', '1.23']
|
go: ['1.23', '1.24']
|
||||||
name: Go ${{ matrix.go }} test
|
name: Go ${{ matrix.go }} test
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
|
@ -156,10 +156,9 @@ Versions that also build are marked with :warning:.
|
||||||
|
|
||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
| ------- | ------------------ |
|
| ------- | ------------------ |
|
||||||
| <1.21 | :x: |
|
| <1.23 | :x: |
|
||||||
| 1.21 | :warning: |
|
|
||||||
| 1.22 | :white_check_mark: |
|
|
||||||
| 1.23 | :white_check_mark: |
|
| 1.23 | :white_check_mark: |
|
||||||
|
| 1.24 | :white_check_mark: |
|
||||||
|
|
||||||
## Why another library
|
## Why another library
|
||||||
|
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
||||||
module github.com/zitadel/oidc/v3
|
module github.com/zitadel/oidc/v3
|
||||||
|
|
||||||
go 1.21
|
go 1.23.7
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bmatcuk/doublestar/v4 v4.8.1
|
github.com/bmatcuk/doublestar/v4 v4.8.1
|
||||||
|
|
|
@ -91,10 +91,7 @@ func createDeviceAuthorization(ctx context.Context, req *oidc.DeviceAuthorizatio
|
||||||
}
|
}
|
||||||
config := o.DeviceAuthorization()
|
config := o.DeviceAuthorization()
|
||||||
|
|
||||||
deviceCode, err := NewDeviceCode(RecommendedDeviceCodeBytes)
|
deviceCode, _ := NewDeviceCode(RecommendedDeviceCodeBytes)
|
||||||
if err != nil {
|
|
||||||
return nil, NewStatusError(err, http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
userCode, err := NewUserCode([]rune(config.UserCode.CharSet), config.UserCode.CharAmount, config.UserCode.DashInterval)
|
userCode, err := NewUserCode([]rune(config.UserCode.CharSet), config.UserCode.CharAmount, config.UserCode.DashInterval)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, NewStatusError(err, http.StatusInternalServerError)
|
return nil, NewStatusError(err, http.StatusInternalServerError)
|
||||||
|
@ -163,11 +160,14 @@ func ParseDeviceCodeRequest(r *http.Request, o OpenIDProvider) (*oidc.DeviceAuth
|
||||||
// results in a 22 character base64 encoded string.
|
// results in a 22 character base64 encoded string.
|
||||||
const RecommendedDeviceCodeBytes = 16
|
const RecommendedDeviceCodeBytes = 16
|
||||||
|
|
||||||
|
// NewDeviceCode generates a new cryptographically secure device code as a base64 encoded string.
|
||||||
|
// The length of the string is nBytes * 4 / 3.
|
||||||
|
// An error is never returned.
|
||||||
|
//
|
||||||
|
// TODO(v4): change return type to string alone.
|
||||||
func NewDeviceCode(nBytes int) (string, error) {
|
func NewDeviceCode(nBytes int) (string, error) {
|
||||||
bytes := make([]byte, nBytes)
|
bytes := make([]byte, nBytes)
|
||||||
if _, err := rand.Read(bytes); err != nil {
|
rand.Read(bytes)
|
||||||
return "", fmt.Errorf("%w getting entropy for device code", err)
|
|
||||||
}
|
|
||||||
return base64.RawURLEncoding.EncodeToString(bytes), nil
|
return base64.RawURLEncoding.EncodeToString(bytes), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,21 +145,11 @@ func runWithRandReader(r io.Reader, f func()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewDeviceCode(t *testing.T) {
|
func TestNewDeviceCode(t *testing.T) {
|
||||||
t.Run("reader error", func(t *testing.T) {
|
|
||||||
runWithRandReader(errReader{}, func() {
|
|
||||||
_, err := op.NewDeviceCode(16)
|
|
||||||
require.Error(t, err)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("different lengths, rand reader", func(t *testing.T) {
|
|
||||||
for i := 1; i <= 32; i++ {
|
for i := 1; i <= 32; i++ {
|
||||||
got, err := op.NewDeviceCode(i)
|
got, err := op.NewDeviceCode(i)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Len(t, got, base64.RawURLEncoding.EncodedLen(i))
|
assert.Len(t, got, base64.RawURLEncoding.EncodedLen(i))
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewUserCode(t *testing.T) {
|
func TestNewUserCode(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue