From 5c8871317748cb76f6000c03af1095604a09235a Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Mon, 29 Jan 2018 20:48:40 +0000 Subject: [PATCH] Remove connectordata from other structs --- server/api_test.go | 1 - server/handlers.go | 37 +++++++++++++++++-------------------- storage/storage.go | 13 +++++-------- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/server/api_test.go b/server/api_test.go index 80a22486..a7891208 100644 --- a/server/api_test.go +++ b/server/api_test.go @@ -259,7 +259,6 @@ func TestRefreshToken(t *testing.T) { EmailVerified: true, Groups: []string{"a", "b"}, }, - ConnectorData: []byte(`{"some":"data"}`), } if err := s.CreateRefresh(r); err != nil { diff --git a/server/handlers.go b/server/handlers.go index 1c320b29..08bf5d04 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -490,7 +490,6 @@ func (s *Server) finalizeLogin(identity connector.Identity, authReq storage.Auth updater := func(a storage.AuthRequest) (storage.AuthRequest, error) { a.LoggedIn = true a.Claims = claims - a.ConnectorData = identity.ConnectorData return a, nil } if err := s.storage.UpdateAuthRequest(authReq.ID, updater); err != nil { @@ -620,15 +619,14 @@ func (s *Server) sendCodeResponse(w http.ResponseWriter, r *http.Request, authRe switch responseType { case responseTypeCode: code = storage.AuthCode{ - ID: storage.NewID(), - ClientID: authReq.ClientID, - ConnectorID: authReq.ConnectorID, - Nonce: authReq.Nonce, - Scopes: authReq.Scopes, - Claims: authReq.Claims, - Expiry: s.now().Add(time.Minute * 30), - RedirectURI: authReq.RedirectURI, - ConnectorData: authReq.ConnectorData, + ID: storage.NewID(), + ClientID: authReq.ClientID, + ConnectorID: authReq.ConnectorID, + Nonce: authReq.Nonce, + Scopes: authReq.Scopes, + Claims: authReq.Claims, + Expiry: s.now().Add(time.Minute * 30), + RedirectURI: authReq.RedirectURI, } if err := s.storage.CreateAuthCode(code); err != nil { s.logger.Errorf("Failed to create auth code: %v", err) @@ -824,16 +822,15 @@ func (s *Server) handleAuthCode(w http.ResponseWriter, r *http.Request, client s var refreshToken string if reqRefresh { refresh := storage.RefreshToken{ - ID: storage.NewID(), - Token: storage.NewID(), - ClientID: authCode.ClientID, - ConnectorID: authCode.ConnectorID, - Scopes: authCode.Scopes, - Claims: authCode.Claims, - Nonce: authCode.Nonce, - ConnectorData: authCode.ConnectorData, - CreatedAt: s.now(), - LastUsed: s.now(), + ID: storage.NewID(), + Token: storage.NewID(), + ClientID: authCode.ClientID, + ConnectorID: authCode.ConnectorID, + Scopes: authCode.Scopes, + Claims: authCode.Claims, + Nonce: authCode.Nonce, + CreatedAt: s.now(), + LastUsed: s.now(), } token := &internal.RefreshToken{ RefreshId: refresh.ID, diff --git a/storage/storage.go b/storage/storage.go index cb2a7e0c..85a60965 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -181,8 +181,7 @@ type AuthRequest struct { // The connector used to login the user and any data the connector wishes to persists. // Set when the user authenticates. - ConnectorID string - ConnectorData []byte + ConnectorID string } // AuthCode represents a code which can be exchanged for an OAuth2 token response. @@ -213,9 +212,8 @@ type AuthCode struct { Scopes []string // Authentication data provided by an upstream source. - ConnectorID string - ConnectorData []byte - Claims Claims + ConnectorID string + Claims Claims Expiry time.Time } @@ -237,9 +235,8 @@ type RefreshToken struct { ClientID string // Authentication data provided by an upstream source. - ConnectorID string - ConnectorData []byte - Claims Claims + ConnectorID string + Claims Claims // Scopes present in the initial request. Refresh requests may specify a set // of scopes different from the initial request when refreshing a token,