forked from open-component-model/ocm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidentity.go
48 lines (39 loc) · 1.48 KB
/
identity.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
43
44
45
46
47
48
package identity
import (
"ocm.software/ocm/api/credentials/cpi"
"ocm.software/ocm/api/credentials/identity/hostpath"
"ocm.software/ocm/api/utils/listformat"
)
// CONSUMER_TYPE is the OCI registry type.
const CONSUMER_TYPE = "OCIRegistry"
// used identity properties.
const (
ID_TYPE = hostpath.ID_TYPE
ID_HOSTNAME = hostpath.ID_HOSTNAME
ID_PORT = hostpath.ID_PORT
ID_PATHPREFIX = hostpath.ID_PATHPREFIX
ID_SCHEME = hostpath.ID_SCHEME
)
// used credential properties.
const (
ATTR_USERNAME = cpi.ATTR_USERNAME
ATTR_PASSWORD = cpi.ATTR_PASSWORD
ATTR_IDENTITY_TOKEN = cpi.ATTR_IDENTITY_TOKEN
ATTR_CERTIFICATE_AUTHORITY = cpi.ATTR_CERTIFICATE_AUTHORITY
)
func init() {
attrs := listformat.FormatListElements("", listformat.StringElementDescriptionList{
ATTR_USERNAME, "the basic auth username",
ATTR_PASSWORD, "the basic auth password",
ATTR_IDENTITY_TOKEN, "the bearer token used for non-basic auth authorization",
ATTR_CERTIFICATE_AUTHORITY, "the certificate authority certificate used to verify certificates",
})
cpi.RegisterStandardIdentity(CONSUMER_TYPE, IdentityMatcher, `OCI registry credential matcher
It matches the <code>`+CONSUMER_TYPE+`</code> consumer type and additionally acts like
the <code>`+hostpath.IDENTITY_TYPE+`</code> type.`,
attrs)
}
var identityMatcher = hostpath.IdentityMatcher(CONSUMER_TYPE)
func IdentityMatcher(pattern, cur, id cpi.ConsumerIdentity) bool {
return identityMatcher(pattern, cur, id)
}