Fix ETCD storage backend
This commit is contained in:
		| @@ -16,24 +16,22 @@ type AuthCode struct { | |||||||
| 	Nonce       string   `json:"nonce,omitempty"` | 	Nonce       string   `json:"nonce,omitempty"` | ||||||
| 	Scopes      []string `json:"scopes,omitempty"` | 	Scopes      []string `json:"scopes,omitempty"` | ||||||
|  |  | ||||||
| 	ConnectorID   string `json:"connectorID,omitempty"` | 	ConnectorID string `json:"connectorID,omitempty"` | ||||||
| 	ConnectorData []byte `json:"connectorData,omitempty"` | 	Claims      Claims `json:"claims,omitempty"` | ||||||
| 	Claims        Claims `json:"claims,omitempty"` |  | ||||||
|  |  | ||||||
| 	Expiry time.Time `json:"expiry"` | 	Expiry time.Time `json:"expiry"` | ||||||
| } | } | ||||||
|  |  | ||||||
| func fromStorageAuthCode(a storage.AuthCode) AuthCode { | func fromStorageAuthCode(a storage.AuthCode) AuthCode { | ||||||
| 	return AuthCode{ | 	return AuthCode{ | ||||||
| 		ID:            a.ID, | 		ID:          a.ID, | ||||||
| 		ClientID:      a.ClientID, | 		ClientID:    a.ClientID, | ||||||
| 		RedirectURI:   a.RedirectURI, | 		RedirectURI: a.RedirectURI, | ||||||
| 		ConnectorID:   a.ConnectorID, | 		ConnectorID: a.ConnectorID, | ||||||
| 		ConnectorData: a.ConnectorData, | 		Nonce:       a.Nonce, | ||||||
| 		Nonce:         a.Nonce, | 		Scopes:      a.Scopes, | ||||||
| 		Scopes:        a.Scopes, | 		Claims:      fromStorageClaims(a.Claims), | ||||||
| 		Claims:        fromStorageClaims(a.Claims), | 		Expiry:      a.Expiry, | ||||||
| 		Expiry:        a.Expiry, |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -74,7 +72,6 @@ func fromStorageAuthRequest(a storage.AuthRequest) AuthRequest { | |||||||
| 		LoggedIn:            a.LoggedIn, | 		LoggedIn:            a.LoggedIn, | ||||||
| 		Claims:              fromStorageClaims(a.Claims), | 		Claims:              fromStorageClaims(a.Claims), | ||||||
| 		ConnectorID:         a.ConnectorID, | 		ConnectorID:         a.ConnectorID, | ||||||
| 		ConnectorData:       a.ConnectorData, |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -90,7 +87,6 @@ func toStorageAuthRequest(a AuthRequest) storage.AuthRequest { | |||||||
| 		ForceApprovalPrompt: a.ForceApprovalPrompt, | 		ForceApprovalPrompt: a.ForceApprovalPrompt, | ||||||
| 		LoggedIn:            a.LoggedIn, | 		LoggedIn:            a.LoggedIn, | ||||||
| 		ConnectorID:         a.ConnectorID, | 		ConnectorID:         a.ConnectorID, | ||||||
| 		ConnectorData:       a.ConnectorData, |  | ||||||
| 		Expiry:              a.Expiry, | 		Expiry:              a.Expiry, | ||||||
| 		Claims:              toStorageClaims(a.Claims), | 		Claims:              toStorageClaims(a.Claims), | ||||||
| 	} | 	} | ||||||
| @@ -118,31 +114,29 @@ type RefreshToken struct { | |||||||
|  |  | ||||||
| func toStorageRefreshToken(r RefreshToken) storage.RefreshToken { | func toStorageRefreshToken(r RefreshToken) storage.RefreshToken { | ||||||
| 	return storage.RefreshToken{ | 	return storage.RefreshToken{ | ||||||
| 		ID:            r.ID, | 		ID:          r.ID, | ||||||
| 		Token:         r.Token, | 		Token:       r.Token, | ||||||
| 		CreatedAt:     r.CreatedAt, | 		CreatedAt:   r.CreatedAt, | ||||||
| 		LastUsed:      r.LastUsed, | 		LastUsed:    r.LastUsed, | ||||||
| 		ClientID:      r.ClientID, | 		ClientID:    r.ClientID, | ||||||
| 		ConnectorID:   r.ConnectorID, | 		ConnectorID: r.ConnectorID, | ||||||
| 		ConnectorData: r.ConnectorData, | 		Scopes:      r.Scopes, | ||||||
| 		Scopes:        r.Scopes, | 		Nonce:       r.Nonce, | ||||||
| 		Nonce:         r.Nonce, | 		Claims:      toStorageClaims(r.Claims), | ||||||
| 		Claims:        toStorageClaims(r.Claims), |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func fromStorageRefreshToken(r storage.RefreshToken) RefreshToken { | func fromStorageRefreshToken(r storage.RefreshToken) RefreshToken { | ||||||
| 	return RefreshToken{ | 	return RefreshToken{ | ||||||
| 		ID:            r.ID, | 		ID:          r.ID, | ||||||
| 		Token:         r.Token, | 		Token:       r.Token, | ||||||
| 		CreatedAt:     r.CreatedAt, | 		CreatedAt:   r.CreatedAt, | ||||||
| 		LastUsed:      r.LastUsed, | 		LastUsed:    r.LastUsed, | ||||||
| 		ClientID:      r.ClientID, | 		ClientID:    r.ClientID, | ||||||
| 		ConnectorID:   r.ConnectorID, | 		ConnectorID: r.ConnectorID, | ||||||
| 		ConnectorData: r.ConnectorData, | 		Scopes:      r.Scopes, | ||||||
| 		Scopes:        r.Scopes, | 		Nonce:       r.Nonce, | ||||||
| 		Nonce:         r.Nonce, | 		Claims:      fromStorageClaims(r.Claims), | ||||||
| 		Claims:        fromStorageClaims(r.Claims), |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -188,24 +182,27 @@ type Keys struct { | |||||||
|  |  | ||||||
| // OfflineSessions is a mirrored struct from storage with JSON struct tags | // OfflineSessions is a mirrored struct from storage with JSON struct tags | ||||||
| type OfflineSessions struct { | type OfflineSessions struct { | ||||||
| 	UserID  string                              `json:"user_id,omitempty"` | 	UserID        string                              `json:"user_id,omitempty"` | ||||||
| 	ConnID  string                              `json:"conn_id,omitempty"` | 	ConnID        string                              `json:"conn_id,omitempty"` | ||||||
| 	Refresh map[string]*storage.RefreshTokenRef `json:"refresh,omitempty"` | 	Refresh       map[string]*storage.RefreshTokenRef `json:"refresh,omitempty"` | ||||||
|  | 	ConnectorData []byte                              `json:"connectorData,omitempty"` | ||||||
| } | } | ||||||
|  |  | ||||||
| func fromStorageOfflineSessions(o storage.OfflineSessions) OfflineSessions { | func fromStorageOfflineSessions(o storage.OfflineSessions) OfflineSessions { | ||||||
| 	return OfflineSessions{ | 	return OfflineSessions{ | ||||||
| 		UserID:  o.UserID, | 		UserID:        o.UserID, | ||||||
| 		ConnID:  o.ConnID, | 		ConnID:        o.ConnID, | ||||||
| 		Refresh: o.Refresh, | 		Refresh:       o.Refresh, | ||||||
|  | 		ConnectorData: o.ConnectorData, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func toStorageOfflineSessions(o OfflineSessions) storage.OfflineSessions { | func toStorageOfflineSessions(o OfflineSessions) storage.OfflineSessions { | ||||||
| 	s := storage.OfflineSessions{ | 	s := storage.OfflineSessions{ | ||||||
| 		UserID:  o.UserID, | 		UserID:        o.UserID, | ||||||
| 		ConnID:  o.ConnID, | 		ConnID:        o.ConnID, | ||||||
| 		Refresh: o.Refresh, | 		Refresh:       o.Refresh, | ||||||
|  | 		ConnectorData: o.ConnectorData, | ||||||
| 	} | 	} | ||||||
| 	if s.Refresh == nil { | 	if s.Refresh == nil { | ||||||
| 		// Server code assumes this will be non-nil. | 		// Server code assumes this will be non-nil. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user