generated from theparanoids/.github
/
opt.go
42 lines (36 loc) · 1.3 KB
/
opt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2022 Yahoo Inc.
// Licensed under the terms of the Apache License 2.0. Please see LICENSE file in project root for terms.
package ssh
import (
"github.com/theparanoids/ysshra/sshutils/key"
"golang.org/x/crypto/ssh/agent"
)
const (
defaultKeyValiditySec = 12 * 3600 // 12 hours
defaultPublicKeyAlgo = key.ECDSAsecp384r1
defaultPrivateKeyLabel = "private-key"
defaultCertLabel = "certificate"
)
// keyFilter is the function to determine whether a key is the target key or cert for that handler.
// It's useful to access/remove the keys from the SSH agent.
type keyFilter func(key *agent.Key) bool
// DefaultKeyOpt is the default option of keyAgent.
var DefaultKeyOpt = KeyOpt{
KeyRefreshFilter: func(key *agent.Key) bool {
// Default key filter does not filter any keys.
return false
},
PrivateKeyValiditySec: defaultKeyValiditySec,
PublicKeyAlgo: defaultPublicKeyAlgo,
PrivateKeyLabel: defaultPrivateKeyLabel,
CertLabel: defaultCertLabel,
}
// KeyOpt is the option for AgentKey.
type KeyOpt struct {
// keyFilter is the function to determine whether a key is the target key or cert for that handler.
KeyRefreshFilter keyFilter
PrivateKeyValiditySec uint32
PrivateKeyLabel string
CertLabel string
PublicKeyAlgo key.PublicKeyAlgo
}