Update Kubernetes storage backend

This commit is contained in:
Joel Speed 2018-01-29 21:15:01 +00:00
parent c54f1656c7
commit 7a76c767fe
No known key found for this signature in database
GPG key ID: 6E80578D6751DEFB

View file

@ -265,8 +265,7 @@ type AuthRequest struct {
// with a backend. // with a backend.
Claims Claims `json:"claims,omitempty"` Claims Claims `json:"claims,omitempty"`
// The connector used to login the user. Set when the user authenticates. // The connector used to login the user. Set when the user authenticates.
ConnectorID string `json:"connectorID,omitempty"` ConnectorID string `json:"connectorID,omitempty"`
ConnectorData []byte `json:"connectorData,omitempty"`
Expiry time.Time `json:"expiry"` Expiry time.Time `json:"expiry"`
} }
@ -290,7 +289,6 @@ func toStorageAuthRequest(req AuthRequest) storage.AuthRequest {
ForceApprovalPrompt: req.ForceApprovalPrompt, ForceApprovalPrompt: req.ForceApprovalPrompt,
LoggedIn: req.LoggedIn, LoggedIn: req.LoggedIn,
ConnectorID: req.ConnectorID, ConnectorID: req.ConnectorID,
ConnectorData: req.ConnectorData,
Expiry: req.Expiry, Expiry: req.Expiry,
Claims: toStorageClaims(req.Claims), Claims: toStorageClaims(req.Claims),
} }
@ -316,7 +314,6 @@ func (cli *client) fromStorageAuthRequest(a storage.AuthRequest) AuthRequest {
LoggedIn: a.LoggedIn, LoggedIn: a.LoggedIn,
ForceApprovalPrompt: a.ForceApprovalPrompt, ForceApprovalPrompt: a.ForceApprovalPrompt,
ConnectorID: a.ConnectorID, ConnectorID: a.ConnectorID,
ConnectorData: a.ConnectorData,
Expiry: a.Expiry, Expiry: a.Expiry,
Claims: fromStorageClaims(a.Claims), Claims: fromStorageClaims(a.Claims),
} }
@ -411,28 +408,26 @@ func (cli *client) fromStorageAuthCode(a storage.AuthCode) AuthCode {
Name: a.ID, Name: a.ID,
Namespace: cli.namespace, Namespace: cli.namespace,
}, },
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,
} }
} }
func toStorageAuthCode(a AuthCode) storage.AuthCode { func toStorageAuthCode(a AuthCode) storage.AuthCode {
return storage.AuthCode{ return storage.AuthCode{
ID: a.ObjectMeta.Name, ID: a.ObjectMeta.Name,
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: toStorageClaims(a.Claims),
Claims: toStorageClaims(a.Claims), Expiry: a.Expiry,
Expiry: a.Expiry,
} }
} }
@ -466,16 +461,15 @@ type RefreshList struct {
func toStorageRefreshToken(r RefreshToken) storage.RefreshToken { func toStorageRefreshToken(r RefreshToken) storage.RefreshToken {
return storage.RefreshToken{ return storage.RefreshToken{
ID: r.ObjectMeta.Name, ID: r.ObjectMeta.Name,
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),
} }
} }
@ -489,15 +483,14 @@ func (cli *client) fromStorageRefreshToken(r storage.RefreshToken) RefreshToken
Name: r.ID, Name: r.ID,
Namespace: cli.namespace, Namespace: cli.namespace,
}, },
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),
} }
} }
@ -552,9 +545,10 @@ type OfflineSessions struct {
k8sapi.TypeMeta `json:",inline"` k8sapi.TypeMeta `json:",inline"`
k8sapi.ObjectMeta `json:"metadata,omitempty"` k8sapi.ObjectMeta `json:"metadata,omitempty"`
UserID string `json:"userID,omitempty"` UserID string `json:"userID,omitempty"`
ConnID string `json:"connID,omitempty"` ConnID string `json:"connID,omitempty"`
Refresh map[string]*storage.RefreshTokenRef `json:"refresh,omitempty"` Refresh map[string]*storage.RefreshTokenRef `json:"refresh,omitempty"`
ConnectorData []byte `json:"connectorData,omitempty"`
} }
func (cli *client) fromStorageOfflineSessions(o storage.OfflineSessions) OfflineSessions { func (cli *client) fromStorageOfflineSessions(o storage.OfflineSessions) OfflineSessions {
@ -567,17 +561,19 @@ func (cli *client) fromStorageOfflineSessions(o storage.OfflineSessions) Offline
Name: cli.offlineTokenName(o.UserID, o.ConnID), Name: cli.offlineTokenName(o.UserID, o.ConnID),
Namespace: cli.namespace, Namespace: cli.namespace,
}, },
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.