client: allow the expiry time to be specified for new keys

Adds a parameter for create key that allows a number of seconds
(less than 90) to be specified for new keys.

Fixes https://github.com/tailscale/tailscale/issues/7965

Signed-off-by: Matthew Brown <matthew@bargrove.com>
This commit is contained in:
Matt Brown
2023-05-12 06:05:18 +01:00
committed by GitHub
parent 85215ed58a
commit 9b6e48658f
4 changed files with 21 additions and 9 deletions

View File

@ -807,14 +807,14 @@ type fakeTSClient struct {
deleted []string
}
func (c *fakeTSClient) CreateKey(ctx context.Context, caps tailscale.KeyCapabilities) (string, *tailscale.Key, error) {
func (c *fakeTSClient) CreateKey(ctx context.Context, caps tailscale.KeyCapabilities, expiry time.Duration) (string, *tailscale.Key, error) {
c.Lock()
defer c.Unlock()
c.keyRequests = append(c.keyRequests, caps)
k := &tailscale.Key{
ID: "key",
Created: time.Now(),
Expires: time.Now().Add(24 * time.Hour),
Expires: time.Now().Add(expiry),
Capabilities: caps,
}
return "secret-authkey", k, nil