From 211b43b4c04c732adc5fbfa7cab339f44fbea7d7 Mon Sep 17 00:00:00 2001 From: aeneasr Date: Wed, 24 Oct 2018 14:13:57 +0200 Subject: [PATCH] all: Rearrange commits with goreturns Signed-off-by: aeneasr --- access_error_test.go | 8 ++--- access_request_handler_test.go | 8 ++--- access_response_test.go | 3 +- access_response_writer_test.go | 9 +++--- access_write_test.go | 6 ++-- authorize_error_test.go | 6 ++-- authorize_request_handler.go | 7 ++--- authorize_request_handler_test.go | 11 ++++--- authorize_response_writer.go | 3 +- authorize_response_writer_test.go | 8 ++--- authorize_write_test.go | 3 +- client_authentication_jwks_strategy_test.go | 5 ++-- client_authentication_test.go | 10 +++---- compose/compose.go | 2 +- compose/compose_pkce.go | 6 ++-- fosite_test.go | 5 ++-- handler/oauth2/flow_authorize_code_auth.go | 4 +-- .../oauth2/flow_authorize_code_auth_test.go | 6 ++-- handler/oauth2/flow_authorize_code_token.go | 3 +- .../oauth2/flow_authorize_code_token_test.go | 14 +++------ handler/oauth2/flow_authorize_implicit.go | 6 ++-- .../oauth2/flow_authorize_implicit_test.go | 8 ++--- handler/oauth2/flow_client_credentials.go | 3 +- .../oauth2/flow_client_credentials_test.go | 6 ++-- handler/oauth2/flow_refresh.go | 3 +- handler/oauth2/flow_refresh_test.go | 5 ++-- handler/oauth2/flow_resource_owner.go | 4 +-- handler/oauth2/flow_resource_owner_test.go | 8 ++--- handler/oauth2/helper.go | 3 +- handler/oauth2/helper_test.go | 5 ++-- handler/oauth2/introspector.go | 3 +- handler/oauth2/introspector_jwt.go | 3 +- handler/oauth2/introspector_jwt_test.go | 6 ++-- handler/oauth2/introspector_test.go | 5 ++-- handler/oauth2/revocation.go | 3 +- handler/oauth2/revocation_test.go | 6 ++-- handler/oauth2/strategy_hmacsha.go | 4 +-- handler/oauth2/strategy_hmacsha_test.go | 4 +-- handler/oauth2/strategy_jwt.go | 6 ++-- handler/oauth2/strategy_jwt_session.go | 1 + handler/oauth2/strategy_jwt_test.go | 6 ++-- handler/openid/flow_explicit_auth.go | 3 +- handler/openid/flow_explicit_auth_test.go | 8 ++--- handler/openid/flow_explicit_token.go | 3 +- handler/openid/flow_explicit_token_test.go | 16 +++++----- handler/openid/flow_hybrid.go | 3 +- handler/openid/flow_hybrid_test.go | 11 ++++--- handler/openid/flow_implicit.go | 3 +- handler/openid/flow_implicit_test.go | 9 +++--- handler/openid/flow_refresh_token.go | 3 +- handler/openid/flow_refresh_token_test.go | 11 +++---- handler/openid/helper_test.go | 5 ++-- handler/openid/strategy_jwt.go | 10 ++++--- handler/openid/strategy_jwt_test.go | 7 ++--- handler/openid/validator.go | 8 ++--- handler/openid/validator_test.go | 7 ++--- handler/pkce/handler.go | 3 +- handler/pkce/handler_test.go | 7 +++-- hash_bcrypt_test.go | 3 +- ...rize_code_grant_public_client_pkce_test.go | 20 +++++-------- ...authorize_code_grant_public_client_test.go | 11 ++++--- integration/authorize_code_grant_test.go | 11 ++++--- integration/authorize_implicit_grant_test.go | 10 +++---- integration/client_credentials_grant_test.go | 7 +++-- integration/helper_endpoints_test.go | 5 ++-- integration/helper_setup_test.go | 5 ++-- integration/introspect_token_test.go | 11 ++++--- integration/oidc_explicit_test.go | 13 ++++----- integration/oidc_implicit_hybrid_test.go | 3 +- integration/refresh_token_grant_test.go | 7 +++-- ...e_owner_password_credentials_grant_test.go | 7 +++-- integration/revoke_token_test.go | 10 +++---- internal/access_request.go | 1 + internal/access_response.go | 1 + internal/access_token_storage.go | 1 + internal/access_token_strategy.go | 1 + internal/authorize_code_storage.go | 1 + internal/authorize_code_strategy.go | 1 + internal/authorize_handler.go | 1 + internal/authorize_request.go | 1 + internal/client.go | 3 +- internal/hash.go | 3 +- internal/id_token_strategy.go | 1 + internal/introspector.go | 1 + internal/oauth2_client_storage.go | 1 + internal/oauth2_explicit_storage.go | 1 + internal/oauth2_owner_storage.go | 1 + internal/oauth2_refresh_storage.go | 1 + internal/oauth2_revoke_storage.go | 1 + internal/oauth2_storage.go | 1 + internal/oauth2_strategy.go | 1 + internal/openid_id_token_storage.go | 1 + internal/pkce_storage_strategy.go | 1 + internal/refresh_token_strategy.go | 1 + internal/request.go | 1 + internal/revoke_handler.go | 1 + internal/storage.go | 1 + internal/token_handler.go | 1 + introspect.go | 3 +- introspect_test.go | 11 ++++--- introspection_request_handler_test.go | 13 ++++----- introspection_response_writer_test.go | 3 +- oauth2.go | 3 +- request_test.go | 3 +- revoke_handler.go | 3 +- revoke_handler_test.go | 10 +++---- scope_strategy_test.go | 3 +- storage/memory.go | 29 ++++++++++--------- token/hmac/hmacsha.go | 3 +- token/jwt/claims_id_token_test.go | 23 ++++++++------- token/jwt/claims_jwt_test.go | 3 +- token/jwt/jwt.go | 6 ++-- token/jwt/jwt_test.go | 7 ++--- 113 files changed, 323 insertions(+), 295 deletions(-) diff --git a/access_error_test.go b/access_error_test.go index 7a29f2e83..5a956927f 100644 --- a/access_error_test.go +++ b/access_error_test.go @@ -23,17 +23,17 @@ package fosite_test import ( "encoding/json" + "fmt" "net/http" "net/http/httptest" "testing" - "fmt" - "github.com/golang/mock/gomock" - . "github.com/ory/fosite" - . "github.com/ory/fosite/internal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + . "github.com/ory/fosite" + . "github.com/ory/fosite/internal" ) func TestWriteAccessError(t *testing.T) { diff --git a/access_request_handler_test.go b/access_request_handler_test.go index e8ab44a8b..fc8ebbb05 100644 --- a/access_request_handler_test.go +++ b/access_request_handler_test.go @@ -22,20 +22,20 @@ package fosite_test import ( + "context" "encoding/base64" "fmt" "net/http" "net/url" "testing" - "context" - "github.com/golang/mock/gomock" - . "github.com/ory/fosite" - "github.com/ory/fosite/internal" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + . "github.com/ory/fosite" + "github.com/ory/fosite/internal" ) func TestNewAccessRequest(t *testing.T) { diff --git a/access_response_test.go b/access_response_test.go index 8d4273797..cab95b534 100644 --- a/access_response_test.go +++ b/access_response_test.go @@ -24,8 +24,9 @@ package fosite_test import ( "testing" - . "github.com/ory/fosite" "github.com/stretchr/testify/assert" + + . "github.com/ory/fosite" ) func TestAccessResponse(t *testing.T) { diff --git a/access_response_writer_test.go b/access_response_writer_test.go index cc8caf55f..7b1c7e1a7 100644 --- a/access_response_writer_test.go +++ b/access_response_writer_test.go @@ -22,18 +22,17 @@ package fosite_test import ( - "testing" - "context" - "fmt" + "testing" "github.com/golang/mock/gomock" - . "github.com/ory/fosite" - "github.com/ory/fosite/internal" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + . "github.com/ory/fosite" + "github.com/ory/fosite/internal" ) func TestNewAccessResponse(t *testing.T) { diff --git a/access_write_test.go b/access_write_test.go index 2bcb0b657..67df4964c 100644 --- a/access_write_test.go +++ b/access_write_test.go @@ -22,14 +22,14 @@ package fosite_test import ( - "testing" - "net/http" + "testing" "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + . "github.com/ory/fosite" . "github.com/ory/fosite/internal" - "github.com/stretchr/testify/assert" ) func TestWriteAccessResponse(t *testing.T) { diff --git a/authorize_error_test.go b/authorize_error_test.go index bb5f229d8..673a6cb8a 100644 --- a/authorize_error_test.go +++ b/authorize_error_test.go @@ -22,16 +22,16 @@ package fosite_test import ( + "fmt" "net/http" "net/url" "testing" - "fmt" - "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + . "github.com/ory/fosite" . "github.com/ory/fosite/internal" - "github.com/stretchr/testify/assert" ) // Test for diff --git a/authorize_request_handler.go b/authorize_request_handler.go index 15360c156..0850aa6ed 100644 --- a/authorize_request_handler.go +++ b/authorize_request_handler.go @@ -22,14 +22,11 @@ package fosite import ( - "net/http" - "strings" - "context" - "fmt" - "io/ioutil" + "net/http" + "strings" "github.com/dgrijalva/jwt-go" "github.com/ory/go-convenience/stringslice" diff --git a/authorize_request_handler_test.go b/authorize_request_handler_test.go index 8b4e56663..3a06f501f 100644 --- a/authorize_request_handler_test.go +++ b/authorize_request_handler_test.go @@ -22,20 +22,19 @@ package fosite_test import ( + "context" + "fmt" "net/http" "net/url" "testing" - "context" - - "fmt" - "github.com/golang/mock/gomock" - . "github.com/ory/fosite" - . "github.com/ory/fosite/internal" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + . "github.com/ory/fosite" + . "github.com/ory/fosite/internal" ) // Should pass diff --git a/authorize_response_writer.go b/authorize_response_writer.go index dc191d045..208b104c2 100644 --- a/authorize_response_writer.go +++ b/authorize_response_writer.go @@ -22,11 +22,10 @@ package fosite import ( + "context" "net/http" "net/url" - "context" - "github.com/pkg/errors" ) diff --git a/authorize_response_writer_test.go b/authorize_response_writer_test.go index befbd6628..12961c47a 100644 --- a/authorize_response_writer_test.go +++ b/authorize_response_writer_test.go @@ -22,15 +22,15 @@ package fosite_test import ( - "testing" - "context" + "testing" "github.com/golang/mock/gomock" - . "github.com/ory/fosite" - . "github.com/ory/fosite/internal" "github.com/pkg/errors" "github.com/stretchr/testify/assert" + + . "github.com/ory/fosite" + . "github.com/ory/fosite/internal" ) func TestNewAuthorizeResponse(t *testing.T) { diff --git a/authorize_write_test.go b/authorize_write_test.go index 04b5e924c..240156970 100644 --- a/authorize_write_test.go +++ b/authorize_write_test.go @@ -27,9 +27,10 @@ import ( "testing" "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + . "github.com/ory/fosite" . "github.com/ory/fosite/internal" - "github.com/stretchr/testify/assert" ) func TestWriteAuthorizeResponse(t *testing.T) { diff --git a/client_authentication_jwks_strategy_test.go b/client_authentication_jwks_strategy_test.go index 3a77b5721..ea30434dd 100644 --- a/client_authentication_jwks_strategy_test.go +++ b/client_authentication_jwks_strategy_test.go @@ -27,11 +27,12 @@ import ( "net/http/httptest" "testing" - . "github.com/ory/fosite" - "github.com/ory/fosite/internal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/square/go-jose.v2" + + . "github.com/ory/fosite" + "github.com/ory/fosite/internal" ) func TestDefaultJWKSFetcherStrategy(t *testing.T) { diff --git a/client_authentication_test.go b/client_authentication_test.go index 68a0ef910..f1664f2b6 100644 --- a/client_authentication_test.go +++ b/client_authentication_test.go @@ -22,6 +22,7 @@ package fosite_test import ( + "context" "crypto/rsa" "encoding/base64" "encoding/json" @@ -32,16 +33,15 @@ import ( "testing" "time" - "context" - "github.com/dgrijalva/jwt-go" - . "github.com/ory/fosite" - "github.com/ory/fosite/internal" - "github.com/ory/fosite/storage" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/square/go-jose.v2" + + . "github.com/ory/fosite" + "github.com/ory/fosite/internal" + "github.com/ory/fosite/storage" ) func mustGenerateAssertion(t *testing.T, claims jwt.MapClaims, key *rsa.PrivateKey, kid string) string { diff --git a/compose/compose.go b/compose/compose.go index 84e65d972..04f0cc735 100644 --- a/compose/compose.go +++ b/compose/compose.go @@ -58,7 +58,7 @@ func Compose(config *Config, storage interface{}, strategy interface{}, hasher f } f := &fosite.Fosite{ - Store: storage.(fosite.Storage), + Store: storage.(fosite.Storage), AuthorizeEndpointHandlers: fosite.AuthorizeEndpointHandlers{}, TokenEndpointHandlers: fosite.TokenEndpointHandlers{}, TokenIntrospectionHandlers: fosite.TokenIntrospectionHandlers{}, diff --git a/compose/compose_pkce.go b/compose/compose_pkce.go index 0402a760f..6e8071e32 100644 --- a/compose/compose_pkce.go +++ b/compose/compose_pkce.go @@ -29,9 +29,9 @@ import ( // OAuth2PKCEFactory creates a PKCE handler. func OAuth2PKCEFactory(config *Config, storage interface{}, strategy interface{}) interface{} { return &pkce.Handler{ - AuthorizeCodeStrategy: strategy.(oauth2.AuthorizeCodeStrategy), - Storage: storage.(pkce.PKCERequestStorage), - Force: config.EnforcePKCE, + AuthorizeCodeStrategy: strategy.(oauth2.AuthorizeCodeStrategy), + Storage: storage.(pkce.PKCERequestStorage), + Force: config.EnforcePKCE, EnablePlainChallengeMethod: config.EnablePKCEPlainChallengeMethod, } } diff --git a/fosite_test.go b/fosite_test.go index c31f3ffad..f60cc308e 100644 --- a/fosite_test.go +++ b/fosite_test.go @@ -24,10 +24,11 @@ package fosite_test import ( "testing" - . "github.com/ory/fosite" - "github.com/ory/fosite/handler/oauth2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + . "github.com/ory/fosite" + "github.com/ory/fosite/handler/oauth2" ) func TestAuthorizeEndpointHandlers(t *testing.T) { diff --git a/handler/oauth2/flow_authorize_code_auth.go b/handler/oauth2/flow_authorize_code_auth.go index 46c72a351..b73d5c4ea 100644 --- a/handler/oauth2/flow_authorize_code_auth.go +++ b/handler/oauth2/flow_authorize_code_auth.go @@ -22,13 +22,13 @@ package oauth2 import ( + "context" "strings" "time" - "context" + "github.com/pkg/errors" "github.com/ory/fosite" - "github.com/pkg/errors" ) // AuthorizeExplicitGrantTypeHandler is a response handler for the Authorize Code grant using the explicit grant type diff --git a/handler/oauth2/flow_authorize_code_auth_test.go b/handler/oauth2/flow_authorize_code_auth_test.go index 5adf28747..675c484c2 100644 --- a/handler/oauth2/flow_authorize_code_auth_test.go +++ b/handler/oauth2/flow_authorize_code_auth_test.go @@ -25,14 +25,14 @@ import ( "net/url" "strings" "testing" - "time" - "github.com/ory/fosite" - "github.com/ory/fosite/storage" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/ory/fosite" + "github.com/ory/fosite/storage" ) func parseUrl(uu string) *url.URL { diff --git a/handler/oauth2/flow_authorize_code_token.go b/handler/oauth2/flow_authorize_code_token.go index 45797c701..0b7d97252 100644 --- a/handler/oauth2/flow_authorize_code_token.go +++ b/handler/oauth2/flow_authorize_code_token.go @@ -25,8 +25,9 @@ import ( "context" "time" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) // HandleTokenEndpointRequest implements diff --git a/handler/oauth2/flow_authorize_code_token_test.go b/handler/oauth2/flow_authorize_code_token_test.go index c7db2237b..1c852a7e6 100644 --- a/handler/oauth2/flow_authorize_code_token_test.go +++ b/handler/oauth2/flow_authorize_code_token_test.go @@ -22,20 +22,14 @@ package oauth2 import ( + "context" + "fmt" "net/url" - "testing" - - //"time" - + "testing" //"time" //"github.com/golang/mock/gomock" - "github.com/ory/fosite" - //"github.com/ory/fosite/internal" "time" - "context" - - "fmt" - + "github.com/ory/fosite" //"github.com/ory/fosite/internal" "github.com/ory/fosite/storage" "github.com/pkg/errors" "github.com/stretchr/testify/assert" diff --git a/handler/oauth2/flow_authorize_implicit.go b/handler/oauth2/flow_authorize_implicit.go index 131272f46..2dfa19015 100644 --- a/handler/oauth2/flow_authorize_implicit.go +++ b/handler/oauth2/flow_authorize_implicit.go @@ -22,14 +22,14 @@ package oauth2 import ( + "context" + "strconv" "strings" "time" - "context" - "strconv" + "github.com/pkg/errors" "github.com/ory/fosite" - "github.com/pkg/errors" ) // AuthorizeImplicitGrantTypeHandler is a response handler for the Authorize Code grant using the implicit grant type diff --git a/handler/oauth2/flow_authorize_implicit_test.go b/handler/oauth2/flow_authorize_implicit_test.go index 9d5d0dff3..c8c5e7c12 100644 --- a/handler/oauth2/flow_authorize_implicit_test.go +++ b/handler/oauth2/flow_authorize_implicit_test.go @@ -22,16 +22,16 @@ package oauth2 import ( + "fmt" "testing" "time" - "fmt" - "github.com/golang/mock/gomock" - "github.com/ory/fosite" - "github.com/ory/fosite/internal" "github.com/pkg/errors" "github.com/stretchr/testify/require" + + "github.com/ory/fosite" + "github.com/ory/fosite/internal" ) func TestAuthorizeImplicit_EndpointHandler(t *testing.T) { diff --git a/handler/oauth2/flow_client_credentials.go b/handler/oauth2/flow_client_credentials.go index 3c3490bb9..89f9139ad 100644 --- a/handler/oauth2/flow_client_credentials.go +++ b/handler/oauth2/flow_client_credentials.go @@ -25,8 +25,9 @@ import ( "context" "time" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) type ClientCredentialsGrantHandler struct { diff --git a/handler/oauth2/flow_client_credentials_test.go b/handler/oauth2/flow_client_credentials_test.go index d92b5c7bd..791cef4dc 100644 --- a/handler/oauth2/flow_client_credentials_test.go +++ b/handler/oauth2/flow_client_credentials_test.go @@ -22,16 +22,16 @@ package oauth2 import ( + "fmt" "net/http" "testing" "time" - "fmt" - "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + "github.com/ory/fosite" "github.com/ory/fosite/internal" - "github.com/stretchr/testify/require" ) func TestClientCredentials_HandleTokenEndpointRequest(t *testing.T) { diff --git a/handler/oauth2/flow_refresh.go b/handler/oauth2/flow_refresh.go index 597cfe0b0..2ad9abfad 100644 --- a/handler/oauth2/flow_refresh.go +++ b/handler/oauth2/flow_refresh.go @@ -25,8 +25,9 @@ import ( "context" "time" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) type RefreshTokenGrantHandler struct { diff --git a/handler/oauth2/flow_refresh_test.go b/handler/oauth2/flow_refresh_test.go index 36b1093e9..364e4a926 100644 --- a/handler/oauth2/flow_refresh_test.go +++ b/handler/oauth2/flow_refresh_test.go @@ -26,11 +26,12 @@ import ( "testing" "time" - "github.com/ory/fosite" - "github.com/ory/fosite/storage" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/ory/fosite" + "github.com/ory/fosite/storage" ) func TestRefreshFlow_HandleTokenEndpointRequest(t *testing.T) { diff --git a/handler/oauth2/flow_resource_owner.go b/handler/oauth2/flow_resource_owner.go index a034318d8..25d4d0468 100644 --- a/handler/oauth2/flow_resource_owner.go +++ b/handler/oauth2/flow_resource_owner.go @@ -22,12 +22,12 @@ package oauth2 import ( + "context" "time" - "context" + "github.com/pkg/errors" "github.com/ory/fosite" - "github.com/pkg/errors" ) type ResourceOwnerPasswordCredentialsGrantHandler struct { diff --git a/handler/oauth2/flow_resource_owner_test.go b/handler/oauth2/flow_resource_owner_test.go index 82780e5de..69c40750d 100644 --- a/handler/oauth2/flow_resource_owner_test.go +++ b/handler/oauth2/flow_resource_owner_test.go @@ -22,18 +22,18 @@ package oauth2 import ( + "fmt" "net/url" "testing" "time" - "fmt" - "github.com/golang/mock/gomock" - "github.com/ory/fosite" - "github.com/ory/fosite/internal" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/ory/fosite" + "github.com/ory/fosite/internal" ) func TestResourceOwnerFlow_HandleTokenEndpointRequest(t *testing.T) { diff --git a/handler/oauth2/helper.go b/handler/oauth2/helper.go index 994816b7c..3d531c19b 100644 --- a/handler/oauth2/helper.go +++ b/handler/oauth2/helper.go @@ -22,9 +22,8 @@ package oauth2 import ( - "time" - "context" + "time" "github.com/ory/fosite" ) diff --git a/handler/oauth2/helper_test.go b/handler/oauth2/helper_test.go index 7bbaa3f8c..5e0f3caad 100644 --- a/handler/oauth2/helper_test.go +++ b/handler/oauth2/helper_test.go @@ -26,11 +26,12 @@ import ( "time" "github.com/golang/mock/gomock" - "github.com/ory/fosite" - "github.com/ory/fosite/internal" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/ory/fosite" + "github.com/ory/fosite/internal" ) func TestGetExpiresIn(t *testing.T) { diff --git a/handler/oauth2/introspector.go b/handler/oauth2/introspector.go index a2801e47f..3d91b4cbc 100644 --- a/handler/oauth2/introspector.go +++ b/handler/oauth2/introspector.go @@ -24,8 +24,9 @@ package oauth2 import ( "context" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) type CoreValidator struct { diff --git a/handler/oauth2/introspector_jwt.go b/handler/oauth2/introspector_jwt.go index 2cec5ec8a..e121fcb11 100644 --- a/handler/oauth2/introspector_jwt.go +++ b/handler/oauth2/introspector_jwt.go @@ -24,8 +24,9 @@ package oauth2 import ( "context" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) type JWTAccessTokenStrategy interface { diff --git a/handler/oauth2/introspector_jwt_test.go b/handler/oauth2/introspector_jwt_test.go index c626725c2..d0f713898 100644 --- a/handler/oauth2/introspector_jwt_test.go +++ b/handler/oauth2/introspector_jwt_test.go @@ -23,16 +23,16 @@ package oauth2 import ( "encoding/base64" + "fmt" "strings" "testing" - "fmt" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/ory/fosite" "github.com/ory/fosite/internal" "github.com/ory/fosite/token/jwt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestIntrospectJWT(t *testing.T) { diff --git a/handler/oauth2/introspector_test.go b/handler/oauth2/introspector_test.go index 6a401125d..b55c81888 100644 --- a/handler/oauth2/introspector_test.go +++ b/handler/oauth2/introspector_test.go @@ -27,11 +27,12 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/ory/fosite" - "github.com/ory/fosite/internal" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/ory/fosite" + "github.com/ory/fosite/internal" ) func TestIntrospectToken(t *testing.T) { diff --git a/handler/oauth2/revocation.go b/handler/oauth2/revocation.go index eee796a18..e97bd3550 100644 --- a/handler/oauth2/revocation.go +++ b/handler/oauth2/revocation.go @@ -24,8 +24,9 @@ package oauth2 import ( "context" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) type TokenRevocationHandler struct { diff --git a/handler/oauth2/revocation_test.go b/handler/oauth2/revocation_test.go index c05c74077..e49011b68 100644 --- a/handler/oauth2/revocation_test.go +++ b/handler/oauth2/revocation_test.go @@ -22,14 +22,14 @@ package oauth2 import ( - "testing" - "fmt" + "testing" "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + "github.com/ory/fosite" "github.com/ory/fosite/internal" - "github.com/stretchr/testify/require" ) func TestRevokeToken(t *testing.T) { diff --git a/handler/oauth2/strategy_hmacsha.go b/handler/oauth2/strategy_hmacsha.go index 9cb98dd06..36777d40b 100644 --- a/handler/oauth2/strategy_hmacsha.go +++ b/handler/oauth2/strategy_hmacsha.go @@ -22,13 +22,13 @@ package oauth2 import ( + "context" "time" - "context" + "github.com/pkg/errors" "github.com/ory/fosite" enigma "github.com/ory/fosite/token/hmac" - "github.com/pkg/errors" ) type HMACSHAStrategy struct { diff --git a/handler/oauth2/strategy_hmacsha_test.go b/handler/oauth2/strategy_hmacsha_test.go index 9d0c3b330..dd47b782d 100644 --- a/handler/oauth2/strategy_hmacsha_test.go +++ b/handler/oauth2/strategy_hmacsha_test.go @@ -22,15 +22,15 @@ package oauth2 import ( + "fmt" "strings" "testing" "time" - "fmt" + "github.com/stretchr/testify/assert" "github.com/ory/fosite" "github.com/ory/fosite/token/hmac" - "github.com/stretchr/testify/assert" ) var hmacshaStrategy = HMACSHAStrategy{ diff --git a/handler/oauth2/strategy_jwt.go b/handler/oauth2/strategy_jwt.go index 192e3c360..2f493fc8d 100644 --- a/handler/oauth2/strategy_jwt.go +++ b/handler/oauth2/strategy_jwt.go @@ -22,15 +22,15 @@ package oauth2 import ( + "context" "strings" "time" - "context" - jwtx "github.com/dgrijalva/jwt-go" + "github.com/pkg/errors" + "github.com/ory/fosite" "github.com/ory/fosite/token/jwt" - "github.com/pkg/errors" ) // DefaultJWTStrategy is a JWT RS256 strategy. diff --git a/handler/oauth2/strategy_jwt_session.go b/handler/oauth2/strategy_jwt_session.go index ec180b080..a2bbd454a 100644 --- a/handler/oauth2/strategy_jwt_session.go +++ b/handler/oauth2/strategy_jwt_session.go @@ -25,6 +25,7 @@ import ( "time" "github.com/mohae/deepcopy" + "github.com/ory/fosite" "github.com/ory/fosite/token/jwt" ) diff --git a/handler/oauth2/strategy_jwt_test.go b/handler/oauth2/strategy_jwt_test.go index e4255617c..7726b85c4 100644 --- a/handler/oauth2/strategy_jwt_test.go +++ b/handler/oauth2/strategy_jwt_test.go @@ -22,17 +22,17 @@ package oauth2 import ( - "github.com/stretchr/testify/require" + "fmt" "strings" "testing" "time" - "fmt" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/ory/fosite" "github.com/ory/fosite/internal" "github.com/ory/fosite/token/jwt" - "github.com/stretchr/testify/assert" ) var j = &DefaultJWTStrategy{ diff --git a/handler/openid/flow_explicit_auth.go b/handler/openid/flow_explicit_auth.go index 3155d9f7c..170917e3a 100644 --- a/handler/openid/flow_explicit_auth.go +++ b/handler/openid/flow_explicit_auth.go @@ -24,8 +24,9 @@ package openid import ( "context" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) type OpenIDConnectExplicitHandler struct { diff --git a/handler/openid/flow_explicit_auth_test.go b/handler/openid/flow_explicit_auth_test.go index 49d7bfc78..854771749 100644 --- a/handler/openid/flow_explicit_auth_test.go +++ b/handler/openid/flow_explicit_auth_test.go @@ -22,16 +22,16 @@ package openid import ( - "testing" - "fmt" + "testing" "github.com/golang/mock/gomock" + "github.com/pkg/errors" + "github.com/stretchr/testify/require" + "github.com/ory/fosite" "github.com/ory/fosite/internal" "github.com/ory/fosite/token/jwt" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" ) // expose key to verify id_token diff --git a/handler/openid/flow_explicit_token.go b/handler/openid/flow_explicit_token.go index b88613f4c..ff69d1621 100644 --- a/handler/openid/flow_explicit_token.go +++ b/handler/openid/flow_explicit_token.go @@ -24,8 +24,9 @@ package openid import ( "context" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) func (c *OpenIDConnectExplicitHandler) HandleTokenEndpointRequest(ctx context.Context, request fosite.AccessRequester) error { diff --git a/handler/openid/flow_explicit_token_test.go b/handler/openid/flow_explicit_token_test.go index 8454e95d3..b1f4028b0 100644 --- a/handler/openid/flow_explicit_token_test.go +++ b/handler/openid/flow_explicit_token_test.go @@ -22,18 +22,18 @@ package openid import ( - "testing" - "fmt" + "testing" + jwtgo "github.com/dgrijalva/jwt-go" "github.com/golang/mock/gomock" - "github.com/ory/fosite" - "github.com/ory/fosite/internal" - "github.com/ory/fosite/token/jwt" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - jwtgo "github.com/dgrijalva/jwt-go" + + "github.com/ory/fosite" + "github.com/ory/fosite/internal" + "github.com/ory/fosite/token/jwt" ) func TestHandleTokenEndpointRequest(t *testing.T) { @@ -117,11 +117,11 @@ func TestExplicit_PopulateTokenEndpointResponse(t *testing.T) { check: func(t *testing.T, aresp *fosite.AccessResponse) { assert.NotEmpty(t, aresp.GetExtra("id_token")) idToken, _ := aresp.GetExtra("id_token").(string) - decodedIdToken, _ := jwtgo.Parse(idToken, func(token *jwtgo.Token)(interface{}, error) { + decodedIdToken, _ := jwtgo.Parse(idToken, func(token *jwtgo.Token) (interface{}, error) { return key.PublicKey, nil }) claims, _ := decodedIdToken.Claims.(jwtgo.MapClaims) - assert.NotEmpty(t, claims["at_hash"]) + assert.NotEmpty(t, claims["at_hash"]) }, }, { diff --git a/handler/openid/flow_hybrid.go b/handler/openid/flow_hybrid.go index 3d3291d62..da7aaf201 100644 --- a/handler/openid/flow_hybrid.go +++ b/handler/openid/flow_hybrid.go @@ -25,10 +25,11 @@ import ( "context" "encoding/base64" + "github.com/pkg/errors" + "github.com/ory/fosite" "github.com/ory/fosite/handler/oauth2" "github.com/ory/fosite/token/jwt" - "github.com/pkg/errors" ) type OpenIDConnectHybridHandler struct { diff --git a/handler/openid/flow_hybrid_test.go b/handler/openid/flow_hybrid_test.go index a1d096720..a8e5ed509 100644 --- a/handler/openid/flow_hybrid_test.go +++ b/handler/openid/flow_hybrid_test.go @@ -22,22 +22,21 @@ package openid import ( - "testing" - "time" - "fmt" - "net/url" + "testing" + "time" "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/ory/fosite" "github.com/ory/fosite/handler/oauth2" "github.com/ory/fosite/internal" "github.com/ory/fosite/storage" "github.com/ory/fosite/token/hmac" "github.com/ory/fosite/token/jwt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) var idStrategy = &DefaultStrategy{ diff --git a/handler/openid/flow_implicit.go b/handler/openid/flow_implicit.go index 1764ea5a6..34498632e 100644 --- a/handler/openid/flow_implicit.go +++ b/handler/openid/flow_implicit.go @@ -25,10 +25,11 @@ import ( "context" "encoding/base64" + "github.com/pkg/errors" + "github.com/ory/fosite" "github.com/ory/fosite/handler/oauth2" "github.com/ory/fosite/token/jwt" - "github.com/pkg/errors" ) type OpenIDConnectImplicitHandler struct { diff --git a/handler/openid/flow_implicit_test.go b/handler/openid/flow_implicit_test.go index 82a4e322d..932a818f7 100644 --- a/handler/openid/flow_implicit_test.go +++ b/handler/openid/flow_implicit_test.go @@ -22,19 +22,18 @@ package openid import ( - "testing" - "time" - "fmt" - "net/url" + "testing" + "time" "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + "github.com/ory/fosite" "github.com/ory/fosite/handler/oauth2" "github.com/ory/fosite/storage" "github.com/ory/fosite/token/jwt" - "github.com/stretchr/testify/assert" ) func TestImplicit_HandleAuthorizeEndpointRequest(t *testing.T) { diff --git a/handler/openid/flow_refresh_token.go b/handler/openid/flow_refresh_token.go index d8022bace..cd8e6fe11 100644 --- a/handler/openid/flow_refresh_token.go +++ b/handler/openid/flow_refresh_token.go @@ -25,8 +25,9 @@ import ( "context" "time" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) type OpenIDConnectRefreshHandler struct { diff --git a/handler/openid/flow_refresh_token_test.go b/handler/openid/flow_refresh_token_test.go index 222b8932d..ded55cf59 100644 --- a/handler/openid/flow_refresh_token_test.go +++ b/handler/openid/flow_refresh_token_test.go @@ -24,12 +24,13 @@ package openid import ( "testing" - "github.com/ory/fosite" - "github.com/ory/fosite/token/jwt" + jwtgo "github.com/dgrijalva/jwt-go" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - jwtgo "github.com/dgrijalva/jwt-go" + + "github.com/ory/fosite" + "github.com/ory/fosite/token/jwt" ) func TestOpenIDConnectRefreshHandler_HandleTokenEndpointRequest(t *testing.T) { @@ -157,11 +158,11 @@ func TestOpenIDConnectRefreshHandler_PopulateTokenEndpointResponse(t *testing.T) check: func(t *testing.T, aresp *fosite.AccessResponse) { assert.NotEmpty(t, aresp.GetExtra("id_token")) idToken, _ := aresp.GetExtra("id_token").(string) - decodedIdToken, _ := jwtgo.Parse(idToken, func(token *jwtgo.Token)(interface{}, error) { + decodedIdToken, _ := jwtgo.Parse(idToken, func(token *jwtgo.Token) (interface{}, error) { return key.PublicKey, nil }) claims, _ := decodedIdToken.Claims.(jwtgo.MapClaims) - assert.NotEmpty(t, claims["at_hash"]) + assert.NotEmpty(t, claims["at_hash"]) }, }, { diff --git a/handler/openid/helper_test.go b/handler/openid/helper_test.go index 446b73d01..34e0d5da7 100644 --- a/handler/openid/helper_test.go +++ b/handler/openid/helper_test.go @@ -26,11 +26,12 @@ import ( "testing" "github.com/golang/mock/gomock" + "github.com/pkg/errors" + "github.com/stretchr/testify/assert" + "github.com/ory/fosite" "github.com/ory/fosite/internal" "github.com/ory/fosite/token/jwt" - "github.com/pkg/errors" - "github.com/stretchr/testify/assert" ) var strat = &DefaultStrategy{ diff --git a/handler/openid/strategy_jwt.go b/handler/openid/strategy_jwt.go index faec0b5cc..8509f24de 100644 --- a/handler/openid/strategy_jwt.go +++ b/handler/openid/strategy_jwt.go @@ -24,14 +24,16 @@ package openid import ( "context" "fmt" + "strconv" + "time" + jwtgo "github.com/dgrijalva/jwt-go" "github.com/mohae/deepcopy" - "github.com/ory/fosite" - "github.com/ory/fosite/token/jwt" "github.com/ory/go-convenience/stringslice" "github.com/pkg/errors" - "strconv" - "time" + + "github.com/ory/fosite" + "github.com/ory/fosite/token/jwt" ) const defaultExpiryTime = time.Hour diff --git a/handler/openid/strategy_jwt_test.go b/handler/openid/strategy_jwt_test.go index 11f3f6db1..92748d3e6 100644 --- a/handler/openid/strategy_jwt_test.go +++ b/handler/openid/strategy_jwt_test.go @@ -22,16 +22,15 @@ package openid import ( + "context" + "fmt" "testing" "time" - "fmt" - - "context" + "github.com/stretchr/testify/assert" "github.com/ory/fosite" "github.com/ory/fosite/token/jwt" - "github.com/stretchr/testify/assert" ) func TestJWTStrategy_GenerateIDToken(t *testing.T) { diff --git a/handler/openid/validator.go b/handler/openid/validator.go index ef37488c3..b8239601c 100644 --- a/handler/openid/validator.go +++ b/handler/openid/validator.go @@ -22,17 +22,17 @@ package openid import ( + "context" "strconv" "time" - "context" - jwtgo "github.com/dgrijalva/jwt-go" - "github.com/ory/fosite" - "github.com/ory/fosite/token/jwt" "github.com/ory/go-convenience/stringslice" "github.com/ory/go-convenience/stringsx" "github.com/pkg/errors" + + "github.com/ory/fosite" + "github.com/ory/fosite/token/jwt" ) type OpenIDConnectRequestValidator struct { diff --git a/handler/openid/validator_test.go b/handler/openid/validator_test.go index fe26c0e52..66158dc80 100644 --- a/handler/openid/validator_test.go +++ b/handler/openid/validator_test.go @@ -22,18 +22,17 @@ package openid import ( + "context" "fmt" "net/url" "testing" - "time" - "context" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/ory/fosite" "github.com/ory/fosite/token/jwt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestValidatePrompt(t *testing.T) { diff --git a/handler/pkce/handler.go b/handler/pkce/handler.go index b3e96ae9a..cac7a0180 100644 --- a/handler/pkce/handler.go +++ b/handler/pkce/handler.go @@ -26,9 +26,10 @@ import ( "crypto/sha256" "encoding/base64" + "github.com/pkg/errors" + "github.com/ory/fosite" "github.com/ory/fosite/handler/oauth2" - "github.com/pkg/errors" ) type Handler struct { diff --git a/handler/pkce/handler_test.go b/handler/pkce/handler_test.go index b82ecdcac..e01e33f5c 100644 --- a/handler/pkce/handler_test.go +++ b/handler/pkce/handler_test.go @@ -28,11 +28,12 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/ory/fosite" "github.com/ory/fosite/handler/oauth2" "github.com/ory/fosite/storage" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) type mockCodeStrategy struct { @@ -295,7 +296,7 @@ func TestPKCEHandleTokenEndpointRequest(t *testing.T) { } { t.Run(fmt.Sprintf("case=%d/description=%s", k, tc.d), func(t *testing.T) { h := &Handler{ - Force: tc.force, + Force: tc.force, EnablePlainChallengeMethod: tc.enablePlain, } diff --git a/hash_bcrypt_test.go b/hash_bcrypt_test.go index afe66dbfd..24448a3fe 100644 --- a/hash_bcrypt_test.go +++ b/hash_bcrypt_test.go @@ -22,9 +22,8 @@ package fosite import ( - "testing" - "context" + "testing" "github.com/stretchr/testify/assert" ) diff --git a/integration/authorize_code_grant_public_client_pkce_test.go b/integration/authorize_code_grant_public_client_pkce_test.go index e3768822b..778f8bd84 100644 --- a/integration/authorize_code_grant_public_client_pkce_test.go +++ b/integration/authorize_code_grant_public_client_pkce_test.go @@ -22,24 +22,20 @@ package integration_test import ( - "testing" - - "net/http" - - "fmt" - - "github.com/ory/fosite" - "github.com/ory/fosite/compose" - "github.com/ory/fosite/handler/oauth2" - //"github.com/stretchr/testify/assert" "encoding/json" - "net/url" - + "fmt" "io/ioutil" + "net/http" + "net/url" + "testing" "github.com/magiconair/properties/assert" "github.com/stretchr/testify/require" goauth "golang.org/x/oauth2" + + "github.com/ory/fosite" + "github.com/ory/fosite/compose" + "github.com/ory/fosite/handler/oauth2" //"github.com/stretchr/testify/assert" ) func TestAuthorizeCodeFlowWithPublicClientAndPKCE(t *testing.T) { diff --git a/integration/authorize_code_grant_public_client_test.go b/integration/authorize_code_grant_public_client_test.go index 962bb6f50..d34f410bd 100644 --- a/integration/authorize_code_grant_public_client_test.go +++ b/integration/authorize_code_grant_public_client_test.go @@ -22,18 +22,17 @@ package integration_test import ( - "testing" - + "fmt" "net/http" + "testing" - "fmt" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + goauth "golang.org/x/oauth2" "github.com/ory/fosite" "github.com/ory/fosite/compose" "github.com/ory/fosite/handler/oauth2" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - goauth "golang.org/x/oauth2" ) func TestAuthorizeCodeFlowWithPublicClient(t *testing.T) { diff --git a/integration/authorize_code_grant_test.go b/integration/authorize_code_grant_test.go index 27f9abe16..78b3623d2 100644 --- a/integration/authorize_code_grant_test.go +++ b/integration/authorize_code_grant_test.go @@ -22,18 +22,17 @@ package integration_test import ( - "testing" - + "fmt" "net/http" + "testing" - "fmt" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + goauth "golang.org/x/oauth2" "github.com/ory/fosite" "github.com/ory/fosite/compose" "github.com/ory/fosite/handler/oauth2" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - goauth "golang.org/x/oauth2" ) func TestAuthorizeCodeFlow(t *testing.T) { diff --git a/integration/authorize_implicit_grant_test.go b/integration/authorize_implicit_grant_test.go index 0fe151015..8a4e34125 100644 --- a/integration/authorize_implicit_grant_test.go +++ b/integration/authorize_implicit_grant_test.go @@ -22,6 +22,7 @@ package integration_test import ( + "fmt" "net/http" "net/url" "strconv" @@ -29,15 +30,14 @@ import ( "testing" "time" - "fmt" - - "github.com/ory/fosite" - "github.com/ory/fosite/compose" - "github.com/ory/fosite/handler/oauth2" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" goauth "golang.org/x/oauth2" + + "github.com/ory/fosite" + "github.com/ory/fosite/compose" + "github.com/ory/fosite/handler/oauth2" ) func TestAuthorizeImplicitFlow(t *testing.T) { diff --git a/integration/client_credentials_grant_test.go b/integration/client_credentials_grant_test.go index 598694699..7ef235b69 100644 --- a/integration/client_credentials_grant_test.go +++ b/integration/client_credentials_grant_test.go @@ -24,12 +24,13 @@ package integration_test import ( "testing" - "github.com/ory/fosite" - "github.com/ory/fosite/compose" - "github.com/ory/fosite/handler/oauth2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" goauth "golang.org/x/oauth2" + + "github.com/ory/fosite" + "github.com/ory/fosite/compose" + "github.com/ory/fosite/handler/oauth2" ) func TestClientCredentialsFlow(t *testing.T) { diff --git a/integration/helper_endpoints_test.go b/integration/helper_endpoints_test.go index 2613803b4..bd1b68544 100644 --- a/integration/helper_endpoints_test.go +++ b/integration/helper_endpoints_test.go @@ -25,10 +25,11 @@ import ( "net/http" "testing" - "github.com/ory/fosite" - "github.com/ory/fosite/handler/oauth2" "github.com/pkg/errors" "github.com/stretchr/testify/assert" + + "github.com/ory/fosite" + "github.com/ory/fosite/handler/oauth2" ) type stackTracer interface { diff --git a/integration/helper_setup_test.go b/integration/helper_setup_test.go index 8924c5b3a..e8fc1e910 100644 --- a/integration/helper_setup_test.go +++ b/integration/helper_setup_test.go @@ -27,6 +27,9 @@ import ( "time" "github.com/gorilla/mux" + goauth "golang.org/x/oauth2" + "golang.org/x/oauth2/clientcredentials" + "github.com/ory/fosite" "github.com/ory/fosite/handler/oauth2" "github.com/ory/fosite/handler/openid" @@ -34,8 +37,6 @@ import ( "github.com/ory/fosite/storage" "github.com/ory/fosite/token/hmac" "github.com/ory/fosite/token/jwt" - goauth "golang.org/x/oauth2" - "golang.org/x/oauth2/clientcredentials" ) var fositeStore = &storage.MemoryStore{ diff --git a/integration/introspect_token_test.go b/integration/introspect_token_test.go index c5d21222b..d54b10a7d 100644 --- a/integration/introspect_token_test.go +++ b/integration/introspect_token_test.go @@ -22,19 +22,18 @@ package integration_test import ( - "testing" - "encoding/json" - "fmt" + "testing" - "github.com/ory/fosite" - "github.com/ory/fosite/compose" - "github.com/ory/fosite/handler/oauth2" "github.com/parnurzeal/gorequest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" goauth "golang.org/x/oauth2" + + "github.com/ory/fosite" + "github.com/ory/fosite/compose" + "github.com/ory/fosite/handler/oauth2" ) func TestIntrospectToken(t *testing.T) { diff --git a/integration/oidc_explicit_test.go b/integration/oidc_explicit_test.go index 29da8dbf5..26837bc7c 100644 --- a/integration/oidc_explicit_test.go +++ b/integration/oidc_explicit_test.go @@ -22,23 +22,22 @@ package integration_test import ( - "net/http" - "testing" - "fmt" - "io/ioutil" + "net/http" "strings" + "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "golang.org/x/oauth2" + "github.com/ory/fosite" "github.com/ory/fosite/compose" "github.com/ory/fosite/handler/openid" "github.com/ory/fosite/internal" "github.com/ory/fosite/token/jwt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "golang.org/x/oauth2" ) func newIDSession(j *jwt.IDTokenClaims) *defaultSession { diff --git a/integration/oidc_implicit_hybrid_test.go b/integration/oidc_implicit_hybrid_test.go index f4779fee2..fde89e4d6 100644 --- a/integration/oidc_implicit_hybrid_test.go +++ b/integration/oidc_implicit_hybrid_test.go @@ -22,6 +22,7 @@ package integration_test import ( + "fmt" "net/http" "net/url" "strconv" @@ -34,8 +35,6 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/oauth2" - "fmt" - "github.com/ory/fosite" "github.com/ory/fosite/compose" "github.com/ory/fosite/handler/openid" diff --git a/integration/refresh_token_grant_test.go b/integration/refresh_token_grant_test.go index 9ad3ca64f..35404693b 100644 --- a/integration/refresh_token_grant_test.go +++ b/integration/refresh_token_grant_test.go @@ -26,14 +26,15 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "golang.org/x/oauth2" + "github.com/ory/fosite" "github.com/ory/fosite/compose" "github.com/ory/fosite/handler/openid" "github.com/ory/fosite/internal" "github.com/ory/fosite/token/jwt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "golang.org/x/oauth2" ) func TestRefreshTokenFlow(t *testing.T) { diff --git a/integration/resource_owner_password_credentials_grant_test.go b/integration/resource_owner_password_credentials_grant_test.go index 57c8ac3be..edfc36f0e 100644 --- a/integration/resource_owner_password_credentials_grant_test.go +++ b/integration/resource_owner_password_credentials_grant_test.go @@ -24,12 +24,13 @@ package integration_test import ( "testing" - "github.com/ory/fosite" - "github.com/ory/fosite/compose" - hst "github.com/ory/fosite/handler/oauth2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/oauth2" + + "github.com/ory/fosite" + "github.com/ory/fosite/compose" + hst "github.com/ory/fosite/handler/oauth2" ) func TestResourceOwnerPasswordCredentialsFlow(t *testing.T) { diff --git a/integration/revoke_token_test.go b/integration/revoke_token_test.go index 2d674db86..48ece03e7 100644 --- a/integration/revoke_token_test.go +++ b/integration/revoke_token_test.go @@ -22,17 +22,17 @@ package integration_test import ( - "testing" - "net/http" + "testing" - "github.com/ory/fosite" - "github.com/ory/fosite/compose" - "github.com/ory/fosite/handler/oauth2" "github.com/parnurzeal/gorequest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" goauth "golang.org/x/oauth2" + + "github.com/ory/fosite" + "github.com/ory/fosite/compose" + "github.com/ory/fosite/handler/oauth2" ) func TestRevokeToken(t *testing.T) { diff --git a/internal/access_request.go b/internal/access_request.go index 2d23b4bd8..66e91461d 100644 --- a/internal/access_request.go +++ b/internal/access_request.go @@ -8,6 +8,7 @@ import ( time "time" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/access_response.go b/internal/access_response.go index 802cdc034..4017bbe50 100644 --- a/internal/access_response.go +++ b/internal/access_response.go @@ -7,6 +7,7 @@ import ( time "time" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/access_token_storage.go b/internal/access_token_storage.go index 014a6f1e7..24f5a4f0d 100644 --- a/internal/access_token_storage.go +++ b/internal/access_token_storage.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/access_token_strategy.go b/internal/access_token_strategy.go index 2449ece9c..275f26b20 100644 --- a/internal/access_token_strategy.go +++ b/internal/access_token_strategy.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/authorize_code_storage.go b/internal/authorize_code_storage.go index 8dae8c205..6ea4d9fa6 100644 --- a/internal/authorize_code_storage.go +++ b/internal/authorize_code_storage.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/authorize_code_strategy.go b/internal/authorize_code_strategy.go index c2623cc18..d363ee1cb 100644 --- a/internal/authorize_code_strategy.go +++ b/internal/authorize_code_strategy.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/authorize_handler.go b/internal/authorize_handler.go index 9ffac1a9d..1cbcf6d88 100644 --- a/internal/authorize_handler.go +++ b/internal/authorize_handler.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/authorize_request.go b/internal/authorize_request.go index c502b62b2..2cc29dce0 100644 --- a/internal/authorize_request.go +++ b/internal/authorize_request.go @@ -8,6 +8,7 @@ import ( time "time" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/client.go b/internal/client.go index c3618ada4..bdd66940e 100644 --- a/internal/client.go +++ b/internal/client.go @@ -5,8 +5,9 @@ package internal import ( gomock "github.com/golang/mock/gomock" - fosite "github.com/ory/fosite" go_jose "gopkg.in/square/go-jose.v2" + + fosite "github.com/ory/fosite" ) // Mock of Client interface diff --git a/internal/hash.go b/internal/hash.go index aeca61b3d..d744b6cfb 100644 --- a/internal/hash.go +++ b/internal/hash.go @@ -5,8 +5,9 @@ package internal import ( context "context" - gomock "github.com/golang/mock/gomock" reflect "reflect" + + gomock "github.com/golang/mock/gomock" ) // MockHasher is a mock of Hasher interface diff --git a/internal/id_token_strategy.go b/internal/id_token_strategy.go index 22dde6724..88e0c6d7d 100644 --- a/internal/id_token_strategy.go +++ b/internal/id_token_strategy.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/introspector.go b/internal/introspector.go index 4321c44a5..927a45469 100644 --- a/internal/introspector.go +++ b/internal/introspector.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/oauth2_client_storage.go b/internal/oauth2_client_storage.go index 6434e1199..9bc6fd405 100644 --- a/internal/oauth2_client_storage.go +++ b/internal/oauth2_client_storage.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/oauth2_explicit_storage.go b/internal/oauth2_explicit_storage.go index 594f9ca63..ccf39b424 100644 --- a/internal/oauth2_explicit_storage.go +++ b/internal/oauth2_explicit_storage.go @@ -28,6 +28,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/oauth2_owner_storage.go b/internal/oauth2_owner_storage.go index 10737ed47..6e6f19438 100644 --- a/internal/oauth2_owner_storage.go +++ b/internal/oauth2_owner_storage.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/oauth2_refresh_storage.go b/internal/oauth2_refresh_storage.go index 178728a3b..08d8f26dd 100644 --- a/internal/oauth2_refresh_storage.go +++ b/internal/oauth2_refresh_storage.go @@ -28,6 +28,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/oauth2_revoke_storage.go b/internal/oauth2_revoke_storage.go index b3981a78d..0bb154729 100644 --- a/internal/oauth2_revoke_storage.go +++ b/internal/oauth2_revoke_storage.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/oauth2_storage.go b/internal/oauth2_storage.go index 25ded8798..b3763cd21 100644 --- a/internal/oauth2_storage.go +++ b/internal/oauth2_storage.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/oauth2_strategy.go b/internal/oauth2_strategy.go index 198de19e5..ff5d8092d 100644 --- a/internal/oauth2_strategy.go +++ b/internal/oauth2_strategy.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/openid_id_token_storage.go b/internal/openid_id_token_storage.go index 742856e7e..0bb557e36 100644 --- a/internal/openid_id_token_storage.go +++ b/internal/openid_id_token_storage.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/pkce_storage_strategy.go b/internal/pkce_storage_strategy.go index 0ebe70b2c..b4fb49cb3 100644 --- a/internal/pkce_storage_strategy.go +++ b/internal/pkce_storage_strategy.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/refresh_token_strategy.go b/internal/refresh_token_strategy.go index b7422cf45..8a41aba1e 100644 --- a/internal/refresh_token_strategy.go +++ b/internal/refresh_token_strategy.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/request.go b/internal/request.go index 838519d52..14b0f931f 100644 --- a/internal/request.go +++ b/internal/request.go @@ -8,6 +8,7 @@ import ( time "time" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/revoke_handler.go b/internal/revoke_handler.go index 82f9134b7..fa253ec66 100644 --- a/internal/revoke_handler.go +++ b/internal/revoke_handler.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/storage.go b/internal/storage.go index 8b9d6daea..7ba41e29c 100644 --- a/internal/storage.go +++ b/internal/storage.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/internal/token_handler.go b/internal/token_handler.go index d835568b2..758755338 100644 --- a/internal/token_handler.go +++ b/internal/token_handler.go @@ -7,6 +7,7 @@ import ( context "context" gomock "github.com/golang/mock/gomock" + fosite "github.com/ory/fosite" ) diff --git a/introspect.go b/introspect.go index 69511cde3..c32dbe202 100644 --- a/introspect.go +++ b/introspect.go @@ -22,11 +22,10 @@ package fosite import ( + "context" "net/http" "strings" - "context" - "github.com/pkg/errors" ) diff --git a/introspect_test.go b/introspect_test.go index fa4d0eeab..074b94fb6 100644 --- a/introspect_test.go +++ b/introspect_test.go @@ -22,20 +22,19 @@ package fosite_test import ( - "net/http" - "testing" - "context" - "fmt" + "net/http" + "testing" "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + . "github.com/ory/fosite" "github.com/ory/fosite/compose" "github.com/ory/fosite/internal" "github.com/ory/fosite/storage" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestAccessTokenFromRequestNoToken(t *testing.T) { diff --git a/introspection_request_handler_test.go b/introspection_request_handler_test.go index fec6fcd37..77e3c9aec 100644 --- a/introspection_request_handler_test.go +++ b/introspection_request_handler_test.go @@ -22,23 +22,22 @@ package fosite_test import ( + "context" + "fmt" "net/http" "net/url" "testing" - "fmt" - - "context" - "github.com/golang/mock/gomock" + "github.com/pkg/errors" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/ory/fosite" . "github.com/ory/fosite" "github.com/ory/fosite/compose" "github.com/ory/fosite/internal" "github.com/ory/fosite/storage" - "github.com/pkg/errors" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestIntrospectionResponse(t *testing.T) { diff --git a/introspection_response_writer_test.go b/introspection_response_writer_test.go index 284b73013..b9062814a 100644 --- a/introspection_response_writer_test.go +++ b/introspection_response_writer_test.go @@ -26,9 +26,10 @@ import ( "testing" "github.com/golang/mock/gomock" + "github.com/pkg/errors" + . "github.com/ory/fosite" "github.com/ory/fosite/internal" - "github.com/pkg/errors" ) func TestWriteIntrospectionError(t *testing.T) { diff --git a/oauth2.go b/oauth2.go index 20999b62b..a5550d3b6 100644 --- a/oauth2.go +++ b/oauth2.go @@ -22,11 +22,10 @@ package fosite import ( + "context" "net/http" "net/url" "time" - - "context" ) const MinParameterEntropy = 8 diff --git a/request_test.go b/request_test.go index be4c8c3c9..17258e787 100644 --- a/request_test.go +++ b/request_test.go @@ -26,8 +26,9 @@ import ( "testing" "time" - . "github.com/ory/fosite" "github.com/stretchr/testify/assert" + + . "github.com/ory/fosite" ) func TestRequest(t *testing.T) { diff --git a/revoke_handler.go b/revoke_handler.go index fe86d9d58..2e7cfa8a2 100644 --- a/revoke_handler.go +++ b/revoke_handler.go @@ -22,12 +22,11 @@ package fosite import ( + "context" "encoding/json" "fmt" "net/http" - "context" - "github.com/pkg/errors" ) diff --git a/revoke_handler_test.go b/revoke_handler_test.go index 035471607..35f27b352 100644 --- a/revoke_handler_test.go +++ b/revoke_handler_test.go @@ -22,18 +22,18 @@ package fosite_test import ( + "context" + "fmt" "net/http" "net/url" "testing" - "fmt" - "github.com/golang/mock/gomock" - . "github.com/ory/fosite" - "github.com/ory/fosite/internal" "github.com/pkg/errors" "github.com/stretchr/testify/assert" - "context" + + . "github.com/ory/fosite" + "github.com/ory/fosite/internal" ) func TestNewRevocationRequest(t *testing.T) { diff --git a/scope_strategy_test.go b/scope_strategy_test.go index 14647a1a1..4450a83d5 100644 --- a/scope_strategy_test.go +++ b/scope_strategy_test.go @@ -22,9 +22,8 @@ package fosite import ( - "testing" - "strings" + "testing" "github.com/stretchr/testify/assert" ) diff --git a/storage/memory.go b/storage/memory.go index 1bd757cd8..4d72d74cd 100644 --- a/storage/memory.go +++ b/storage/memory.go @@ -24,8 +24,9 @@ package storage import ( "context" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) type MemoryUserRelation struct { @@ -49,14 +50,14 @@ type MemoryStore struct { func NewMemoryStore() *MemoryStore { return &MemoryStore{ - Clients: make(map[string]fosite.Client), - AuthorizeCodes: make(map[string]StoreAuthorizeCode), - IDSessions: make(map[string]fosite.Requester), - AccessTokens: make(map[string]fosite.Requester), - Implicit: make(map[string]fosite.Requester), - RefreshTokens: make(map[string]fosite.Requester), - PKCES: make(map[string]fosite.Requester), - Users: make(map[string]MemoryUserRelation), + Clients: make(map[string]fosite.Client), + AuthorizeCodes: make(map[string]StoreAuthorizeCode), + IDSessions: make(map[string]fosite.Requester), + AccessTokens: make(map[string]fosite.Requester), + Implicit: make(map[string]fosite.Requester), + RefreshTokens: make(map[string]fosite.Requester), + PKCES: make(map[string]fosite.Requester), + Users: make(map[string]MemoryUserRelation), AccessTokenRequestIDs: make(map[string]string), RefreshTokenRequestIDs: make(map[string]string), } @@ -96,11 +97,11 @@ func NewExampleStore() *MemoryStore { Password: "secret", }, }, - AuthorizeCodes: map[string]StoreAuthorizeCode{}, - Implicit: map[string]fosite.Requester{}, - AccessTokens: map[string]fosite.Requester{}, - RefreshTokens: map[string]fosite.Requester{}, - PKCES: map[string]fosite.Requester{}, + AuthorizeCodes: map[string]StoreAuthorizeCode{}, + Implicit: map[string]fosite.Requester{}, + AccessTokens: map[string]fosite.Requester{}, + RefreshTokens: map[string]fosite.Requester{}, + PKCES: map[string]fosite.Requester{}, AccessTokenRequestIDs: map[string]string{}, RefreshTokenRequestIDs: map[string]string{}, } diff --git a/token/hmac/hmacsha.go b/token/hmac/hmacsha.go index 5c4989b3a..cdc0f38f2 100644 --- a/token/hmac/hmacsha.go +++ b/token/hmac/hmacsha.go @@ -31,8 +31,9 @@ import ( "sync" "github.com/gtank/cryptopasta" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) // HMACStrategy is responsible for generating and validating challenges. diff --git a/token/jwt/claims_id_token_test.go b/token/jwt/claims_id_token_test.go index 9910fec28..e27e0fce9 100644 --- a/token/jwt/claims_id_token_test.go +++ b/token/jwt/claims_id_token_test.go @@ -25,21 +25,22 @@ import ( "testing" "time" - . "github.com/ory/fosite/token/jwt" "github.com/stretchr/testify/assert" + + . "github.com/ory/fosite/token/jwt" ) var idTokenClaims = &IDTokenClaims{ - JTI: "foo-id", - Subject: "peter", - IssuedAt: time.Now().UTC().Round(time.Second), - Issuer: "fosite", - Audience: []string{"tests"}, - ExpiresAt: time.Now().UTC().Add(time.Hour).Round(time.Second), - AuthTime: time.Now().UTC(), - RequestedAt: time.Now().UTC(), - AccessTokenHash: "foobar", - CodeHash: "barfoo", + JTI: "foo-id", + Subject: "peter", + IssuedAt: time.Now().UTC().Round(time.Second), + Issuer: "fosite", + Audience: []string{"tests"}, + ExpiresAt: time.Now().UTC().Add(time.Hour).Round(time.Second), + AuthTime: time.Now().UTC(), + RequestedAt: time.Now().UTC(), + AccessTokenHash: "foobar", + CodeHash: "barfoo", AuthenticationContextClassReference: "acr", Extra: map[string]interface{}{ "foo": "bar", diff --git a/token/jwt/claims_jwt_test.go b/token/jwt/claims_jwt_test.go index 65f4bbf88..3669ef950 100644 --- a/token/jwt/claims_jwt_test.go +++ b/token/jwt/claims_jwt_test.go @@ -25,8 +25,9 @@ import ( "testing" "time" - . "github.com/ory/fosite/token/jwt" "github.com/stretchr/testify/assert" + + . "github.com/ory/fosite/token/jwt" ) var jwtClaims = &JWTClaims{ diff --git a/token/jwt/jwt.go b/token/jwt/jwt.go index 151706c9f..581d9c73e 100644 --- a/token/jwt/jwt.go +++ b/token/jwt/jwt.go @@ -25,16 +25,16 @@ package jwt import ( + "context" "crypto/rsa" "crypto/sha256" "fmt" "strings" - "context" - "github.com/dgrijalva/jwt-go" - "github.com/ory/fosite" "github.com/pkg/errors" + + "github.com/ory/fosite" ) type JWTStrategy interface { diff --git a/token/jwt/jwt_test.go b/token/jwt/jwt_test.go index 5a44b7410..5aed83896 100644 --- a/token/jwt/jwt_test.go +++ b/token/jwt/jwt_test.go @@ -22,16 +22,15 @@ package jwt import ( + "context" "strings" "testing" - "time" - "context" - - "github.com/ory/fosite/internal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/ory/fosite/internal" ) var header = &Headers{