chore: replace interface{}
with any
(#448)
This PR replaces all occurances of interface{} with any to be consistent and improve readability. * example: Replace `interface{}` with `any` Signed-off-by: Thomas Hipp <thomashipp@gmail.com> * pkg/client: Replace `interface{}` with `any` Signed-off-by: Thomas Hipp <thomashipp@gmail.com> * pkg/crypto: Replace `interface{}` with `any` Signed-off-by: Thomas Hipp <thomashipp@gmail.com> * pkg/http: Replace `interface{}` with `any` Signed-off-by: Thomas Hipp <thomashipp@gmail.com> * pkg/oidc: Replace `interface{}` with `any` Signed-off-by: Thomas Hipp <thomashipp@gmail.com> * pkg/op: Replace `interface{}` with `any` Signed-off-by: Thomas Hipp <thomashipp@gmail.com> --------- Signed-off-by: Thomas Hipp <thomashipp@gmail.com>
This commit is contained in:
parent
ceaf2b184d
commit
e6e3835362
25 changed files with 83 additions and 83 deletions
|
@ -151,7 +151,7 @@ func (e *Error) WithParent(err error) *Error {
|
|||
return e
|
||||
}
|
||||
|
||||
func (e *Error) WithDescription(desc string, args ...interface{}) *Error {
|
||||
func (e *Error) WithDescription(desc string, args ...any) *Error {
|
||||
e.Description = fmt.Sprintf(desc, args...)
|
||||
return e
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ func GetKeyIDAndAlg(jws *jose.JSONWebSignature) (string, string) {
|
|||
//
|
||||
// will return false none or multiple match
|
||||
//
|
||||
//deprecated: use FindMatchingKey which will return an error (more specific) instead of just a bool
|
||||
//moved implementation already to FindMatchingKey
|
||||
// deprecated: use FindMatchingKey which will return an error (more specific) instead of just a bool
|
||||
// moved implementation already to FindMatchingKey
|
||||
func FindKey(keyID, use, expectedAlg string, keys ...jose.JSONWebKey) (jose.JSONWebKey, bool) {
|
||||
key, err := FindMatchingKey(keyID, use, expectedAlg, keys...)
|
||||
return key, err == nil
|
||||
|
@ -91,7 +91,7 @@ func FindMatchingKey(keyID, use, expectedAlg string, keys ...jose.JSONWebKey) (k
|
|||
return key, ErrKeyNone
|
||||
}
|
||||
|
||||
func algToKeyType(key interface{}, alg string) bool {
|
||||
func algToKeyType(key any, alg string) bool {
|
||||
switch alg[0] {
|
||||
case 'R', 'P':
|
||||
_, ok := key.(*rsa.PublicKey)
|
||||
|
|
|
@ -17,7 +17,7 @@ const dataDir = "regression_data"
|
|||
|
||||
// jsonFilename builds a filename for the regression testdata.
|
||||
// dataDir/<type_name>.json
|
||||
func jsonFilename(obj interface{}) string {
|
||||
func jsonFilename(obj any) string {
|
||||
name := fmt.Sprintf("%T.json", obj)
|
||||
return path.Join(
|
||||
dataDir,
|
||||
|
@ -25,13 +25,13 @@ func jsonFilename(obj interface{}) string {
|
|||
)
|
||||
}
|
||||
|
||||
func encodeJSON(t *testing.T, w io.Writer, obj interface{}) {
|
||||
func encodeJSON(t *testing.T, w io.Writer, obj any) {
|
||||
enc := json.NewEncoder(w)
|
||||
enc.SetIndent("", "\t")
|
||||
require.NoError(t, enc.Encode(obj))
|
||||
}
|
||||
|
||||
var regressionData = []interface{}{
|
||||
var regressionData = []any{
|
||||
accessTokenData,
|
||||
idTokenData,
|
||||
introspectionResponseData,
|
||||
|
|
|
@ -222,7 +222,7 @@ type JWTProfileAssertionClaims struct {
|
|||
Expiration Time `json:"exp"`
|
||||
IssuedAt Time `json:"iat"`
|
||||
|
||||
Claims map[string]interface{} `json:"-"`
|
||||
Claims map[string]any `json:"-"`
|
||||
}
|
||||
|
||||
type jpaAlias JWTProfileAssertionClaims
|
||||
|
@ -262,7 +262,7 @@ func JWTProfileDelegatedSubject(sub string) func(*JWTProfileAssertionClaims) {
|
|||
}
|
||||
}
|
||||
|
||||
func JWTProfileCustomClaim(key string, value interface{}) func(*JWTProfileAssertionClaims) {
|
||||
func JWTProfileCustomClaim(key string, value any) func(*JWTProfileAssertionClaims) {
|
||||
return func(j *JWTProfileAssertionClaims) {
|
||||
j.Claims[key] = value
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ func NewJWTProfileAssertion(userID, keyID string, audience []string, key []byte,
|
|||
IssuedAt: FromTime(time.Now().UTC()),
|
||||
Expiration: FromTime(time.Now().Add(1 * time.Hour).UTC()),
|
||||
Audience: audience,
|
||||
Claims: make(map[string]interface{}),
|
||||
Claims: make(map[string]any),
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
|
|
|
@ -130,7 +130,7 @@ type JWTTokenRequest struct {
|
|||
IssuedAt Time `json:"iat"`
|
||||
ExpiresAt Time `json:"exp"`
|
||||
|
||||
private map[string]interface{}
|
||||
private map[string]any
|
||||
}
|
||||
|
||||
func (j *JWTTokenRequest) MarshalJSON() ([]byte, error) {
|
||||
|
@ -171,7 +171,7 @@ func (j *JWTTokenRequest) UnmarshalJSON(data []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (j *JWTTokenRequest) GetCustomClaim(key string) interface{} {
|
||||
func (j *JWTTokenRequest) GetCustomClaim(key string) any {
|
||||
return j.private[key]
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ var (
|
|||
accessTokenData = &AccessTokenClaims{
|
||||
TokenClaims: tokenClaimsData,
|
||||
Scopes: []string{"email", "phone"},
|
||||
Claims: map[string]interface{}{
|
||||
Claims: map[string]any{
|
||||
"foo": "bar",
|
||||
},
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ var (
|
|||
UserInfoEmail: userInfoData.UserInfoEmail,
|
||||
UserInfoPhone: userInfoData.UserInfoPhone,
|
||||
Address: userInfoData.Address,
|
||||
Claims: map[string]interface{}{
|
||||
Claims: map[string]any{
|
||||
"foo": "bar",
|
||||
},
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ var (
|
|||
UserInfoEmail: userInfoData.UserInfoEmail,
|
||||
UserInfoPhone: userInfoData.UserInfoPhone,
|
||||
Address: userInfoData.Address,
|
||||
Claims: map[string]interface{}{
|
||||
Claims: map[string]any{
|
||||
"foo": "bar",
|
||||
},
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ var (
|
|||
PostalCode: "666-666",
|
||||
Country: "Moon",
|
||||
},
|
||||
Claims: map[string]interface{}{
|
||||
Claims: map[string]any{
|
||||
"foo": "bar",
|
||||
},
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ var (
|
|||
Audience: Audience{"foo", "bar"},
|
||||
Expiration: 12345,
|
||||
IssuedAt: 12000,
|
||||
Claims: map[string]interface{}{
|
||||
Claims: map[string]any{
|
||||
"foo": "bar",
|
||||
},
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ func TestIDTokenClaims_SetUserInfo(t *testing.T) {
|
|||
UserInfoEmail: userInfoData.UserInfoEmail,
|
||||
UserInfoPhone: userInfoData.UserInfoPhone,
|
||||
Address: userInfoData.Address,
|
||||
Claims: map[string]interface{}{
|
||||
Claims: map[string]any{
|
||||
"foo": "bar",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@ import (
|
|||
type Audience []string
|
||||
|
||||
func (a *Audience) UnmarshalJSON(text []byte) error {
|
||||
var i interface{}
|
||||
var i any
|
||||
err := json.Unmarshal(text, &i)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch aud := i.(type) {
|
||||
case []interface{}:
|
||||
case []any:
|
||||
*a = make([]string, len(aud))
|
||||
for i, audience := range aud {
|
||||
(*a)[i] = audience.(string)
|
||||
|
@ -177,7 +177,7 @@ func (s *SpaceDelimitedArray) UnmarshalJSON(data []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *SpaceDelimitedArray) Scan(src interface{}) error {
|
||||
func (s *SpaceDelimitedArray) Scan(src any) error {
|
||||
if src == nil {
|
||||
*s = nil
|
||||
return nil
|
||||
|
|
|
@ -85,7 +85,7 @@ func DecryptToken(tokenString string) (string, error) {
|
|||
return tokenString, nil // TODO: impl
|
||||
}
|
||||
|
||||
func ParseToken(tokenString string, claims interface{}) ([]byte, error) {
|
||||
func ParseToken(tokenString string, claims any) ([]byte, error) {
|
||||
parts := strings.Split(tokenString, ".")
|
||||
if len(parts) != 3 {
|
||||
return nil, fmt.Errorf("%w: token contains an invalid number of segments", ErrParse)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue