Skip to content

Commit 897a262

Browse files
Copilotreinkrul
andauthored
refactor(dpop): eliminate variable shadowing in Parse() HTU/HTM claim validation (#4117)
* Initial plan * refactor: rename shadowing s variables to htu/htm in Parse() Co-authored-by: reinkrul <1481228+reinkrul@users.noreply.github.com> Agent-Logs-Url: https://github.com/nuts-foundation/nuts-node/sessions/a3558c07-9536-44cd-b10a-74d497ac71f4 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: reinkrul <1481228+reinkrul@users.noreply.github.com>
1 parent d3aac13 commit 897a262

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

crypto/dpop/dpop.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"net/http"
3131
"net/url"
3232
"slices"
33-
"strings"
3433
"time"
3534

3635
"github.com/lestrrat-go/jwx/v2/jwa"
@@ -158,18 +157,18 @@ func Parse(s string) (*DPoP, error) {
158157
}
159158
if v, ok := token.Get(HTUKey); !ok {
160159
return nil, fmt.Errorf("%w: missing htu claim", ErrInvalidDPoP)
161-
} else if s, ok := v.(string); !ok {
160+
} else if htu, ok := v.(string); !ok {
162161
return nil, fmt.Errorf("%w: invalid htu claim", ErrInvalidDPoP)
163-
} else if s == "" {
162+
} else if htu == "" {
164163
return nil, fmt.Errorf("%w: missing htu claim", ErrInvalidDPoP)
165-
} else if _, err := url.Parse(s); err != nil {
164+
} else if _, err := url.Parse(htu); err != nil {
166165
return nil, fmt.Errorf("%w: invalid htu claim: %w", ErrInvalidDPoP, err)
167166
}
168167
if v, ok := token.Get(HTMKey); !ok {
169168
return nil, fmt.Errorf("%w: missing htm claim", ErrInvalidDPoP)
170-
} else if s, ok := v.(string); !ok {
169+
} else if htm, ok := v.(string); !ok {
171170
return nil, fmt.Errorf("%w: invalid htm claim", ErrInvalidDPoP)
172-
} else if s == "" {
171+
} else if htm == "" {
173172
return nil, fmt.Errorf("%w: missing htm claim", ErrInvalidDPoP)
174173
}
175174
if token.JwtID() == "" {

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,6 @@ github.com/nuts-foundation/crypto-ecies v0.0.0-20211207143025-5b84f9efce2b h1:80
398398
github.com/nuts-foundation/crypto-ecies v0.0.0-20211207143025-5b84f9efce2b/go.mod h1:6YUioYirD6/8IahZkoS4Ypc8xbeJW76Xdk1QKcziNTM=
399399
github.com/nuts-foundation/go-did v0.18.0 h1:IB0X8PrzDulpR1zAgDpaHfwoSjJpIhx5u1Tg8I2nnb8=
400400
github.com/nuts-foundation/go-did v0.18.0/go.mod h1:4od1gAmCi9HjHTQGEvHC8pLeuXdXACxidAcdA52YScc=
401-
github.com/nuts-foundation/go-leia/v4 v4.2.0 h1:o/bgYVCyTgsfgtaKmlrcUaJ2z4NwetERC98SUWwYajM=
402-
github.com/nuts-foundation/go-leia/v4 v4.2.0/go.mod h1:Gw6bXqJLOAmHSiXJJYbVoj+Mowp/PoBRywO0ZPsVzA0=
403401
github.com/nuts-foundation/go-leia/v4 v4.3.0 h1:R0qGISIeg2q/PCQTC9cuoBtA6cFu4WBV2DbmSOWKZyM=
404402
github.com/nuts-foundation/go-leia/v4 v4.3.0/go.mod h1:Gw6bXqJLOAmHSiXJJYbVoj+Mowp/PoBRywO0ZPsVzA0=
405403
github.com/nuts-foundation/go-stoabs v1.11.0 h1:q18jVruPdFcVhodDrnKuhq/24i0pUC/YXgzJS0glKUU=

0 commit comments

Comments
 (0)