mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
feat: add cache abstraction for fetching signing keys (#14777)
- Adds the database implementation for fetching and caching keys used for JWT signing. It's been merged into the `keyrotate` pkg and renamed to `cryptokeys` since they're coupled concepts.
This commit is contained in:
@ -17,6 +17,7 @@ import (
|
||||
agpl "github.com/coder/coder/v2/coderd"
|
||||
"github.com/coder/coder/v2/coderd/audit"
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/database/db2sdk"
|
||||
"github.com/coder/coder/v2/coderd/database/dbauthz"
|
||||
"github.com/coder/coder/v2/coderd/database/dbtime"
|
||||
"github.com/coder/coder/v2/coderd/httpapi"
|
||||
@ -733,7 +734,7 @@ func (api *API) workspaceProxyCryptoKeys(rw http.ResponseWriter, r *http.Request
|
||||
}
|
||||
|
||||
httpapi.Write(ctx, rw, http.StatusOK, wsproxysdk.CryptoKeysResponse{
|
||||
CryptoKeys: fromDBCryptoKeys(keys),
|
||||
CryptoKeys: db2sdk.CryptoKeys(keys),
|
||||
})
|
||||
}
|
||||
|
||||
@ -994,17 +995,3 @@ func (w *workspaceProxiesFetchUpdater) Fetch(ctx context.Context) (codersdk.Regi
|
||||
func (w *workspaceProxiesFetchUpdater) Update(ctx context.Context) error {
|
||||
return w.updateFunc(ctx)
|
||||
}
|
||||
|
||||
func fromDBCryptoKeys(keys []database.CryptoKey) []wsproxysdk.CryptoKey {
|
||||
wskeys := make([]wsproxysdk.CryptoKey, 0, len(keys))
|
||||
for _, key := range keys {
|
||||
wskeys = append(wskeys, wsproxysdk.CryptoKey{
|
||||
Feature: wsproxysdk.CryptoKeyFeature(key.Feature),
|
||||
Sequence: key.Sequence,
|
||||
StartsAt: key.StartsAt.UTC(),
|
||||
DeletesAt: key.DeletesAt.Time.UTC(),
|
||||
Secret: key.Secret.String,
|
||||
})
|
||||
}
|
||||
return wskeys
|
||||
}
|
||||
|
Reference in New Issue
Block a user