From 5425584e46d98d8ce2404f739f4c4a6d57738b28 Mon Sep 17 00:00:00 2001 From: arekkas Date: Mon, 4 Dec 2017 13:38:03 +0100 Subject: [PATCH] handler/oauth2: Client IDs in revokation requests must match now --- errors.go | 45 +++++++++++++++-------------- handler.go | 2 +- handler/oauth2/revocation.go | 7 ++++- handler/oauth2/revocation_test.go | 29 +++++++++++++++++-- internal/access_request.go | 14 --------- internal/access_response.go | 14 --------- internal/access_token_storage.go | 14 --------- internal/access_token_strategy.go | 14 --------- internal/authorize_code_storage.go | 14 --------- internal/authorize_code_strategy.go | 14 --------- internal/authorize_handler.go | 14 --------- internal/authorize_request.go | 14 --------- internal/authorize_response.go | 14 --------- internal/client.go | 14 --------- internal/hash.go | 14 --------- internal/id_token_strategy.go | 14 --------- internal/introspector.go | 14 --------- internal/oauth2_client_storage.go | 14 --------- internal/oauth2_owner_storage.go | 14 --------- internal/oauth2_revoke_storage.go | 14 --------- internal/oauth2_storage.go | 14 --------- internal/oauth2_strategy.go | 14 --------- internal/openid_id_token_storage.go | 14 --------- internal/refresh_token_strategy.go | 14 --------- internal/request.go | 14 --------- internal/revoke_handler.go | 22 +++----------- internal/storage.go | 14 --------- internal/token_handler.go | 14 --------- revoke_handler.go | 2 +- revoke_handler_test.go | 10 +++---- 30 files changed, 66 insertions(+), 373 deletions(-) diff --git a/errors.go b/errors.go index f35735fa..4f580faa 100644 --- a/errors.go +++ b/errors.go @@ -21,28 +21,29 @@ import ( ) var ( - ErrRequestUnauthorized = errors.New("The request could not be authorized") - ErrRequestForbidden = errors.New("The request is not allowed") - ErrInvalidRequest = errors.New("The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed") - ErrUnauthorizedClient = errors.New("The client is not authorized to request a token using this method") - ErrAccessDenied = errors.New("The resource owner or authorization server denied the request") - ErrUnsupportedResponseType = errors.New("The authorization server does not support obtaining a token using this method") - ErrInvalidScope = errors.New("The requested scope is invalid, unknown, or malformed") - ErrServerError = errors.New("The authorization server encountered an unexpected condition that prevented it from fulfilling the request") - ErrTemporarilyUnavailable = errors.New("The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server") - ErrUnsupportedGrantType = errors.New("The authorization grant type is not supported by the authorization server") - ErrInvalidGrant = errors.New("The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client") - ErrInvalidClient = errors.New("Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method)") - ErrInvalidState = errors.Errorf("The state is missing or has less than %d characters and is therefore considered too weak", MinParameterEntropy) - ErrInsufficientEntropy = errors.Errorf("The request used a security parameter (e.g., anti-replay, anti-csrf) with insufficient entropy (minimum of %d characters)", MinParameterEntropy) - ErrMisconfiguration = errors.New("The request failed because of an internal error that is probably caused by misconfiguration") - ErrNotFound = errors.New("Could not find the requested resource(s)") - ErrInvalidTokenFormat = errors.New("Invalid token format") - ErrTokenSignatureMismatch = errors.New("Token signature mismatch") - ErrTokenExpired = errors.New("Token expired") - ErrScopeNotGranted = errors.New("The token was not granted the requested scope") - ErrTokenClaim = errors.New("The token failed validation due to a claim mismatch") - ErrInactiveToken = errors.New("Token is inactive because it is malformed, expired or otherwise invalid") + ErrRequestUnauthorized = errors.New("The request could not be authorized") + ErrRequestForbidden = errors.New("The request is not allowed") + ErrInvalidRequest = errors.New("The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed") + ErrUnauthorizedClient = errors.New("The client is not authorized to request a token using this method") + ErrAccessDenied = errors.New("The resource owner or authorization server denied the request") + ErrUnsupportedResponseType = errors.New("The authorization server does not support obtaining a token using this method") + ErrInvalidScope = errors.New("The requested scope is invalid, unknown, or malformed") + ErrServerError = errors.New("The authorization server encountered an unexpected condition that prevented it from fulfilling the request") + ErrTemporarilyUnavailable = errors.New("The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server") + ErrUnsupportedGrantType = errors.New("The authorization grant type is not supported by the authorization server") + ErrInvalidGrant = errors.New("The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client") + ErrInvalidClient = errors.New("Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method)") + ErrInvalidState = errors.Errorf("The state is missing or has less than %d characters and is therefore considered too weak", MinParameterEntropy) + ErrInsufficientEntropy = errors.Errorf("The request used a security parameter (e.g., anti-replay, anti-csrf) with insufficient entropy (minimum of %d characters)", MinParameterEntropy) + ErrMisconfiguration = errors.New("The request failed because of an internal error that is probably caused by misconfiguration") + ErrNotFound = errors.New("Could not find the requested resource(s)") + ErrInvalidTokenFormat = errors.New("Invalid token format") + ErrTokenSignatureMismatch = errors.New("Token signature mismatch") + ErrTokenExpired = errors.New("Token expired") + ErrScopeNotGranted = errors.New("The token was not granted the requested scope") + ErrTokenClaim = errors.New("The token failed validation due to a claim mismatch") + ErrInactiveToken = errors.New("Token is inactive because it is malformed, expired or otherwise invalid") + ErrRevokationClientMismatch = errors.New("Token was not issued to the client making the revokation request") ) const ( diff --git a/handler.go b/handler.go index 984e3024..4e7acaa4 100644 --- a/handler.go +++ b/handler.go @@ -62,5 +62,5 @@ type TokenEndpointHandler interface { // token as well. type RevocationHandler interface { // RevokeToken handles access and refresh token revocation. - RevokeToken(ctx context.Context, token string, tokenType TokenType) error + RevokeToken(ctx context.Context, token string, tokenType TokenType, client Client) error } diff --git a/handler/oauth2/revocation.go b/handler/oauth2/revocation.go index 79d8cab1..b36fd06b 100644 --- a/handler/oauth2/revocation.go +++ b/handler/oauth2/revocation.go @@ -18,6 +18,7 @@ import ( "context" "github.com/ory/fosite" + "github.com/pkg/errors" ) type TokenRevocationHandler struct { @@ -28,7 +29,7 @@ type TokenRevocationHandler struct { // RevokeToken implements https://tools.ietf.org/html/rfc7009#section-2.1 // The token type hint indicates which token type check should be performed first. -func (r *TokenRevocationHandler) RevokeToken(ctx context.Context, token string, tokenType fosite.TokenType) error { +func (r *TokenRevocationHandler) RevokeToken(ctx context.Context, token string, tokenType fosite.TokenType, client fosite.Client) error { discoveryFuncs := []func() (request fosite.Requester, err error){ func() (request fosite.Requester, err error) { // Refresh token @@ -56,6 +57,10 @@ func (r *TokenRevocationHandler) RevokeToken(ctx context.Context, token string, return err } + if ar.GetClient().GetID() != client.GetID() { + return errors.WithStack(fosite.ErrRevokationClientMismatch) + } + requestID := ar.GetID() r.TokenRevocationStorage.RevokeRefreshToken(ctx, requestID) r.TokenRevocationStorage.RevokeAccessToken(ctx, requestID) diff --git a/handler/oauth2/revocation_test.go b/handler/oauth2/revocation_test.go index 57be6632..ce8ce941 100644 --- a/handler/oauth2/revocation_test.go +++ b/handler/oauth2/revocation_test.go @@ -45,16 +45,31 @@ func TestRevokeToken(t *testing.T) { description string mock func() expectErr error + client fosite.Client }{ + { + description: "should fail - token was issued to another client", + expectErr: fosite.ErrRevokationClientMismatch, + client: &fosite.DefaultClient{ID: "bar"}, + mock: func() { + token = "foo" + tokenType = fosite.RefreshToken + rtStrat.EXPECT().RefreshTokenSignature(token) + store.EXPECT().GetRefreshTokenSession(gomock.Any(), gomock.Any(), gomock.Any()).Return(ar, nil) + ar.EXPECT().GetClient().Return(&fosite.DefaultClient{ID: "foo"}) + }, + }, { description: "should pass - refresh token discovery first; refresh token found", expectErr: nil, + client: &fosite.DefaultClient{ID: "bar"}, mock: func() { token = "foo" tokenType = fosite.RefreshToken rtStrat.EXPECT().RefreshTokenSignature(token) store.EXPECT().GetRefreshTokenSession(gomock.Any(), gomock.Any(), gomock.Any()).Return(ar, nil) ar.EXPECT().GetID() + ar.EXPECT().GetClient().Return(&fosite.DefaultClient{ID: "bar"}) store.EXPECT().RevokeRefreshToken(gomock.Any(), gomock.Any()) store.EXPECT().RevokeAccessToken(gomock.Any(), gomock.Any()) }, @@ -62,12 +77,14 @@ func TestRevokeToken(t *testing.T) { { description: "should pass - access token discovery first; access token found", expectErr: nil, + client: &fosite.DefaultClient{ID: "bar"}, mock: func() { token = "foo" tokenType = fosite.AccessToken atStrat.EXPECT().AccessTokenSignature(token) store.EXPECT().GetAccessTokenSession(gomock.Any(), gomock.Any(), gomock.Any()).Return(ar, nil) ar.EXPECT().GetID() + ar.EXPECT().GetClient().Return(&fosite.DefaultClient{ID: "bar"}) store.EXPECT().RevokeRefreshToken(gomock.Any(), gomock.Any()) store.EXPECT().RevokeAccessToken(gomock.Any(), gomock.Any()) }, @@ -75,6 +92,7 @@ func TestRevokeToken(t *testing.T) { { description: "should pass - refresh token discovery first; refresh token not found", expectErr: nil, + client: &fosite.DefaultClient{ID: "bar"}, mock: func() { token = "foo" tokenType = fosite.AccessToken @@ -84,6 +102,7 @@ func TestRevokeToken(t *testing.T) { rtStrat.EXPECT().RefreshTokenSignature(token) store.EXPECT().GetRefreshTokenSession(gomock.Any(), gomock.Any(), gomock.Any()).Return(ar, nil) ar.EXPECT().GetID() + ar.EXPECT().GetClient().Return(&fosite.DefaultClient{ID: "bar"}) store.EXPECT().RevokeRefreshToken(gomock.Any(), gomock.Any()) store.EXPECT().RevokeAccessToken(gomock.Any(), gomock.Any()) }, @@ -91,6 +110,7 @@ func TestRevokeToken(t *testing.T) { { description: "should pass - access token discovery first; access token not found", expectErr: nil, + client: &fosite.DefaultClient{ID: "bar"}, mock: func() { token = "foo" tokenType = fosite.RefreshToken @@ -100,13 +120,15 @@ func TestRevokeToken(t *testing.T) { atStrat.EXPECT().AccessTokenSignature(token) store.EXPECT().GetAccessTokenSession(gomock.Any(), gomock.Any(), gomock.Any()).Return(ar, nil) ar.EXPECT().GetID() + ar.EXPECT().GetClient().Return(&fosite.DefaultClient{ID: "bar"}) store.EXPECT().RevokeRefreshToken(gomock.Any(), gomock.Any()) store.EXPECT().RevokeAccessToken(gomock.Any(), gomock.Any()) }, }, { - description: "should pass - refresh token discovery first; both tokens not found", + description: "should fail - refresh token discovery first; both tokens not found", expectErr: fosite.ErrNotFound, + client: &fosite.DefaultClient{ID: "bar"}, mock: func() { token = "foo" tokenType = fosite.RefreshToken @@ -118,8 +140,9 @@ func TestRevokeToken(t *testing.T) { }, }, { - description: "should pass - access token discovery first; both tokens not found", + description: "should fail - access token discovery first; both tokens not found", expectErr: fosite.ErrNotFound, + client: &fosite.DefaultClient{ID: "bar"}, mock: func() { token = "foo" tokenType = fosite.AccessToken @@ -132,7 +155,7 @@ func TestRevokeToken(t *testing.T) { }, } { c.mock() - err := h.RevokeToken(nil, token, tokenType) + err := h.RevokeToken(nil, token, tokenType, c.client) assert.True(t, errors.Cause(err) == c.expectErr, "(%d) %s\n%s\n%s", k, c.description, err, c.expectErr) t.Logf("Passed test case %d", k) } diff --git a/internal/access_request.go b/internal/access_request.go index 78cf7249..136ab8f9 100644 --- a/internal/access_request.go +++ b/internal/access_request.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: AccessRequester) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/access_response.go b/internal/access_response.go index 53636108..802cdc03 100644 --- a/internal/access_response.go +++ b/internal/access_response.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: AccessResponder) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/access_token_storage.go b/internal/access_token_storage.go index c587dfed..014a6f1e 100644 --- a/internal/access_token_storage.go +++ b/internal/access_token_storage.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/oauth2 (interfaces: AccessTokenStorage) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/access_token_strategy.go b/internal/access_token_strategy.go index 66dfb123..2449ece9 100644 --- a/internal/access_token_strategy.go +++ b/internal/access_token_strategy.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/oauth2 (interfaces: AccessTokenStrategy) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/authorize_code_storage.go b/internal/authorize_code_storage.go index a3836812..6d829abb 100644 --- a/internal/authorize_code_storage.go +++ b/internal/authorize_code_storage.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/oauth2 (interfaces: AuthorizeCodeStorage) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/authorize_code_strategy.go b/internal/authorize_code_strategy.go index 17f64ba2..c2623cc1 100644 --- a/internal/authorize_code_strategy.go +++ b/internal/authorize_code_strategy.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/oauth2 (interfaces: AuthorizeCodeStrategy) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/authorize_handler.go b/internal/authorize_handler.go index a44937f1..9ffac1a9 100644 --- a/internal/authorize_handler.go +++ b/internal/authorize_handler.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: AuthorizeEndpointHandler) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/authorize_request.go b/internal/authorize_request.go index f5abae42..a4393561 100644 --- a/internal/authorize_request.go +++ b/internal/authorize_request.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: AuthorizeRequester) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/authorize_response.go b/internal/authorize_response.go index ddab7e1c..ed4c49b5 100644 --- a/internal/authorize_response.go +++ b/internal/authorize_response.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: AuthorizeResponder) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/client.go b/internal/client.go index 576bc551..42801162 100644 --- a/internal/client.go +++ b/internal/client.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: Client) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/hash.go b/internal/hash.go index 774f9a67..47d4da94 100644 --- a/internal/hash.go +++ b/internal/hash.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: Hasher) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/id_token_strategy.go b/internal/id_token_strategy.go index 0bab466c..22dde672 100644 --- a/internal/id_token_strategy.go +++ b/internal/id_token_strategy.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/openid (interfaces: OpenIDConnectTokenStrategy) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/introspector.go b/internal/introspector.go index 062246a5..4063df7c 100644 --- a/internal/introspector.go +++ b/internal/introspector.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: TokenIntrospector) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/oauth2_client_storage.go b/internal/oauth2_client_storage.go index b35c9c96..6434e119 100644 --- a/internal/oauth2_client_storage.go +++ b/internal/oauth2_client_storage.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/oauth2 (interfaces: ClientCredentialsGrantStorage) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/oauth2_owner_storage.go b/internal/oauth2_owner_storage.go index 694a159d..10737ed4 100644 --- a/internal/oauth2_owner_storage.go +++ b/internal/oauth2_owner_storage.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/oauth2 (interfaces: ResourceOwnerPasswordCredentialsGrantStorage) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/oauth2_revoke_storage.go b/internal/oauth2_revoke_storage.go index 19e61755..b3981a78 100644 --- a/internal/oauth2_revoke_storage.go +++ b/internal/oauth2_revoke_storage.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/oauth2 (interfaces: TokenRevocationStorage) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/oauth2_storage.go b/internal/oauth2_storage.go index 5f04e75c..611882ae 100644 --- a/internal/oauth2_storage.go +++ b/internal/oauth2_storage.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/oauth2 (interfaces: CoreStorage) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/oauth2_strategy.go b/internal/oauth2_strategy.go index 6a03c7ee..198de19e 100644 --- a/internal/oauth2_strategy.go +++ b/internal/oauth2_strategy.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/oauth2 (interfaces: CoreStrategy) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/openid_id_token_storage.go b/internal/openid_id_token_storage.go index a7f71aa1..742856e7 100644 --- a/internal/openid_id_token_storage.go +++ b/internal/openid_id_token_storage.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/openid (interfaces: OpenIDConnectRequestStorage) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/refresh_token_strategy.go b/internal/refresh_token_strategy.go index 2c3897cd..b7422cf4 100644 --- a/internal/refresh_token_strategy.go +++ b/internal/refresh_token_strategy.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite/handler/oauth2 (interfaces: RefreshTokenStrategy) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/request.go b/internal/request.go index 6d0f6836..f908933a 100644 --- a/internal/request.go +++ b/internal/request.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: Requester) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/revoke_handler.go b/internal/revoke_handler.go index 1ca9cfd0..82f9134b 100644 --- a/internal/revoke_handler.go +++ b/internal/revoke_handler.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: RevocationHandler) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( @@ -45,12 +31,12 @@ func (_m *MockRevocationHandler) EXPECT() *_MockRevocationHandlerRecorder { return _m.recorder } -func (_m *MockRevocationHandler) RevokeToken(_param0 context.Context, _param1 string, _param2 fosite.TokenType) error { - ret := _m.ctrl.Call(_m, "RevokeToken", _param0, _param1, _param2) +func (_m *MockRevocationHandler) RevokeToken(_param0 context.Context, _param1 string, _param2 fosite.TokenType, _param3 fosite.Client) error { + ret := _m.ctrl.Call(_m, "RevokeToken", _param0, _param1, _param2, _param3) ret0, _ := ret[0].(error) return ret0 } -func (_mr *_MockRevocationHandlerRecorder) RevokeToken(arg0, arg1, arg2 interface{}) *gomock.Call { - return _mr.mock.ctrl.RecordCall(_mr.mock, "RevokeToken", arg0, arg1, arg2) +func (_mr *_MockRevocationHandlerRecorder) RevokeToken(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + return _mr.mock.ctrl.RecordCall(_mr.mock, "RevokeToken", arg0, arg1, arg2, arg3) } diff --git a/internal/storage.go b/internal/storage.go index c5a0a5d5..8b9d6dae 100644 --- a/internal/storage.go +++ b/internal/storage.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: Storage) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/internal/token_handler.go b/internal/token_handler.go index e472176a..d835568b 100644 --- a/internal/token_handler.go +++ b/internal/token_handler.go @@ -1,20 +1,6 @@ // Automatically generated by MockGen. DO NOT EDIT! // Source: github.com/ory/fosite (interfaces: TokenEndpointHandler) -// Copyright © 2017 Aeneas Rekkas -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package internal import ( diff --git a/revoke_handler.go b/revoke_handler.go index aa349c06..b53438b1 100644 --- a/revoke_handler.go +++ b/revoke_handler.go @@ -70,7 +70,7 @@ func (f *Fosite) NewRevocationRequest(ctx context.Context, r *http.Request) erro var found bool for _, loader := range f.RevocationHandlers { - if err := loader.RevokeToken(ctx, token, tokenTypeHint); err == nil { + if err := loader.RevokeToken(ctx, token, tokenTypeHint, client); err == nil { found = true } else if errors.Cause(err) == ErrUnknownRequest { // do nothing diff --git a/revoke_handler_test.go b/revoke_handler_test.go index d95c25a9..697366b4 100644 --- a/revoke_handler_test.go +++ b/revoke_handler_test.go @@ -108,7 +108,7 @@ func TestNewRevocationRequest(t *testing.T) { client.EXPECT().GetHashedSecret().Return([]byte("foo")) client.EXPECT().IsPublic().Return(false) hasher.EXPECT().Compare(gomock.Eq([]byte("foo")), gomock.Eq([]byte("bar"))).Return(nil) - handler.EXPECT().RevokeToken(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + handler.EXPECT().RevokeToken(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) }, handlers: RevocationHandlers{handler}, }, @@ -127,7 +127,7 @@ func TestNewRevocationRequest(t *testing.T) { client.EXPECT().GetHashedSecret().Return([]byte("foo")) client.EXPECT().IsPublic().Return(false) hasher.EXPECT().Compare(gomock.Eq([]byte("foo")), gomock.Eq([]byte("bar"))).Return(nil) - handler.EXPECT().RevokeToken(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + handler.EXPECT().RevokeToken(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) }, handlers: RevocationHandlers{handler}, }, @@ -145,7 +145,7 @@ func TestNewRevocationRequest(t *testing.T) { store.EXPECT().GetClient(gomock.Any(), gomock.Eq("foo")).Return(client, nil) client.EXPECT().IsPublic().Return(true) hasher.EXPECT().Compare(gomock.Eq([]byte("foo")), gomock.Eq([]byte("bar"))).Return(nil) - handler.EXPECT().RevokeToken(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + handler.EXPECT().RevokeToken(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) }, handlers: RevocationHandlers{handler}, }, @@ -163,7 +163,7 @@ func TestNewRevocationRequest(t *testing.T) { store.EXPECT().GetClient(gomock.Any(), gomock.Eq("foo")).Return(client, nil) client.EXPECT().GetHashedSecret().Return([]byte("foo")) client.EXPECT().IsPublic().Return(false) - handler.EXPECT().RevokeToken(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + handler.EXPECT().RevokeToken(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) }, handlers: RevocationHandlers{handler}, }, @@ -182,7 +182,7 @@ func TestNewRevocationRequest(t *testing.T) { client.EXPECT().GetHashedSecret().Return([]byte("foo")) client.EXPECT().IsPublic().Return(false) hasher.EXPECT().Compare(gomock.Eq([]byte("foo")), gomock.Eq([]byte("bar"))).Return(nil) - handler.EXPECT().RevokeToken(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + handler.EXPECT().RevokeToken(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) }, handlers: RevocationHandlers{handler}, },