diff --git a/pkg/oidc/token_request.go b/pkg/oidc/token_request.go index 800c515..e80d28a 100644 --- a/pkg/oidc/token_request.go +++ b/pkg/oidc/token_request.go @@ -43,7 +43,7 @@ type JWTTokenRequest struct { ExpiresAt Time `json:"exp"` } -//GetSubject implements the Claims interface +//GetIssuer implements the Claims interface func (j *JWTTokenRequest) GetIssuer() string { return j.Issuer } diff --git a/pkg/op/storage.go b/pkg/op/storage.go index e220c15..eba5003 100644 --- a/pkg/op/storage.go +++ b/pkg/op/storage.go @@ -26,11 +26,11 @@ type AuthStorage interface { } type OPStorage interface { - GetClientByClientID(context.Context, string) (Client, error) - AuthorizeClientIDSecret(context.Context, string, string) error - GetUserinfoFromScopes(context.Context, string, string, []string) (oidc.UserInfo, error) + GetClientByClientID(ctx context.Context, clientID string) (Client, error) + AuthorizeClientIDSecret(ctx context.Context, clientID, clientSecret string) error + GetUserinfoFromScopes(ctx context.Context, userID, clientID string, scopes []string) (oidc.UserInfo, error) GetUserinfoFromToken(ctx context.Context, tokenID, subject, origin string) (oidc.UserInfo, error) - GetPrivateClaimsFromScopes(context.Context, string, string, []string) (map[string]interface{}, error) + GetPrivateClaimsFromScopes(ctx context.Context, userID, clientID string, scopes []string) (map[string]interface{}, error) GetKeyByIDAndUserID(ctx context.Context, keyID, userID string) (*jose.JSONWebKey, error) } diff --git a/pkg/utils/marshal_test.go b/pkg/utils/marshal_test.go new file mode 100644 index 0000000..f9221f6 --- /dev/null +++ b/pkg/utils/marshal_test.go @@ -0,0 +1,60 @@ +package utils + +import ( + "bytes" + "testing" +) + +func TestConcatenateJSON(t *testing.T) { + type args struct { + first []byte + second []byte + } + tests := []struct { + name string + args args + want []byte + wantErr bool + }{ + { + "invalid first part, error", + args{ + []byte(`invalid`), + []byte(`{"some": "thing"}`), + }, + nil, + true, + }, + { + "invalid second part, error", + args{ + []byte(`{"some": "thing"}`), + []byte(`invalid`), + }, + nil, + true, + }, + { + "both valid, merged", + args{ + []byte(`{"some": "thing"}`), + []byte(`{"another": "thing"}`), + }, + + []byte(`{"some": "thing","another": "thing"}`), + false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := ConcatenateJSON(tt.args.first, tt.args.second) + if (err != nil) != tt.wantErr { + t.Errorf("ConcatenateJSON() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !bytes.Equal(got, tt.want) { + t.Errorf("ConcatenateJSON() got = %v, want %v", got, tt.want) + } + }) + } +}