pkg/op: Replace interface{} with any

Signed-off-by: Thomas Hipp <thomashipp@gmail.com>
This commit is contained in:
Thomas Hipp 2023-09-26 19:55:32 +02:00
parent 868cf39632
commit e948bed16e
No known key found for this signature in database
GPG key ID: 36F3DB891755E09B
6 changed files with 19 additions and 19 deletions

View file

@ -501,7 +501,7 @@ func BuildAuthRequestCode(authReq AuthRequest, crypto Crypto) (string, error) {
// AuthResponseURL encodes the authorization response (successful and error) and sets it as query or fragment values // AuthResponseURL encodes the authorization response (successful and error) and sets it as query or fragment values
// depending on the response_mode and response_type // depending on the response_mode and response_type
func AuthResponseURL(redirectURI string, responseType oidc.ResponseType, responseMode oidc.ResponseMode, response interface{}, encoder httphelper.Encoder) (string, error) { func AuthResponseURL(redirectURI string, responseType oidc.ResponseType, responseMode oidc.ResponseMode, response any, encoder httphelper.Encoder) (string, error) {
uri, err := url.Parse(redirectURI) uri, err := url.Parse(redirectURI)
if err != nil { if err != nil {
return "", oidc.ErrServerError().WithParent(err) return "", oidc.ErrServerError().WithParent(err)

View file

@ -745,7 +745,7 @@ func TestAuthResponseURL(t *testing.T) {
redirectURI string redirectURI string
responseType oidc.ResponseType responseType oidc.ResponseType
responseMode oidc.ResponseMode responseMode oidc.ResponseMode
response interface{} response any
encoder httphelper.Encoder encoder httphelper.Encoder
} }
type res struct { type res struct {
@ -763,7 +763,7 @@ func TestAuthResponseURL(t *testing.T) {
"uri", "uri",
oidc.ResponseTypeCode, oidc.ResponseTypeCode,
"", "",
map[string]interface{}{"test": "test"}, map[string]any{"test": "test"},
&mockEncoder{ &mockEncoder{
errors.New("error encoding"), errors.New("error encoding"),
}, },
@ -934,7 +934,7 @@ type mockEncoder struct {
err error err error
} }
func (m *mockEncoder) Encode(src interface{}, dst map[string][]string) error { func (m *mockEncoder) Encode(src any, dst map[string][]string) error {
if m.err != nil { if m.err != nil {
return m.err return m.err
} }

View file

@ -10,7 +10,7 @@ var ErrSignerCreationFailed = errors.New("signer creation failed")
type SigningKey interface { type SigningKey interface {
SignatureAlgorithm() jose.SignatureAlgorithm SignatureAlgorithm() jose.SignatureAlgorithm
Key() interface{} Key() any
ID() string ID() string
} }
@ -32,5 +32,5 @@ type Key interface {
ID() string ID() string
Algorithm() jose.SignatureAlgorithm Algorithm() jose.SignatureAlgorithm
Use() string Use() string
Key() interface{} Key() any
} }

View file

@ -100,7 +100,7 @@ type TokenExchangeStorage interface {
// GetPrivateClaimsFromTokenExchangeRequest will be called during access token creation. // GetPrivateClaimsFromTokenExchangeRequest will be called during access token creation.
// Claims evaluation can be based on all validated request data available, including: scopes, resource, audience, etc. // Claims evaluation can be based on all validated request data available, including: scopes, resource, audience, etc.
GetPrivateClaimsFromTokenExchangeRequest(ctx context.Context, request TokenExchangeRequest) (claims map[string]interface{}, err error) GetPrivateClaimsFromTokenExchangeRequest(ctx context.Context, request TokenExchangeRequest) (claims map[string]any, err error)
// SetUserinfoFromTokenExchangeRequest will be called during id token creation. // SetUserinfoFromTokenExchangeRequest will be called during id token creation.
// Claims evaluation can be based on all validated request data available, including: scopes, resource, audience, etc. // Claims evaluation can be based on all validated request data available, including: scopes, resource, audience, etc.
@ -110,8 +110,8 @@ type TokenExchangeStorage interface {
// TokenExchangeTokensVerifierStorage is an optional interface used in token exchange process to verify tokens // TokenExchangeTokensVerifierStorage is an optional interface used in token exchange process to verify tokens
// issued by third-party applications. If interface is not implemented - only tokens issued by op will be exchanged. // issued by third-party applications. If interface is not implemented - only tokens issued by op will be exchanged.
type TokenExchangeTokensVerifierStorage interface { type TokenExchangeTokensVerifierStorage interface {
VerifyExchangeSubjectToken(ctx context.Context, token string, tokenType oidc.TokenType) (tokenIDOrToken string, subject string, tokenClaims map[string]interface{}, err error) VerifyExchangeSubjectToken(ctx context.Context, token string, tokenType oidc.TokenType) (tokenIDOrToken string, subject string, tokenClaims map[string]any, err error)
VerifyExchangeActorToken(ctx context.Context, token string, tokenType oidc.TokenType) (tokenIDOrToken string, actor string, tokenClaims map[string]interface{}, err error) VerifyExchangeActorToken(ctx context.Context, token string, tokenType oidc.TokenType) (tokenIDOrToken string, actor string, tokenClaims map[string]any, err error)
} }
var ErrInvalidRefreshToken = errors.New("invalid_refresh_token") var ErrInvalidRefreshToken = errors.New("invalid_refresh_token")
@ -126,7 +126,7 @@ type OPStorage interface {
SetUserinfoFromScopes(ctx context.Context, userinfo *oidc.UserInfo, userID, clientID string, scopes []string) error SetUserinfoFromScopes(ctx context.Context, userinfo *oidc.UserInfo, userID, clientID string, scopes []string) error
SetUserinfoFromToken(ctx context.Context, userinfo *oidc.UserInfo, tokenID, subject, origin string) error SetUserinfoFromToken(ctx context.Context, userinfo *oidc.UserInfo, tokenID, subject, origin string) error
SetIntrospectionFromToken(ctx context.Context, userinfo *oidc.IntrospectionResponse, tokenID, subject, clientID string) error SetIntrospectionFromToken(ctx context.Context, userinfo *oidc.IntrospectionResponse, tokenID, subject, clientID string) error
GetPrivateClaimsFromScopes(ctx context.Context, userID, clientID string, scopes []string) (map[string]interface{}, error) GetPrivateClaimsFromScopes(ctx context.Context, userID, clientID string, scopes []string) (map[string]any, error)
GetKeyByIDAndClientID(ctx context.Context, keyID, clientID string) (*jose.JSONWebKey, error) GetKeyByIDAndClientID(ctx context.Context, keyID, clientID string) (*jose.JSONWebKey, error)
ValidateJWTProfileScopes(ctx context.Context, userID string, scopes []string) ([]string, error) ValidateJWTProfileScopes(ctx context.Context, userID string, scopes []string) ([]string, error)
} }

View file

@ -122,7 +122,7 @@ func CreateJWT(ctx context.Context, issuer string, tokenRequest TokenRequest, ex
restrictedScopes := client.RestrictAdditionalAccessTokenScopes()(tokenRequest.GetScopes()) restrictedScopes := client.RestrictAdditionalAccessTokenScopes()(tokenRequest.GetScopes())
var ( var (
privateClaims map[string]interface{} privateClaims map[string]any
err error err error
) )

View file

@ -24,12 +24,12 @@ type TokenExchangeRequest interface {
GetExchangeSubject() string GetExchangeSubject() string
GetExchangeSubjectTokenType() oidc.TokenType GetExchangeSubjectTokenType() oidc.TokenType
GetExchangeSubjectTokenIDOrToken() string GetExchangeSubjectTokenIDOrToken() string
GetExchangeSubjectTokenClaims() map[string]interface{} GetExchangeSubjectTokenClaims() map[string]any
GetExchangeActor() string GetExchangeActor() string
GetExchangeActorTokenType() oidc.TokenType GetExchangeActorTokenType() oidc.TokenType
GetExchangeActorTokenIDOrToken() string GetExchangeActorTokenIDOrToken() string
GetExchangeActorTokenClaims() map[string]interface{} GetExchangeActorTokenClaims() map[string]any
SetCurrentScopes(scopes []string) SetCurrentScopes(scopes []string)
SetRequestedTokenType(tt oidc.TokenType) SetRequestedTokenType(tt oidc.TokenType)
@ -40,12 +40,12 @@ type tokenExchangeRequest struct {
exchangeSubjectTokenIDOrToken string exchangeSubjectTokenIDOrToken string
exchangeSubjectTokenType oidc.TokenType exchangeSubjectTokenType oidc.TokenType
exchangeSubject string exchangeSubject string
exchangeSubjectTokenClaims map[string]interface{} exchangeSubjectTokenClaims map[string]any
exchangeActorTokenIDOrToken string exchangeActorTokenIDOrToken string
exchangeActorTokenType oidc.TokenType exchangeActorTokenType oidc.TokenType
exchangeActor string exchangeActor string
exchangeActorTokenClaims map[string]interface{} exchangeActorTokenClaims map[string]any
resource []string resource []string
audience oidc.Audience audience oidc.Audience
@ -96,7 +96,7 @@ func (r *tokenExchangeRequest) GetExchangeSubjectTokenIDOrToken() string {
return r.exchangeSubjectTokenIDOrToken return r.exchangeSubjectTokenIDOrToken
} }
func (r *tokenExchangeRequest) GetExchangeSubjectTokenClaims() map[string]interface{} { func (r *tokenExchangeRequest) GetExchangeSubjectTokenClaims() map[string]any {
return r.exchangeSubjectTokenClaims return r.exchangeSubjectTokenClaims
} }
@ -112,7 +112,7 @@ func (r *tokenExchangeRequest) GetExchangeActorTokenIDOrToken() string {
return r.exchangeActorTokenIDOrToken return r.exchangeActorTokenIDOrToken
} }
func (r *tokenExchangeRequest) GetExchangeActorTokenClaims() map[string]interface{} { func (r *tokenExchangeRequest) GetExchangeActorTokenClaims() map[string]any {
return r.exchangeActorTokenClaims return r.exchangeActorTokenClaims
} }
@ -232,7 +232,7 @@ func ValidateTokenExchangeRequest(
var ( var (
exchangeActorTokenIDOrToken, exchangeActor string exchangeActorTokenIDOrToken, exchangeActor string
exchangeActorTokenClaims map[string]interface{} exchangeActorTokenClaims map[string]any
) )
if oidcTokenExchangeRequest.ActorToken != "" { if oidcTokenExchangeRequest.ActorToken != "" {
exchangeActorTokenIDOrToken, exchangeActor, exchangeActorTokenClaims, ok = GetTokenIDAndSubjectFromToken(ctx, exchanger, exchangeActorTokenIDOrToken, exchangeActor, exchangeActorTokenClaims, ok = GetTokenIDAndSubjectFromToken(ctx, exchanger,
@ -281,7 +281,7 @@ func GetTokenIDAndSubjectFromToken(
token string, token string,
tokenType oidc.TokenType, tokenType oidc.TokenType,
isActor bool, isActor bool,
) (tokenIDOrToken, subject string, claims map[string]interface{}, ok bool) { ) (tokenIDOrToken, subject string, claims map[string]any, ok bool) {
switch tokenType { switch tokenType {
case oidc.AccessTokenType: case oidc.AccessTokenType:
var accessTokenClaims *oidc.AccessTokenClaims var accessTokenClaims *oidc.AccessTokenClaims