repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
gravitational/teleport
lib/sshutils/signer.go
NewSigner
func NewSigner(keyBytes, certBytes []byte) (ssh.Signer, error) { keySigner, err := ssh.ParsePrivateKey(keyBytes) if err != nil { return nil, trace.Wrap(err, "failed to parse SSH private key") } pubkey, _, _, _, err := ssh.ParseAuthorizedKey(certBytes) if err != nil { return nil, trace.Wrap(err, "failed to par...
go
func NewSigner(keyBytes, certBytes []byte) (ssh.Signer, error) { keySigner, err := ssh.ParsePrivateKey(keyBytes) if err != nil { return nil, trace.Wrap(err, "failed to parse SSH private key") } pubkey, _, _, _, err := ssh.ParseAuthorizedKey(certBytes) if err != nil { return nil, trace.Wrap(err, "failed to par...
[ "func", "NewSigner", "(", "keyBytes", ",", "certBytes", "[", "]", "byte", ")", "(", "ssh", ".", "Signer", ",", "error", ")", "{", "keySigner", ",", "err", ":=", "ssh", ".", "ParsePrivateKey", "(", "keyBytes", ")", "\n", "if", "err", "!=", "nil", "{",...
// NewSigner returns new ssh Signer from private key + certificate pair. The // signer can be used to create "auth methods" i.e. login into Teleport SSH // servers.
[ "NewSigner", "returns", "new", "ssh", "Signer", "from", "private", "key", "+", "certificate", "pair", ".", "The", "signer", "can", "be", "used", "to", "create", "auth", "methods", "i", ".", "e", ".", "login", "into", "Teleport", "SSH", "servers", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/signer.go#L29-L46
train
gravitational/teleport
lib/sshutils/signer.go
CryptoPublicKey
func CryptoPublicKey(publicKey []byte) (crypto.PublicKey, error) { // reuse the same RSA keys for SSH and TLS keys pubKey, _, _, _, err := ssh.ParseAuthorizedKey(publicKey) if err != nil { return nil, trace.Wrap(err) } cryptoPubKey, ok := pubKey.(ssh.CryptoPublicKey) if !ok { return nil, trace.BadParameter("e...
go
func CryptoPublicKey(publicKey []byte) (crypto.PublicKey, error) { // reuse the same RSA keys for SSH and TLS keys pubKey, _, _, _, err := ssh.ParseAuthorizedKey(publicKey) if err != nil { return nil, trace.Wrap(err) } cryptoPubKey, ok := pubKey.(ssh.CryptoPublicKey) if !ok { return nil, trace.BadParameter("e...
[ "func", "CryptoPublicKey", "(", "publicKey", "[", "]", "byte", ")", "(", "crypto", ".", "PublicKey", ",", "error", ")", "{", "// reuse the same RSA keys for SSH and TLS keys", "pubKey", ",", "_", ",", "_", ",", "_", ",", "err", ":=", "ssh", ".", "ParseAuthor...
// CryptoPublicKey extracts public key from RSA public key in authorized_keys format
[ "CryptoPublicKey", "extracts", "public", "key", "from", "RSA", "public", "key", "in", "authorized_keys", "format" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/signer.go#L49-L60
train
gravitational/teleport
lib/tlsca/parsegen.go
ClusterName
func ClusterName(subject pkix.Name) (string, error) { if len(subject.Organization) == 0 { return "", trace.BadParameter("missing subject organization") } return subject.Organization[0], nil }
go
func ClusterName(subject pkix.Name) (string, error) { if len(subject.Organization) == 0 { return "", trace.BadParameter("missing subject organization") } return subject.Organization[0], nil }
[ "func", "ClusterName", "(", "subject", "pkix", ".", "Name", ")", "(", "string", ",", "error", ")", "{", "if", "len", "(", "subject", ".", "Organization", ")", "==", "0", "{", "return", "\"", "\"", ",", "trace", ".", "BadParameter", "(", "\"", "\"", ...
// ClusterName returns cluster name from organization
[ "ClusterName", "returns", "cluster", "name", "from", "organization" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/tlsca/parsegen.go#L36-L41
train
gravitational/teleport
lib/tlsca/parsegen.go
GenerateRSAPrivateKeyPEM
func GenerateRSAPrivateKeyPEM() ([]byte, error) { priv, err := rsa.GenerateKey(rand.Reader, teleport.RSAKeySize) if err != nil { return nil, trace.Wrap(err) } return pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)}), nil }
go
func GenerateRSAPrivateKeyPEM() ([]byte, error) { priv, err := rsa.GenerateKey(rand.Reader, teleport.RSAKeySize) if err != nil { return nil, trace.Wrap(err) } return pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)}), nil }
[ "func", "GenerateRSAPrivateKeyPEM", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "priv", ",", "err", ":=", "rsa", ".", "GenerateKey", "(", "rand", ".", "Reader", ",", "teleport", ".", "RSAKeySize", ")", "\n", "if", "err", "!=", "nil", "{"...
// GenerateRSAPrivateKeyPEM generates new RSA private key and returns PEM encoded bytes
[ "GenerateRSAPrivateKeyPEM", "generates", "new", "RSA", "private", "key", "and", "returns", "PEM", "encoded", "bytes" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/tlsca/parsegen.go#L44-L50
train
gravitational/teleport
lib/tlsca/parsegen.go
ParsePublicKeyPEM
func ParsePublicKeyPEM(bytes []byte) (interface{}, error) { block, _ := pem.Decode(bytes) if block == nil { return nil, trace.BadParameter("expected PEM-encoded block") } return ParsePublicKeyDER(block.Bytes) }
go
func ParsePublicKeyPEM(bytes []byte) (interface{}, error) { block, _ := pem.Decode(bytes) if block == nil { return nil, trace.BadParameter("expected PEM-encoded block") } return ParsePublicKeyDER(block.Bytes) }
[ "func", "ParsePublicKeyPEM", "(", "bytes", "[", "]", "byte", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "block", ",", "_", ":=", "pem", ".", "Decode", "(", "bytes", ")", "\n", "if", "block", "==", "nil", "{", "return", "nil", ",", "...
// ParsePublicKeyPEM parses public key PEM
[ "ParsePublicKeyPEM", "parses", "public", "key", "PEM" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/tlsca/parsegen.go#L160-L166
train
gravitational/teleport
lib/tlsca/parsegen.go
ParsePublicKeyDER
func ParsePublicKeyDER(der []byte) (crypto.PublicKey, error) { generalKey, err := x509.ParsePKIXPublicKey(der) if err != nil { return nil, trace.Wrap(err) } return generalKey, nil }
go
func ParsePublicKeyDER(der []byte) (crypto.PublicKey, error) { generalKey, err := x509.ParsePKIXPublicKey(der) if err != nil { return nil, trace.Wrap(err) } return generalKey, nil }
[ "func", "ParsePublicKeyDER", "(", "der", "[", "]", "byte", ")", "(", "crypto", ".", "PublicKey", ",", "error", ")", "{", "generalKey", ",", "err", ":=", "x509", ".", "ParsePKIXPublicKey", "(", "der", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// ParsePublicKeyDER parses unencrypted DER-encoded publice key
[ "ParsePublicKeyDER", "parses", "unencrypted", "DER", "-", "encoded", "publice", "key" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/tlsca/parsegen.go#L169-L175
train
gravitational/teleport
lib/tlsca/parsegen.go
MarshalPublicKeyFromPrivateKeyPEM
func MarshalPublicKeyFromPrivateKeyPEM(privateKey crypto.PrivateKey) ([]byte, error) { rsaPrivateKey, ok := privateKey.(*rsa.PrivateKey) if !ok { return nil, trace.BadParameter("expected RSA key") } rsaPublicKey := rsaPrivateKey.Public() derBytes, err := x509.MarshalPKIXPublicKey(rsaPublicKey) if err != nil { ...
go
func MarshalPublicKeyFromPrivateKeyPEM(privateKey crypto.PrivateKey) ([]byte, error) { rsaPrivateKey, ok := privateKey.(*rsa.PrivateKey) if !ok { return nil, trace.BadParameter("expected RSA key") } rsaPublicKey := rsaPrivateKey.Public() derBytes, err := x509.MarshalPKIXPublicKey(rsaPublicKey) if err != nil { ...
[ "func", "MarshalPublicKeyFromPrivateKeyPEM", "(", "privateKey", "crypto", ".", "PrivateKey", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "rsaPrivateKey", ",", "ok", ":=", "privateKey", ".", "(", "*", "rsa", ".", "PrivateKey", ")", "\n", "if", "!", ...
// MarshalPublicKeyFromPrivateKeyPEM extracts public key from private key // and returns PEM marshalled key
[ "MarshalPublicKeyFromPrivateKeyPEM", "extracts", "public", "key", "from", "private", "key", "and", "returns", "PEM", "marshalled", "key" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/tlsca/parsegen.go#L179-L190
train
gravitational/teleport
lib/auth/init.go
isFirstStart
func isFirstStart(authServer *AuthServer, cfg InitConfig) (bool, error) { // check if the CA exists? _, err := authServer.GetCertAuthority( services.CertAuthID{ DomainName: cfg.ClusterName.GetClusterName(), Type: services.HostCA, }, false) if err != nil { if !trace.IsNotFound(err) { return false...
go
func isFirstStart(authServer *AuthServer, cfg InitConfig) (bool, error) { // check if the CA exists? _, err := authServer.GetCertAuthority( services.CertAuthID{ DomainName: cfg.ClusterName.GetClusterName(), Type: services.HostCA, }, false) if err != nil { if !trace.IsNotFound(err) { return false...
[ "func", "isFirstStart", "(", "authServer", "*", "AuthServer", ",", "cfg", "InitConfig", ")", "(", "bool", ",", "error", ")", "{", "// check if the CA exists?", "_", ",", "err", ":=", "authServer", ".", "GetCertAuthority", "(", "services", ".", "CertAuthID", "{...
// isFirstStart returns 'true' if the auth server is starting for the 1st time // on this server.
[ "isFirstStart", "returns", "true", "if", "the", "auth", "server", "is", "starting", "for", "the", "1st", "time", "on", "this", "server", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L476-L491
train
gravitational/teleport
lib/auth/init.go
GenerateIdentity
func GenerateIdentity(a *AuthServer, id IdentityID, additionalPrincipals, dnsNames []string) (*Identity, error) { keys, err := a.GenerateServerKeys(GenerateServerKeysRequest{ HostID: id.HostUUID, NodeName: id.NodeName, Roles: teleport.Roles{id.Role}, AdditionalPrincipal...
go
func GenerateIdentity(a *AuthServer, id IdentityID, additionalPrincipals, dnsNames []string) (*Identity, error) { keys, err := a.GenerateServerKeys(GenerateServerKeysRequest{ HostID: id.HostUUID, NodeName: id.NodeName, Roles: teleport.Roles{id.Role}, AdditionalPrincipal...
[ "func", "GenerateIdentity", "(", "a", "*", "AuthServer", ",", "id", "IdentityID", ",", "additionalPrincipals", ",", "dnsNames", "[", "]", "string", ")", "(", "*", "Identity", ",", "error", ")", "{", "keys", ",", "err", ":=", "a", ".", "GenerateServerKeys",...
// GenerateIdentity generates identity for the auth server
[ "GenerateIdentity", "generates", "identity", "for", "the", "auth", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L494-L506
train
gravitational/teleport
lib/auth/init.go
String
func (i *Identity) String() string { var out []string if i.XCert != nil { out = append(out, fmt.Sprintf("cert(%v issued by %v:%v)", i.XCert.Subject.CommonName, i.XCert.Issuer.CommonName, i.XCert.Issuer.SerialNumber)) } for j := range i.TLSCACertsBytes { cert, err := tlsca.ParseCertificatePEM(i.TLSCACertsBytes[j...
go
func (i *Identity) String() string { var out []string if i.XCert != nil { out = append(out, fmt.Sprintf("cert(%v issued by %v:%v)", i.XCert.Subject.CommonName, i.XCert.Issuer.CommonName, i.XCert.Issuer.SerialNumber)) } for j := range i.TLSCACertsBytes { cert, err := tlsca.ParseCertificatePEM(i.TLSCACertsBytes[j...
[ "func", "(", "i", "*", "Identity", ")", "String", "(", ")", "string", "{", "var", "out", "[", "]", "string", "\n", "if", "i", ".", "XCert", "!=", "nil", "{", "out", "=", "append", "(", "out", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", ...
// String returns user-friendly representation of the identity.
[ "String", "returns", "user", "-", "friendly", "representation", "of", "the", "identity", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L534-L548
train
gravitational/teleport
lib/auth/init.go
CertInfo
func CertInfo(cert *x509.Certificate) string { return fmt.Sprintf("cert(%v issued by %v:%v)", cert.Subject.CommonName, cert.Issuer.CommonName, cert.Issuer.SerialNumber) }
go
func CertInfo(cert *x509.Certificate) string { return fmt.Sprintf("cert(%v issued by %v:%v)", cert.Subject.CommonName, cert.Issuer.CommonName, cert.Issuer.SerialNumber) }
[ "func", "CertInfo", "(", "cert", "*", "x509", ".", "Certificate", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cert", ".", "Subject", ".", "CommonName", ",", "cert", ".", "Issuer", ".", "CommonName", ",", "cert", ".", "...
// CertInfo returns diagnostic information about certificate
[ "CertInfo", "returns", "diagnostic", "information", "about", "certificate" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L551-L553
train
gravitational/teleport
lib/auth/init.go
TLSCertInfo
func TLSCertInfo(cert *tls.Certificate) string { x509cert, err := x509.ParseCertificate(cert.Certificate[0]) if err != nil { return err.Error() } return CertInfo(x509cert) }
go
func TLSCertInfo(cert *tls.Certificate) string { x509cert, err := x509.ParseCertificate(cert.Certificate[0]) if err != nil { return err.Error() } return CertInfo(x509cert) }
[ "func", "TLSCertInfo", "(", "cert", "*", "tls", ".", "Certificate", ")", "string", "{", "x509cert", ",", "err", ":=", "x509", ".", "ParseCertificate", "(", "cert", ".", "Certificate", "[", "0", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// TLSCertInfo returns diagnostic information about certificate
[ "TLSCertInfo", "returns", "diagnostic", "information", "about", "certificate" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L556-L562
train
gravitational/teleport
lib/auth/init.go
CertAuthorityInfo
func CertAuthorityInfo(ca services.CertAuthority) string { var out []string for _, keyPair := range ca.GetTLSKeyPairs() { cert, err := tlsca.ParseCertificatePEM(keyPair.Cert) if err != nil { out = append(out, err.Error()) } else { out = append(out, fmt.Sprintf("trust root(%v:%v)", cert.Subject.CommonName,...
go
func CertAuthorityInfo(ca services.CertAuthority) string { var out []string for _, keyPair := range ca.GetTLSKeyPairs() { cert, err := tlsca.ParseCertificatePEM(keyPair.Cert) if err != nil { out = append(out, err.Error()) } else { out = append(out, fmt.Sprintf("trust root(%v:%v)", cert.Subject.CommonName,...
[ "func", "CertAuthorityInfo", "(", "ca", "services", ".", "CertAuthority", ")", "string", "{", "var", "out", "[", "]", "string", "\n", "for", "_", ",", "keyPair", ":=", "range", "ca", ".", "GetTLSKeyPairs", "(", ")", "{", "cert", ",", "err", ":=", "tlsc...
// CertAuthorityInfo returns debugging information about certificate authority
[ "CertAuthorityInfo", "returns", "debugging", "information", "about", "certificate", "authority" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L565-L576
train
gravitational/teleport
lib/auth/init.go
HasTLSConfig
func (i *Identity) HasTLSConfig() bool { return len(i.TLSCACertsBytes) != 0 && len(i.TLSCertBytes) != 0 }
go
func (i *Identity) HasTLSConfig() bool { return len(i.TLSCACertsBytes) != 0 && len(i.TLSCertBytes) != 0 }
[ "func", "(", "i", "*", "Identity", ")", "HasTLSConfig", "(", ")", "bool", "{", "return", "len", "(", "i", ".", "TLSCACertsBytes", ")", "!=", "0", "&&", "len", "(", "i", ".", "TLSCertBytes", ")", "!=", "0", "\n", "}" ]
// HasTSLConfig returns true if this identity has TLS certificate and private key
[ "HasTSLConfig", "returns", "true", "if", "this", "identity", "has", "TLS", "certificate", "and", "private", "key" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L579-L581
train
gravitational/teleport
lib/auth/init.go
HasPrincipals
func (i *Identity) HasPrincipals(additionalPrincipals []string) bool { set := utils.StringsSet(i.Cert.ValidPrincipals) for _, principal := range additionalPrincipals { if _, ok := set[principal]; !ok { return false } } return true }
go
func (i *Identity) HasPrincipals(additionalPrincipals []string) bool { set := utils.StringsSet(i.Cert.ValidPrincipals) for _, principal := range additionalPrincipals { if _, ok := set[principal]; !ok { return false } } return true }
[ "func", "(", "i", "*", "Identity", ")", "HasPrincipals", "(", "additionalPrincipals", "[", "]", "string", ")", "bool", "{", "set", ":=", "utils", ".", "StringsSet", "(", "i", ".", "Cert", ".", "ValidPrincipals", ")", "\n", "for", "_", ",", "principal", ...
// HasPrincipals returns whether identity has principals
[ "HasPrincipals", "returns", "whether", "identity", "has", "principals" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L584-L592
train
gravitational/teleport
lib/auth/init.go
HasDNSNames
func (i *Identity) HasDNSNames(dnsNames []string) bool { if i.XCert == nil { return false } set := utils.StringsSet(i.XCert.DNSNames) for _, dnsName := range dnsNames { if _, ok := set[dnsName]; !ok { return false } } return true }
go
func (i *Identity) HasDNSNames(dnsNames []string) bool { if i.XCert == nil { return false } set := utils.StringsSet(i.XCert.DNSNames) for _, dnsName := range dnsNames { if _, ok := set[dnsName]; !ok { return false } } return true }
[ "func", "(", "i", "*", "Identity", ")", "HasDNSNames", "(", "dnsNames", "[", "]", "string", ")", "bool", "{", "if", "i", ".", "XCert", "==", "nil", "{", "return", "false", "\n", "}", "\n", "set", ":=", "utils", ".", "StringsSet", "(", "i", ".", "...
// HasDNSNames returns true if TLS certificate has required DNS names
[ "HasDNSNames", "returns", "true", "if", "TLS", "certificate", "has", "required", "DNS", "names" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L595-L606
train
gravitational/teleport
lib/auth/init.go
TLSConfig
func (i *Identity) TLSConfig(cipherSuites []uint16) (*tls.Config, error) { tlsConfig := utils.TLSConfig(cipherSuites) if !i.HasTLSConfig() { return nil, trace.NotFound("no TLS credentials setup for this identity") } tlsCert, err := tls.X509KeyPair(i.TLSCertBytes, i.KeyBytes) if err != nil { return nil, trace.B...
go
func (i *Identity) TLSConfig(cipherSuites []uint16) (*tls.Config, error) { tlsConfig := utils.TLSConfig(cipherSuites) if !i.HasTLSConfig() { return nil, trace.NotFound("no TLS credentials setup for this identity") } tlsCert, err := tls.X509KeyPair(i.TLSCertBytes, i.KeyBytes) if err != nil { return nil, trace.B...
[ "func", "(", "i", "*", "Identity", ")", "TLSConfig", "(", "cipherSuites", "[", "]", "uint16", ")", "(", "*", "tls", ".", "Config", ",", "error", ")", "{", "tlsConfig", ":=", "utils", ".", "TLSConfig", "(", "cipherSuites", ")", "\n", "if", "!", "i", ...
// TLSConfig returns TLS config for mutual TLS authentication // can return NotFound error if there are no TLS credentials setup for identity
[ "TLSConfig", "returns", "TLS", "config", "for", "mutual", "TLS", "authentication", "can", "return", "NotFound", "error", "if", "there", "are", "no", "TLS", "credentials", "setup", "for", "identity" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L610-L632
train
gravitational/teleport
lib/auth/init.go
SSHClientConfig
func (i *Identity) SSHClientConfig() *ssh.ClientConfig { return &ssh.ClientConfig{ User: i.ID.HostUUID, Auth: []ssh.AuthMethod{ ssh.PublicKeys(i.KeySigner), }, HostKeyCallback: i.hostKeyCallback, Timeout: defaults.DefaultDialTimeout, } }
go
func (i *Identity) SSHClientConfig() *ssh.ClientConfig { return &ssh.ClientConfig{ User: i.ID.HostUUID, Auth: []ssh.AuthMethod{ ssh.PublicKeys(i.KeySigner), }, HostKeyCallback: i.hostKeyCallback, Timeout: defaults.DefaultDialTimeout, } }
[ "func", "(", "i", "*", "Identity", ")", "SSHClientConfig", "(", ")", "*", "ssh", ".", "ClientConfig", "{", "return", "&", "ssh", ".", "ClientConfig", "{", "User", ":", "i", ".", "ID", ".", "HostUUID", ",", "Auth", ":", "[", "]", "ssh", ".", "AuthMe...
// SSHClientConfig returns a ssh.ClientConfig used by nodes to connect to // the reverse tunnel server.
[ "SSHClientConfig", "returns", "a", "ssh", ".", "ClientConfig", "used", "by", "nodes", "to", "connect", "to", "the", "reverse", "tunnel", "server", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L636-L645
train
gravitational/teleport
lib/auth/init.go
hostKeyCallback
func (i *Identity) hostKeyCallback(hostname string, remote net.Addr, key ssh.PublicKey) error { cert, ok := key.(*ssh.Certificate) if !ok { return trace.BadParameter("only host certificates supported") } // Loop over all CAs and see if any of them signed the certificate. for _, k := range i.SSHCACertBytes { p...
go
func (i *Identity) hostKeyCallback(hostname string, remote net.Addr, key ssh.PublicKey) error { cert, ok := key.(*ssh.Certificate) if !ok { return trace.BadParameter("only host certificates supported") } // Loop over all CAs and see if any of them signed the certificate. for _, k := range i.SSHCACertBytes { p...
[ "func", "(", "i", "*", "Identity", ")", "hostKeyCallback", "(", "hostname", "string", ",", "remote", "net", ".", "Addr", ",", "key", "ssh", ".", "PublicKey", ")", "error", "{", "cert", ",", "ok", ":=", "key", ".", "(", "*", "ssh", ".", "Certificate",...
// hostKeyCallback checks if the host certificate was signed by any of the // known CAs.
[ "hostKeyCallback", "checks", "if", "the", "host", "certificate", "was", "signed", "by", "any", "of", "the", "known", "CAs", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L649-L667
train
gravitational/teleport
lib/auth/init.go
HostID
func (id *IdentityID) HostID() (string, error) { parts := strings.Split(id.HostUUID, ".") if len(parts) < 2 { return "", trace.BadParameter("expected 2 parts in %q", id.HostUUID) } return parts[0], nil }
go
func (id *IdentityID) HostID() (string, error) { parts := strings.Split(id.HostUUID, ".") if len(parts) < 2 { return "", trace.BadParameter("expected 2 parts in %q", id.HostUUID) } return parts[0], nil }
[ "func", "(", "id", "*", "IdentityID", ")", "HostID", "(", ")", "(", "string", ",", "error", ")", "{", "parts", ":=", "strings", ".", "Split", "(", "id", ".", "HostUUID", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", "<", "2", "{",...
// HostID is host ID part of the host UUID that consists cluster name
[ "HostID", "is", "host", "ID", "part", "of", "the", "host", "UUID", "that", "consists", "cluster", "name" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L677-L683
train
gravitational/teleport
lib/auth/init.go
Equals
func (id *IdentityID) Equals(other IdentityID) bool { return id.Role == other.Role && id.HostUUID == other.HostUUID }
go
func (id *IdentityID) Equals(other IdentityID) bool { return id.Role == other.Role && id.HostUUID == other.HostUUID }
[ "func", "(", "id", "*", "IdentityID", ")", "Equals", "(", "other", "IdentityID", ")", "bool", "{", "return", "id", ".", "Role", "==", "other", ".", "Role", "&&", "id", ".", "HostUUID", "==", "other", ".", "HostUUID", "\n", "}" ]
// Equals returns true if two identities are equal
[ "Equals", "returns", "true", "if", "two", "identities", "are", "equal" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L686-L688
train
gravitational/teleport
lib/auth/init.go
ReadIdentityFromKeyPair
func ReadIdentityFromKeyPair(keys *PackedKeys) (*Identity, error) { identity, err := ReadSSHIdentityFromKeyPair(keys.Key, keys.Cert) if err != nil { return nil, trace.Wrap(err) } if len(keys.SSHCACerts) != 0 { identity.SSHCACertBytes = keys.SSHCACerts } if len(keys.TLSCACerts) != 0 { // Parse the key pair...
go
func ReadIdentityFromKeyPair(keys *PackedKeys) (*Identity, error) { identity, err := ReadSSHIdentityFromKeyPair(keys.Key, keys.Cert) if err != nil { return nil, trace.Wrap(err) } if len(keys.SSHCACerts) != 0 { identity.SSHCACertBytes = keys.SSHCACerts } if len(keys.TLSCACerts) != 0 { // Parse the key pair...
[ "func", "ReadIdentityFromKeyPair", "(", "keys", "*", "PackedKeys", ")", "(", "*", "Identity", ",", "error", ")", "{", "identity", ",", "err", ":=", "ReadSSHIdentityFromKeyPair", "(", "keys", ".", "Key", ",", "keys", ".", "Cert", ")", "\n", "if", "err", "...
// ReadIdentityFromKeyPair reads SSH and TLS identity from key pair.
[ "ReadIdentityFromKeyPair", "reads", "SSH", "and", "TLS", "identity", "from", "key", "pair", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L696-L718
train
gravitational/teleport
lib/auth/init.go
ReadTLSIdentityFromKeyPair
func ReadTLSIdentityFromKeyPair(keyBytes, certBytes []byte, caCertsBytes [][]byte) (*Identity, error) { if len(keyBytes) == 0 { return nil, trace.BadParameter("missing private key") } if len(certBytes) == 0 { return nil, trace.BadParameter("missing certificate") } cert, err := tlsca.ParseCertificatePEM(certB...
go
func ReadTLSIdentityFromKeyPair(keyBytes, certBytes []byte, caCertsBytes [][]byte) (*Identity, error) { if len(keyBytes) == 0 { return nil, trace.BadParameter("missing private key") } if len(certBytes) == 0 { return nil, trace.BadParameter("missing certificate") } cert, err := tlsca.ParseCertificatePEM(certB...
[ "func", "ReadTLSIdentityFromKeyPair", "(", "keyBytes", ",", "certBytes", "[", "]", "byte", ",", "caCertsBytes", "[", "]", "[", "]", "byte", ")", "(", "*", "Identity", ",", "error", ")", "{", "if", "len", "(", "keyBytes", ")", "==", "0", "{", "return", ...
// ReadTLSIdentityFromKeyPair reads TLS identity from key pair
[ "ReadTLSIdentityFromKeyPair", "reads", "TLS", "identity", "from", "key", "pair" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L721-L763
train
gravitational/teleport
lib/auth/init.go
ReadSSHIdentityFromKeyPair
func ReadSSHIdentityFromKeyPair(keyBytes, certBytes []byte) (*Identity, error) { if len(keyBytes) == 0 { return nil, trace.BadParameter("PrivateKey: missing private key") } if len(certBytes) == 0 { return nil, trace.BadParameter("Cert: missing parameter") } pubKey, _, _, _, err := ssh.ParseAuthorizedKey(cert...
go
func ReadSSHIdentityFromKeyPair(keyBytes, certBytes []byte) (*Identity, error) { if len(keyBytes) == 0 { return nil, trace.BadParameter("PrivateKey: missing private key") } if len(certBytes) == 0 { return nil, trace.BadParameter("Cert: missing parameter") } pubKey, _, _, _, err := ssh.ParseAuthorizedKey(cert...
[ "func", "ReadSSHIdentityFromKeyPair", "(", "keyBytes", ",", "certBytes", "[", "]", "byte", ")", "(", "*", "Identity", ",", "error", ")", "{", "if", "len", "(", "keyBytes", ")", "==", "0", "{", "return", "nil", ",", "trace", ".", "BadParameter", "(", "\...
// ReadSSHIdentityFromKeyPair reads identity from initialized keypair
[ "ReadSSHIdentityFromKeyPair", "reads", "identity", "from", "initialized", "keypair" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/init.go#L766-L837
train
gravitational/teleport
lib/services/role.go
NewImplicitRole
func NewImplicitRole() Role { return &RoleV3{ Kind: KindRole, Version: V3, Metadata: Metadata{ Name: teleport.DefaultImplicitRole, Namespace: defaults.Namespace, }, Spec: RoleSpecV3{ Options: RoleOptions{ MaxSessionTTL: MaxDuration(), }, Allow: RoleConditions{ Namespaces: []str...
go
func NewImplicitRole() Role { return &RoleV3{ Kind: KindRole, Version: V3, Metadata: Metadata{ Name: teleport.DefaultImplicitRole, Namespace: defaults.Namespace, }, Spec: RoleSpecV3{ Options: RoleOptions{ MaxSessionTTL: MaxDuration(), }, Allow: RoleConditions{ Namespaces: []str...
[ "func", "NewImplicitRole", "(", ")", "Role", "{", "return", "&", "RoleV3", "{", "Kind", ":", "KindRole", ",", "Version", ":", "V3", ",", "Metadata", ":", "Metadata", "{", "Name", ":", "teleport", ".", "DefaultImplicitRole", ",", "Namespace", ":", "defaults...
// NewImplicitRole is the default implicit role that gets added to all // RoleSets.
[ "NewImplicitRole", "is", "the", "default", "implicit", "role", "that", "gets", "added", "to", "all", "RoleSets", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L115-L133
train
gravitational/teleport
lib/services/role.go
RoleForUser
func RoleForUser(u User) Role { return &RoleV3{ Kind: KindRole, Version: V3, Metadata: Metadata{ Name: RoleNameForUser(u.GetName()), Namespace: defaults.Namespace, }, Spec: RoleSpecV3{ Options: RoleOptions{ CertificateFormat: teleport.CertificateFormatStandard, MaxSessionTTL: New...
go
func RoleForUser(u User) Role { return &RoleV3{ Kind: KindRole, Version: V3, Metadata: Metadata{ Name: RoleNameForUser(u.GetName()), Namespace: defaults.Namespace, }, Spec: RoleSpecV3{ Options: RoleOptions{ CertificateFormat: teleport.CertificateFormatStandard, MaxSessionTTL: New...
[ "func", "RoleForUser", "(", "u", "User", ")", "Role", "{", "return", "&", "RoleV3", "{", "Kind", ":", "KindRole", ",", "Version", ":", "V3", ",", "Metadata", ":", "Metadata", "{", "Name", ":", "RoleNameForUser", "(", "u", ".", "GetName", "(", ")", ")...
// RoleForUser creates an admin role for a services.User.
[ "RoleForUser", "creates", "an", "admin", "role", "for", "a", "services", ".", "User", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L136-L158
train
gravitational/teleport
lib/services/role.go
RoleForCertAuthority
func RoleForCertAuthority(ca CertAuthority) Role { return &RoleV3{ Kind: KindRole, Version: V3, Metadata: Metadata{ Name: RoleNameForCertAuthority(ca.GetClusterName()), Namespace: defaults.Namespace, }, Spec: RoleSpecV3{ Options: RoleOptions{ MaxSessionTTL: NewDuration(defaults.MaxCertDu...
go
func RoleForCertAuthority(ca CertAuthority) Role { return &RoleV3{ Kind: KindRole, Version: V3, Metadata: Metadata{ Name: RoleNameForCertAuthority(ca.GetClusterName()), Namespace: defaults.Namespace, }, Spec: RoleSpecV3{ Options: RoleOptions{ MaxSessionTTL: NewDuration(defaults.MaxCertDu...
[ "func", "RoleForCertAuthority", "(", "ca", "CertAuthority", ")", "Role", "{", "return", "&", "RoleV3", "{", "Kind", ":", "KindRole", ",", "Version", ":", "V3", ",", "Metadata", ":", "Metadata", "{", "Name", ":", "RoleNameForCertAuthority", "(", "ca", ".", ...
// RoleForCertauthority creates role using services.CertAuthority.
[ "RoleForCertauthority", "creates", "role", "using", "services", ".", "CertAuthority", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L161-L180
train
gravitational/teleport
lib/services/role.go
ConvertV1CertAuthority
func ConvertV1CertAuthority(v1 *CertAuthorityV1) (CertAuthority, Role) { ca := v1.V2() role := RoleForCertAuthority(ca) role.SetLogins(Allow, v1.AllowedLogins) ca.AddRole(role.GetName()) return ca, role }
go
func ConvertV1CertAuthority(v1 *CertAuthorityV1) (CertAuthority, Role) { ca := v1.V2() role := RoleForCertAuthority(ca) role.SetLogins(Allow, v1.AllowedLogins) ca.AddRole(role.GetName()) return ca, role }
[ "func", "ConvertV1CertAuthority", "(", "v1", "*", "CertAuthorityV1", ")", "(", "CertAuthority", ",", "Role", ")", "{", "ca", ":=", "v1", ".", "V2", "(", ")", "\n", "role", ":=", "RoleForCertAuthority", "(", "ca", ")", "\n", "role", ".", "SetLogins", "(",...
// ConvertV1CertAuthority converts V1 cert authority for new CA and Role
[ "ConvertV1CertAuthority", "converts", "V1", "cert", "authority", "for", "new", "CA", "and", "Role" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L183-L189
train
gravitational/teleport
lib/services/role.go
applyValueTraits
func applyValueTraits(val string, traits map[string][]string) ([]string, error) { // Extract the variablePrefix and variableName from the role variable. variablePrefix, variableName, err := parse.IsRoleVariable(val) if err != nil { if !trace.IsNotFound(err) { return nil, trace.Wrap(err) } return []string{v...
go
func applyValueTraits(val string, traits map[string][]string) ([]string, error) { // Extract the variablePrefix and variableName from the role variable. variablePrefix, variableName, err := parse.IsRoleVariable(val) if err != nil { if !trace.IsNotFound(err) { return nil, trace.Wrap(err) } return []string{v...
[ "func", "applyValueTraits", "(", "val", "string", ",", "traits", "map", "[", "string", "]", "[", "]", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "// Extract the variablePrefix and variableName from the role variable.", "variablePrefix", ",", "...
// applyValueTraits applies the passed in traits to the variable, // returns BadParameter in case if referenced variable is unsupported, // returns NotFound in case if referenced trait is missing, // mapped list of values otherwise, the function guarantees to return // at least one value in case if return value is nil
[ "applyValueTraits", "applies", "the", "passed", "in", "traits", "to", "the", "variable", "returns", "BadParameter", "in", "case", "if", "referenced", "variable", "is", "unsupported", "returns", "NotFound", "in", "case", "if", "referenced", "trait", "is", "missing"...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L349-L374
train
gravitational/teleport
lib/services/role.go
Equals
func (r *RoleV3) Equals(other Role) bool { if !r.GetOptions().Equals(other.GetOptions()) { return false } for _, condition := range []RoleConditionType{Allow, Deny} { if !utils.StringSlicesEqual(r.GetLogins(condition), other.GetLogins(condition)) { return false } if !utils.StringSlicesEqual(r.GetNamespac...
go
func (r *RoleV3) Equals(other Role) bool { if !r.GetOptions().Equals(other.GetOptions()) { return false } for _, condition := range []RoleConditionType{Allow, Deny} { if !utils.StringSlicesEqual(r.GetLogins(condition), other.GetLogins(condition)) { return false } if !utils.StringSlicesEqual(r.GetNamespac...
[ "func", "(", "r", "*", "RoleV3", ")", "Equals", "(", "other", "Role", ")", "bool", "{", "if", "!", "r", ".", "GetOptions", "(", ")", ".", "Equals", "(", "other", ".", "GetOptions", "(", ")", ")", "{", "return", "false", "\n", "}", "\n\n", "for", ...
// Equals returns true if the roles are equal. Roles are equal if options, // namespaces, logins, labels, and conditions match.
[ "Equals", "returns", "true", "if", "the", "roles", "are", "equal", ".", "Roles", "are", "equal", "if", "options", "namespaces", "logins", "labels", "and", "conditions", "match", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L408-L429
train
gravitational/teleport
lib/services/role.go
GetLogins
func (r *RoleV3) GetLogins(rct RoleConditionType) []string { if rct == Allow { return r.Spec.Allow.Logins } return r.Spec.Deny.Logins }
go
func (r *RoleV3) GetLogins(rct RoleConditionType) []string { if rct == Allow { return r.Spec.Allow.Logins } return r.Spec.Deny.Logins }
[ "func", "(", "r", "*", "RoleV3", ")", "GetLogins", "(", "rct", "RoleConditionType", ")", "[", "]", "string", "{", "if", "rct", "==", "Allow", "{", "return", "r", ".", "Spec", ".", "Allow", ".", "Logins", "\n", "}", "\n", "return", "r", ".", "Spec",...
// GetLogins gets system logins for allow or deny condition.
[ "GetLogins", "gets", "system", "logins", "for", "allow", "or", "deny", "condition", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L478-L483
train
gravitational/teleport
lib/services/role.go
SetLogins
func (r *RoleV3) SetLogins(rct RoleConditionType, logins []string) { lcopy := utils.CopyStrings(logins) if rct == Allow { r.Spec.Allow.Logins = lcopy } else { r.Spec.Deny.Logins = lcopy } }
go
func (r *RoleV3) SetLogins(rct RoleConditionType, logins []string) { lcopy := utils.CopyStrings(logins) if rct == Allow { r.Spec.Allow.Logins = lcopy } else { r.Spec.Deny.Logins = lcopy } }
[ "func", "(", "r", "*", "RoleV3", ")", "SetLogins", "(", "rct", "RoleConditionType", ",", "logins", "[", "]", "string", ")", "{", "lcopy", ":=", "utils", ".", "CopyStrings", "(", "logins", ")", "\n\n", "if", "rct", "==", "Allow", "{", "r", ".", "Spec"...
// SetLogins sets system logins for allow or deny condition.
[ "SetLogins", "sets", "system", "logins", "for", "allow", "or", "deny", "condition", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L486-L494
train
gravitational/teleport
lib/services/role.go
GetKubeGroups
func (r *RoleV3) GetKubeGroups(rct RoleConditionType) []string { if rct == Allow { return r.Spec.Allow.KubeGroups } return r.Spec.Deny.KubeGroups }
go
func (r *RoleV3) GetKubeGroups(rct RoleConditionType) []string { if rct == Allow { return r.Spec.Allow.KubeGroups } return r.Spec.Deny.KubeGroups }
[ "func", "(", "r", "*", "RoleV3", ")", "GetKubeGroups", "(", "rct", "RoleConditionType", ")", "[", "]", "string", "{", "if", "rct", "==", "Allow", "{", "return", "r", ".", "Spec", ".", "Allow", ".", "KubeGroups", "\n", "}", "\n", "return", "r", ".", ...
// GetKubeGroups returns kubernetes groups
[ "GetKubeGroups", "returns", "kubernetes", "groups" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L497-L502
train
gravitational/teleport
lib/services/role.go
SetKubeGroups
func (r *RoleV3) SetKubeGroups(rct RoleConditionType, groups []string) { lcopy := utils.CopyStrings(groups) if rct == Allow { r.Spec.Allow.KubeGroups = lcopy } else { r.Spec.Deny.KubeGroups = lcopy } }
go
func (r *RoleV3) SetKubeGroups(rct RoleConditionType, groups []string) { lcopy := utils.CopyStrings(groups) if rct == Allow { r.Spec.Allow.KubeGroups = lcopy } else { r.Spec.Deny.KubeGroups = lcopy } }
[ "func", "(", "r", "*", "RoleV3", ")", "SetKubeGroups", "(", "rct", "RoleConditionType", ",", "groups", "[", "]", "string", ")", "{", "lcopy", ":=", "utils", ".", "CopyStrings", "(", "groups", ")", "\n\n", "if", "rct", "==", "Allow", "{", "r", ".", "S...
// SetKubeGroups sets kubernetes groups for allow or deny condition.
[ "SetKubeGroups", "sets", "kubernetes", "groups", "for", "allow", "or", "deny", "condition", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L505-L513
train
gravitational/teleport
lib/services/role.go
GetNamespaces
func (r *RoleV3) GetNamespaces(rct RoleConditionType) []string { if rct == Allow { return r.Spec.Allow.Namespaces } return r.Spec.Deny.Namespaces }
go
func (r *RoleV3) GetNamespaces(rct RoleConditionType) []string { if rct == Allow { return r.Spec.Allow.Namespaces } return r.Spec.Deny.Namespaces }
[ "func", "(", "r", "*", "RoleV3", ")", "GetNamespaces", "(", "rct", "RoleConditionType", ")", "[", "]", "string", "{", "if", "rct", "==", "Allow", "{", "return", "r", ".", "Spec", ".", "Allow", ".", "Namespaces", "\n", "}", "\n", "return", "r", ".", ...
// GetNamespaces gets a list of namespaces this role is allowed or denied access to.
[ "GetNamespaces", "gets", "a", "list", "of", "namespaces", "this", "role", "is", "allowed", "or", "denied", "access", "to", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L516-L521
train
gravitational/teleport
lib/services/role.go
SetNamespaces
func (r *RoleV3) SetNamespaces(rct RoleConditionType, namespaces []string) { ncopy := utils.CopyStrings(namespaces) if rct == Allow { r.Spec.Allow.Namespaces = ncopy } else { r.Spec.Deny.Namespaces = ncopy } }
go
func (r *RoleV3) SetNamespaces(rct RoleConditionType, namespaces []string) { ncopy := utils.CopyStrings(namespaces) if rct == Allow { r.Spec.Allow.Namespaces = ncopy } else { r.Spec.Deny.Namespaces = ncopy } }
[ "func", "(", "r", "*", "RoleV3", ")", "SetNamespaces", "(", "rct", "RoleConditionType", ",", "namespaces", "[", "]", "string", ")", "{", "ncopy", ":=", "utils", ".", "CopyStrings", "(", "namespaces", ")", "\n\n", "if", "rct", "==", "Allow", "{", "r", "...
// GetNamespaces sets a list of namespaces this role is allowed or denied access to.
[ "GetNamespaces", "sets", "a", "list", "of", "namespaces", "this", "role", "is", "allowed", "or", "denied", "access", "to", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L524-L532
train
gravitational/teleport
lib/services/role.go
GetNodeLabels
func (r *RoleV3) GetNodeLabels(rct RoleConditionType) Labels { if rct == Allow { return r.Spec.Allow.NodeLabels } return r.Spec.Deny.NodeLabels }
go
func (r *RoleV3) GetNodeLabels(rct RoleConditionType) Labels { if rct == Allow { return r.Spec.Allow.NodeLabels } return r.Spec.Deny.NodeLabels }
[ "func", "(", "r", "*", "RoleV3", ")", "GetNodeLabels", "(", "rct", "RoleConditionType", ")", "Labels", "{", "if", "rct", "==", "Allow", "{", "return", "r", ".", "Spec", ".", "Allow", ".", "NodeLabels", "\n", "}", "\n", "return", "r", ".", "Spec", "."...
// GetNodeLabels gets the map of node labels this role is allowed or denied access to.
[ "GetNodeLabels", "gets", "the", "map", "of", "node", "labels", "this", "role", "is", "allowed", "or", "denied", "access", "to", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L535-L540
train
gravitational/teleport
lib/services/role.go
SetNodeLabels
func (r *RoleV3) SetNodeLabels(rct RoleConditionType, labels Labels) { if rct == Allow { r.Spec.Allow.NodeLabels = labels.Clone() } else { r.Spec.Deny.NodeLabels = labels.Clone() } }
go
func (r *RoleV3) SetNodeLabels(rct RoleConditionType, labels Labels) { if rct == Allow { r.Spec.Allow.NodeLabels = labels.Clone() } else { r.Spec.Deny.NodeLabels = labels.Clone() } }
[ "func", "(", "r", "*", "RoleV3", ")", "SetNodeLabels", "(", "rct", "RoleConditionType", ",", "labels", "Labels", ")", "{", "if", "rct", "==", "Allow", "{", "r", ".", "Spec", ".", "Allow", ".", "NodeLabels", "=", "labels", ".", "Clone", "(", ")", "\n"...
// SetNodeLabels sets the map of node labels this role is allowed or denied access to.
[ "SetNodeLabels", "sets", "the", "map", "of", "node", "labels", "this", "role", "is", "allowed", "or", "denied", "access", "to", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L543-L549
train
gravitational/teleport
lib/services/role.go
GetRules
func (r *RoleV3) GetRules(rct RoleConditionType) []Rule { if rct == Allow { return r.Spec.Allow.Rules } return r.Spec.Deny.Rules }
go
func (r *RoleV3) GetRules(rct RoleConditionType) []Rule { if rct == Allow { return r.Spec.Allow.Rules } return r.Spec.Deny.Rules }
[ "func", "(", "r", "*", "RoleV3", ")", "GetRules", "(", "rct", "RoleConditionType", ")", "[", "]", "Rule", "{", "if", "rct", "==", "Allow", "{", "return", "r", ".", "Spec", ".", "Allow", ".", "Rules", "\n", "}", "\n", "return", "r", ".", "Spec", "...
// GetRules gets all allow or deny rules.
[ "GetRules", "gets", "all", "allow", "or", "deny", "rules", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L552-L557
train
gravitational/teleport
lib/services/role.go
SetRules
func (r *RoleV3) SetRules(rct RoleConditionType, in []Rule) { rcopy := CopyRulesSlice(in) if rct == Allow { r.Spec.Allow.Rules = rcopy } else { r.Spec.Deny.Rules = rcopy } }
go
func (r *RoleV3) SetRules(rct RoleConditionType, in []Rule) { rcopy := CopyRulesSlice(in) if rct == Allow { r.Spec.Allow.Rules = rcopy } else { r.Spec.Deny.Rules = rcopy } }
[ "func", "(", "r", "*", "RoleV3", ")", "SetRules", "(", "rct", "RoleConditionType", ",", "in", "[", "]", "Rule", ")", "{", "rcopy", ":=", "CopyRulesSlice", "(", "in", ")", "\n\n", "if", "rct", "==", "Allow", "{", "r", ".", "Spec", ".", "Allow", ".",...
// SetRules sets an allow or deny rule.
[ "SetRules", "sets", "an", "allow", "or", "deny", "rule", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L560-L568
train
gravitational/teleport
lib/services/role.go
String
func (r *RoleV3) String() string { return fmt.Sprintf("Role(Name=%v,Options=%v,Allow=%+v,Deny=%+v)", r.GetName(), r.Spec.Options, r.Spec.Allow, r.Spec.Deny) }
go
func (r *RoleV3) String() string { return fmt.Sprintf("Role(Name=%v,Options=%v,Allow=%+v,Deny=%+v)", r.GetName(), r.Spec.Options, r.Spec.Allow, r.Spec.Deny) }
[ "func", "(", "r", "*", "RoleV3", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ".", "GetName", "(", ")", ",", "r", ".", "Spec", ".", "Options", ",", "r", ".", "Spec", ".", "Allow", ",", "r...
// String returns the human readable representation of a role.
[ "String", "returns", "the", "human", "readable", "representation", "of", "a", "role", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L641-L644
train
gravitational/teleport
lib/services/role.go
NewRule
func NewRule(resource string, verbs []string) Rule { return Rule{ Resources: []string{resource}, Verbs: verbs, } }
go
func NewRule(resource string, verbs []string) Rule { return Rule{ Resources: []string{resource}, Verbs: verbs, } }
[ "func", "NewRule", "(", "resource", "string", ",", "verbs", "[", "]", "string", ")", "Rule", "{", "return", "Rule", "{", "Resources", ":", "[", "]", "string", "{", "resource", "}", ",", "Verbs", ":", "verbs", ",", "}", "\n", "}" ]
// NewRule creates a rule based on a resource name and a list of verbs
[ "NewRule", "creates", "a", "rule", "based", "on", "a", "resource", "name", "and", "a", "list", "of", "verbs" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L680-L685
train
gravitational/teleport
lib/services/role.go
CheckAndSetDefaults
func (r *Rule) CheckAndSetDefaults() error { if len(r.Resources) == 0 { return trace.BadParameter("missing resources to match") } if len(r.Verbs) == 0 { return trace.BadParameter("missing verbs") } if len(r.Where) != 0 { parser, err := GetWhereParserFn()(&Context{}) if err != nil { return trace.Wrap(err...
go
func (r *Rule) CheckAndSetDefaults() error { if len(r.Resources) == 0 { return trace.BadParameter("missing resources to match") } if len(r.Verbs) == 0 { return trace.BadParameter("missing verbs") } if len(r.Where) != 0 { parser, err := GetWhereParserFn()(&Context{}) if err != nil { return trace.Wrap(err...
[ "func", "(", "r", "*", "Rule", ")", "CheckAndSetDefaults", "(", ")", "error", "{", "if", "len", "(", "r", ".", "Resources", ")", "==", "0", "{", "return", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "r",...
// CheckAndSetDefaults checks and sets defaults for this rule
[ "CheckAndSetDefaults", "checks", "and", "sets", "defaults", "for", "this", "rule" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L688-L718
train
gravitational/teleport
lib/services/role.go
score
func (r *Rule) score() int { score := 0 // wilcard rules are less specific if utils.SliceContainsStr(r.Resources, Wildcard) { score -= 4 } else if len(r.Resources) == 1 { // rules that match specific resource are more specific than // fields that match several resources score += 2 } // rules that have wil...
go
func (r *Rule) score() int { score := 0 // wilcard rules are less specific if utils.SliceContainsStr(r.Resources, Wildcard) { score -= 4 } else if len(r.Resources) == 1 { // rules that match specific resource are more specific than // fields that match several resources score += 2 } // rules that have wil...
[ "func", "(", "r", "*", "Rule", ")", "score", "(", ")", "int", "{", "score", ":=", "0", "\n", "// wilcard rules are less specific", "if", "utils", ".", "SliceContainsStr", "(", "r", ".", "Resources", ",", "Wildcard", ")", "{", "score", "-=", "4", "\n", ...
// score is a sorting score of the rule, the more the score, the more // specific the rule is
[ "score", "is", "a", "sorting", "score", "of", "the", "rule", "the", "more", "the", "score", "the", "more", "specific", "the", "rule", "is" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L722-L748
train
gravitational/teleport
lib/services/role.go
MatchesWhere
func (r *Rule) MatchesWhere(parser predicate.Parser) (bool, error) { if r.Where == "" { return true, nil } ifn, err := parser.Parse(r.Where) if err != nil { return false, trace.Wrap(err) } fn, ok := ifn.(predicate.BoolPredicate) if !ok { return false, trace.BadParameter("unsupported type: %T", ifn) } ret...
go
func (r *Rule) MatchesWhere(parser predicate.Parser) (bool, error) { if r.Where == "" { return true, nil } ifn, err := parser.Parse(r.Where) if err != nil { return false, trace.Wrap(err) } fn, ok := ifn.(predicate.BoolPredicate) if !ok { return false, trace.BadParameter("unsupported type: %T", ifn) } ret...
[ "func", "(", "r", "*", "Rule", ")", "MatchesWhere", "(", "parser", "predicate", ".", "Parser", ")", "(", "bool", ",", "error", ")", "{", "if", "r", ".", "Where", "==", "\"", "\"", "{", "return", "true", ",", "nil", "\n", "}", "\n", "ifn", ",", ...
// MatchesWhere returns true if Where rule matches // Empty Where block always matches
[ "MatchesWhere", "returns", "true", "if", "Where", "rule", "matches", "Empty", "Where", "block", "always", "matches" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L766-L779
train
gravitational/teleport
lib/services/role.go
ProcessActions
func (r *Rule) ProcessActions(parser predicate.Parser) error { for _, action := range r.Actions { ifn, err := parser.Parse(action) if err != nil { return trace.Wrap(err) } fn, ok := ifn.(predicate.BoolPredicate) if !ok { return trace.BadParameter("unsupported type: %T", ifn) } fn() } return nil }
go
func (r *Rule) ProcessActions(parser predicate.Parser) error { for _, action := range r.Actions { ifn, err := parser.Parse(action) if err != nil { return trace.Wrap(err) } fn, ok := ifn.(predicate.BoolPredicate) if !ok { return trace.BadParameter("unsupported type: %T", ifn) } fn() } return nil }
[ "func", "(", "r", "*", "Rule", ")", "ProcessActions", "(", "parser", "predicate", ".", "Parser", ")", "error", "{", "for", "_", ",", "action", ":=", "range", "r", ".", "Actions", "{", "ifn", ",", "err", ":=", "parser", ".", "Parse", "(", "action", ...
// ProcessActions processes actions specified for this rule
[ "ProcessActions", "processes", "actions", "specified", "for", "this", "rule" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L782-L795
train
gravitational/teleport
lib/services/role.go
HasResource
func (r *Rule) HasResource(resource string) bool { for _, r := range r.Resources { if r == resource { return true } } return false }
go
func (r *Rule) HasResource(resource string) bool { for _, r := range r.Resources { if r == resource { return true } } return false }
[ "func", "(", "r", "*", "Rule", ")", "HasResource", "(", "resource", "string", ")", "bool", "{", "for", "_", ",", "r", ":=", "range", "r", ".", "Resources", "{", "if", "r", "==", "resource", "{", "return", "true", "\n", "}", "\n", "}", "\n", "retu...
// HasResource returns true if the rule has the specified resource.
[ "HasResource", "returns", "true", "if", "the", "rule", "has", "the", "specified", "resource", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L798-L805
train
gravitational/teleport
lib/services/role.go
HasVerb
func (r *Rule) HasVerb(verb string) bool { for _, v := range r.Verbs { // readnosecrets can be satisfied by having readnosecrets or read if verb == VerbReadNoSecrets { if v == VerbReadNoSecrets || v == VerbRead { return true } continue } if v == verb { return true } } return false }
go
func (r *Rule) HasVerb(verb string) bool { for _, v := range r.Verbs { // readnosecrets can be satisfied by having readnosecrets or read if verb == VerbReadNoSecrets { if v == VerbReadNoSecrets || v == VerbRead { return true } continue } if v == verb { return true } } return false }
[ "func", "(", "r", "*", "Rule", ")", "HasVerb", "(", "verb", "string", ")", "bool", "{", "for", "_", ",", "v", ":=", "range", "r", ".", "Verbs", "{", "// readnosecrets can be satisfied by having readnosecrets or read", "if", "verb", "==", "VerbReadNoSecrets", "...
// HasVerb returns true if the rule has verb, // this method also matches wildcard
[ "HasVerb", "returns", "true", "if", "the", "rule", "has", "verb", "this", "method", "also", "matches", "wildcard" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L809-L823
train
gravitational/teleport
lib/services/role.go
Equals
func (r *Rule) Equals(other Rule) bool { if !utils.StringSlicesEqual(r.Resources, other.Resources) { return false } if !utils.StringSlicesEqual(r.Verbs, other.Verbs) { return false } if !utils.StringSlicesEqual(r.Actions, other.Actions) { return false } if r.Where != other.Where { return false } return...
go
func (r *Rule) Equals(other Rule) bool { if !utils.StringSlicesEqual(r.Resources, other.Resources) { return false } if !utils.StringSlicesEqual(r.Verbs, other.Verbs) { return false } if !utils.StringSlicesEqual(r.Actions, other.Actions) { return false } if r.Where != other.Where { return false } return...
[ "func", "(", "r", "*", "Rule", ")", "Equals", "(", "other", "Rule", ")", "bool", "{", "if", "!", "utils", ".", "StringSlicesEqual", "(", "r", ".", "Resources", ",", "other", ".", "Resources", ")", "{", "return", "false", "\n", "}", "\n", "if", "!",...
// Equals returns true if the rule equals to another
[ "Equals", "returns", "true", "if", "the", "rule", "equals", "to", "another" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L826-L840
train
gravitational/teleport
lib/services/role.go
Slice
func (set RuleSet) Slice() []Rule { var out []Rule for _, rules := range set { out = append(out, rules...) } return out }
go
func (set RuleSet) Slice() []Rule { var out []Rule for _, rules := range set { out = append(out, rules...) } return out }
[ "func", "(", "set", "RuleSet", ")", "Slice", "(", ")", "[", "]", "Rule", "{", "var", "out", "[", "]", "Rule", "\n", "for", "_", ",", "rules", ":=", "range", "set", "{", "out", "=", "append", "(", "out", ",", "rules", "...", ")", "\n", "}", "\...
// Slice returns slice from a set
[ "Slice", "returns", "slice", "from", "a", "set" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L893-L899
train
gravitational/teleport
lib/services/role.go
MakeRuleSet
func MakeRuleSet(rules []Rule) RuleSet { set := make(RuleSet) for _, rule := range rules { for _, resource := range rule.Resources { rules, ok := set[resource] if !ok { set[resource] = []Rule{rule} } else { rules = append(rules, rule) set[resource] = rules } } } for resource := range set...
go
func MakeRuleSet(rules []Rule) RuleSet { set := make(RuleSet) for _, rule := range rules { for _, resource := range rule.Resources { rules, ok := set[resource] if !ok { set[resource] = []Rule{rule} } else { rules = append(rules, rule) set[resource] = rules } } } for resource := range set...
[ "func", "MakeRuleSet", "(", "rules", "[", "]", "Rule", ")", "RuleSet", "{", "set", ":=", "make", "(", "RuleSet", ")", "\n", "for", "_", ",", "rule", ":=", "range", "rules", "{", "for", "_", ",", "resource", ":=", "range", "rule", ".", "Resources", ...
// MakeRuleSet converts slice of rules to the set of rules
[ "MakeRuleSet", "converts", "slice", "of", "rules", "to", "the", "set", "of", "rules" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L902-L925
train
gravitational/teleport
lib/services/role.go
CopyRulesSlice
func CopyRulesSlice(in []Rule) []Rule { out := make([]Rule, len(in)) copy(out, in) return out }
go
func CopyRulesSlice(in []Rule) []Rule { out := make([]Rule, len(in)) copy(out, in) return out }
[ "func", "CopyRulesSlice", "(", "in", "[", "]", "Rule", ")", "[", "]", "Rule", "{", "out", ":=", "make", "(", "[", "]", "Rule", ",", "len", "(", "in", ")", ")", "\n", "copy", "(", "out", ",", "in", ")", "\n", "return", "out", "\n", "}" ]
// CopyRulesSlice copies input slice of Rules and returns the copy
[ "CopyRulesSlice", "copies", "input", "slice", "of", "Rules", "and", "returns", "the", "copy" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L928-L932
train
gravitational/teleport
lib/services/role.go
RuleSlicesEqual
func RuleSlicesEqual(a, b []Rule) bool { if len(a) != len(b) { return false } for i := range a { if !a[i].Equals(b[i]) { return false } } return true }
go
func RuleSlicesEqual(a, b []Rule) bool { if len(a) != len(b) { return false } for i := range a { if !a[i].Equals(b[i]) { return false } } return true }
[ "func", "RuleSlicesEqual", "(", "a", ",", "b", "[", "]", "Rule", ")", "bool", "{", "if", "len", "(", "a", ")", "!=", "len", "(", "b", ")", "{", "return", "false", "\n", "}", "\n", "for", "i", ":=", "range", "a", "{", "if", "!", "a", "[", "i...
// RuleSlicesEqual returns true if two rule slices are equal
[ "RuleSlicesEqual", "returns", "true", "if", "two", "rule", "slices", "are", "equal" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L935-L945
train
gravitational/teleport
lib/services/role.go
Equals
func (r *RoleV2) Equals(other Role) bool { return r.V3().Equals(other) }
go
func (r *RoleV2) Equals(other Role) bool { return r.V3().Equals(other) }
[ "func", "(", "r", "*", "RoleV2", ")", "Equals", "(", "other", "Role", ")", "bool", "{", "return", "r", ".", "V3", "(", ")", ".", "Equals", "(", "other", ")", "\n", "}" ]
// Equals test roles for equality. Roles are considered equal if all resources, // logins, namespaces, labels, and options match.
[ "Equals", "test", "roles", "for", "equality", ".", "Roles", "are", "considered", "equal", "if", "all", "resources", "logins", "namespaces", "labels", "and", "options", "match", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L993-L995
train
gravitational/teleport
lib/services/role.go
SetResource
func (r *RoleV2) SetResource(kind string, actions []string) { if r.Spec.Resources == nil { r.Spec.Resources = make(map[string][]string) } r.Spec.Resources[kind] = actions }
go
func (r *RoleV2) SetResource(kind string, actions []string) { if r.Spec.Resources == nil { r.Spec.Resources = make(map[string][]string) } r.Spec.Resources[kind] = actions }
[ "func", "(", "r", "*", "RoleV2", ")", "SetResource", "(", "kind", "string", ",", "actions", "[", "]", "string", ")", "{", "if", "r", ".", "Spec", ".", "Resources", "==", "nil", "{", "r", ".", "Spec", ".", "Resources", "=", "make", "(", "map", "["...
// SetResource sets resource rule
[ "SetResource", "sets", "resource", "rule" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L998-L1003
train
gravitational/teleport
lib/services/role.go
RemoveResource
func (r *RoleV2) RemoveResource(kind string) { delete(r.Spec.Resources, kind) }
go
func (r *RoleV2) RemoveResource(kind string) { delete(r.Spec.Resources, kind) }
[ "func", "(", "r", "*", "RoleV2", ")", "RemoveResource", "(", "kind", "string", ")", "{", "delete", "(", "r", ".", "Spec", ".", "Resources", ",", "kind", ")", "\n", "}" ]
// RemoveResource deletes resource entry
[ "RemoveResource", "deletes", "resource", "entry" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1006-L1008
train
gravitational/teleport
lib/services/role.go
SetNodeLabels
func (r *RoleV2) SetNodeLabels(labels map[string]string) { r.Spec.NodeLabels = labels }
go
func (r *RoleV2) SetNodeLabels(labels map[string]string) { r.Spec.NodeLabels = labels }
[ "func", "(", "r", "*", "RoleV2", ")", "SetNodeLabels", "(", "labels", "map", "[", "string", "]", "string", ")", "{", "r", ".", "Spec", ".", "NodeLabels", "=", "labels", "\n", "}" ]
// SetNodeLabels sets node labels for role
[ "SetNodeLabels", "sets", "node", "labels", "for", "role" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1016-L1018
train
gravitational/teleport
lib/services/role.go
SetMaxSessionTTL
func (r *RoleV2) SetMaxSessionTTL(duration time.Duration) { r.Spec.MaxSessionTTL = Duration(duration) }
go
func (r *RoleV2) SetMaxSessionTTL(duration time.Duration) { r.Spec.MaxSessionTTL = Duration(duration) }
[ "func", "(", "r", "*", "RoleV2", ")", "SetMaxSessionTTL", "(", "duration", "time", ".", "Duration", ")", "{", "r", ".", "Spec", ".", "MaxSessionTTL", "=", "Duration", "(", "duration", ")", "\n", "}" ]
// SetMaxSessionTTL sets a maximum TTL for SSH or Web session
[ "SetMaxSessionTTL", "sets", "a", "maximum", "TTL", "for", "SSH", "or", "Web", "session" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1021-L1023
train
gravitational/teleport
lib/services/role.go
FromSpec
func FromSpec(name string, spec RoleSpecV3) (RoleSet, error) { role, err := NewRole(name, spec) if err != nil { return nil, trace.Wrap(err) } return NewRoleSet(role), nil }
go
func FromSpec(name string, spec RoleSpecV3) (RoleSet, error) { role, err := NewRole(name, spec) if err != nil { return nil, trace.Wrap(err) } return NewRoleSet(role), nil }
[ "func", "FromSpec", "(", "name", "string", ",", "spec", "RoleSpecV3", ")", "(", "RoleSet", ",", "error", ")", "{", "role", ",", "err", ":=", "NewRole", "(", "name", ",", "spec", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "trace...
// FromSpec returns new RoleSet created from spec
[ "FromSpec", "returns", "new", "RoleSet", "created", "from", "spec" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1271-L1278
train
gravitational/teleport
lib/services/role.go
NewRole
func NewRole(name string, spec RoleSpecV3) (Role, error) { role := RoleV3{ Kind: KindRole, Version: V3, Metadata: Metadata{ Name: name, Namespace: defaults.Namespace, }, Spec: spec, } if err := role.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } return &role, nil }
go
func NewRole(name string, spec RoleSpecV3) (Role, error) { role := RoleV3{ Kind: KindRole, Version: V3, Metadata: Metadata{ Name: name, Namespace: defaults.Namespace, }, Spec: spec, } if err := role.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } return &role, nil }
[ "func", "NewRole", "(", "name", "string", ",", "spec", "RoleSpecV3", ")", "(", "Role", ",", "error", ")", "{", "role", ":=", "RoleV3", "{", "Kind", ":", "KindRole", ",", "Version", ":", "V3", ",", "Metadata", ":", "Metadata", "{", "Name", ":", "name"...
// NewRole constructs new standard role
[ "NewRole", "constructs", "new", "standard", "role" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1297-L1312
train
gravitational/teleport
lib/services/role.go
FetchRoles
func FetchRoles(roleNames []string, access RoleGetter, traits map[string][]string) (RoleSet, error) { var roles []Role for _, roleName := range roleNames { role, err := access.GetRole(roleName) if err != nil { return nil, trace.Wrap(err) } roles = append(roles, role.ApplyTraits(traits)) } return NewRol...
go
func FetchRoles(roleNames []string, access RoleGetter, traits map[string][]string) (RoleSet, error) { var roles []Role for _, roleName := range roleNames { role, err := access.GetRole(roleName) if err != nil { return nil, trace.Wrap(err) } roles = append(roles, role.ApplyTraits(traits)) } return NewRol...
[ "func", "FetchRoles", "(", "roleNames", "[", "]", "string", ",", "access", "RoleGetter", ",", "traits", "map", "[", "string", "]", "[", "]", "string", ")", "(", "RoleSet", ",", "error", ")", "{", "var", "roles", "[", "]", "Role", "\n\n", "for", "_", ...
// FetchRoles fetches roles by their names, applies the traits to role // variables, and returns the RoleSet.
[ "FetchRoles", "fetches", "roles", "by", "their", "names", "applies", "the", "traits", "to", "role", "variables", "and", "returns", "the", "RoleSet", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1322-L1334
train
gravitational/teleport
lib/services/role.go
NewRoleSet
func NewRoleSet(roles ...Role) RoleSet { // unauthenticated Nop role should not have any privileges // by default, otherwise it is too permissive if len(roles) == 1 && roles[0].GetName() == string(teleport.RoleNop) { return roles } return append(roles, NewImplicitRole()) }
go
func NewRoleSet(roles ...Role) RoleSet { // unauthenticated Nop role should not have any privileges // by default, otherwise it is too permissive if len(roles) == 1 && roles[0].GetName() == string(teleport.RoleNop) { return roles } return append(roles, NewImplicitRole()) }
[ "func", "NewRoleSet", "(", "roles", "...", "Role", ")", "RoleSet", "{", "// unauthenticated Nop role should not have any privileges", "// by default, otherwise it is too permissive", "if", "len", "(", "roles", ")", "==", "1", "&&", "roles", "[", "0", "]", ".", "GetNam...
// NewRoleSet returns new RoleSet based on the roles
[ "NewRoleSet", "returns", "new", "RoleSet", "based", "on", "the", "roles" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1337-L1344
train
gravitational/teleport
lib/services/role.go
MatchNamespace
func MatchNamespace(selectors []string, namespace string) (bool, string) { for _, n := range selectors { if n == namespace || n == Wildcard { return true, "matched" } } return false, fmt.Sprintf("no match, role selectors %v, server namespace: %v", selectors, namespace) }
go
func MatchNamespace(selectors []string, namespace string) (bool, string) { for _, n := range selectors { if n == namespace || n == Wildcard { return true, "matched" } } return false, fmt.Sprintf("no match, role selectors %v, server namespace: %v", selectors, namespace) }
[ "func", "MatchNamespace", "(", "selectors", "[", "]", "string", ",", "namespace", "string", ")", "(", "bool", ",", "string", ")", "{", "for", "_", ",", "n", ":=", "range", "selectors", "{", "if", "n", "==", "namespace", "||", "n", "==", "Wildcard", "...
// MatchNamespace returns true if given list of namespace matches // target namespace, wildcard matches everything.
[ "MatchNamespace", "returns", "true", "if", "given", "list", "of", "namespace", "matches", "target", "namespace", "wildcard", "matches", "everything", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1351-L1358
train
gravitational/teleport
lib/services/role.go
MatchLogin
func MatchLogin(selectors []string, login string) (bool, string) { for _, l := range selectors { if l == login { return true, "matched" } } return false, fmt.Sprintf("no match, role selectors %v, login: %v", selectors, login) }
go
func MatchLogin(selectors []string, login string) (bool, string) { for _, l := range selectors { if l == login { return true, "matched" } } return false, fmt.Sprintf("no match, role selectors %v, login: %v", selectors, login) }
[ "func", "MatchLogin", "(", "selectors", "[", "]", "string", ",", "login", "string", ")", "(", "bool", ",", "string", ")", "{", "for", "_", ",", "l", ":=", "range", "selectors", "{", "if", "l", "==", "login", "{", "return", "true", ",", "\"", "\"", ...
// MatchLogin returns true if attempted login matches any of the logins.
[ "MatchLogin", "returns", "true", "if", "attempted", "login", "matches", "any", "of", "the", "logins", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1361-L1368
train
gravitational/teleport
lib/services/role.go
MatchLabels
func MatchLabels(selector Labels, target map[string]string) (bool, string, error) { // Empty selector matches nothing. if len(selector) == 0 { return false, "no match, empty selector", nil } // *: * matches everything even empty target set. selectorValues := selector[Wildcard] if len(selectorValues) == 1 && se...
go
func MatchLabels(selector Labels, target map[string]string) (bool, string, error) { // Empty selector matches nothing. if len(selector) == 0 { return false, "no match, empty selector", nil } // *: * matches everything even empty target set. selectorValues := selector[Wildcard] if len(selectorValues) == 1 && se...
[ "func", "MatchLabels", "(", "selector", "Labels", ",", "target", "map", "[", "string", "]", "string", ")", "(", "bool", ",", "string", ",", "error", ")", "{", "// Empty selector matches nothing.", "if", "len", "(", "selector", ")", "==", "0", "{", "return"...
// MatchLabels matches selector against target. Empty selector matches // nothing, wildcard matches everything.
[ "MatchLabels", "matches", "selector", "against", "target", ".", "Empty", "selector", "matches", "nothing", "wildcard", "matches", "everything", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1372-L1403
train
gravitational/teleport
lib/services/role.go
RoleNames
func (set RoleSet) RoleNames() []string { out := make([]string, len(set)) for i, r := range set { out[i] = r.GetName() } return out }
go
func (set RoleSet) RoleNames() []string { out := make([]string, len(set)) for i, r := range set { out[i] = r.GetName() } return out }
[ "func", "(", "set", "RoleSet", ")", "RoleNames", "(", ")", "[", "]", "string", "{", "out", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "set", ")", ")", "\n", "for", "i", ",", "r", ":=", "range", "set", "{", "out", "[", "i", "]", ...
// RoleNames returns a slice with role names
[ "RoleNames", "returns", "a", "slice", "with", "role", "names" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1406-L1412
train
gravitational/teleport
lib/services/role.go
HasRole
func (set RoleSet) HasRole(role string) bool { for _, r := range set { if r.GetName() == role { return true } } return false }
go
func (set RoleSet) HasRole(role string) bool { for _, r := range set { if r.GetName() == role { return true } } return false }
[ "func", "(", "set", "RoleSet", ")", "HasRole", "(", "role", "string", ")", "bool", "{", "for", "_", ",", "r", ":=", "range", "set", "{", "if", "r", ".", "GetName", "(", ")", "==", "role", "{", "return", "true", "\n", "}", "\n", "}", "\n", "retu...
// HasRole checks if the role set has the role
[ "HasRole", "checks", "if", "the", "role", "set", "has", "the", "role" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1415-L1422
train
gravitational/teleport
lib/services/role.go
AdjustSessionTTL
func (set RoleSet) AdjustSessionTTL(ttl time.Duration) time.Duration { for _, role := range set { maxSessionTTL := role.GetOptions().MaxSessionTTL.Value() if maxSessionTTL != 0 && ttl > maxSessionTTL { ttl = maxSessionTTL } } return ttl }
go
func (set RoleSet) AdjustSessionTTL(ttl time.Duration) time.Duration { for _, role := range set { maxSessionTTL := role.GetOptions().MaxSessionTTL.Value() if maxSessionTTL != 0 && ttl > maxSessionTTL { ttl = maxSessionTTL } } return ttl }
[ "func", "(", "set", "RoleSet", ")", "AdjustSessionTTL", "(", "ttl", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "for", "_", ",", "role", ":=", "range", "set", "{", "maxSessionTTL", ":=", "role", ".", "GetOptions", "(", ")", ".", "MaxSes...
// AdjustSessionTTL will reduce the requested ttl to lowest max allowed TTL // for this role set, otherwise it returns ttl unchanged
[ "AdjustSessionTTL", "will", "reduce", "the", "requested", "ttl", "to", "lowest", "max", "allowed", "TTL", "for", "this", "role", "set", "otherwise", "it", "returns", "ttl", "unchanged" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1426-L1434
train
gravitational/teleport
lib/services/role.go
AdjustClientIdleTimeout
func (set RoleSet) AdjustClientIdleTimeout(timeout time.Duration) time.Duration { if timeout < 0 { timeout = 0 } for _, role := range set { roleTimeout := role.GetOptions().ClientIdleTimeout // 0 means not set, so it can't be most restrictive, disregard it too if roleTimeout.Duration() <= 0 { continue }...
go
func (set RoleSet) AdjustClientIdleTimeout(timeout time.Duration) time.Duration { if timeout < 0 { timeout = 0 } for _, role := range set { roleTimeout := role.GetOptions().ClientIdleTimeout // 0 means not set, so it can't be most restrictive, disregard it too if roleTimeout.Duration() <= 0 { continue }...
[ "func", "(", "set", "RoleSet", ")", "AdjustClientIdleTimeout", "(", "timeout", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "if", "timeout", "<", "0", "{", "timeout", "=", "0", "\n", "}", "\n", "for", "_", ",", "role", ":=", "range", "...
// AdjustClientIdleTimeout adjusts requested idle timeout // to the lowest max allowed timeout, the most restrictive // option will be picked, negative values will be assumed as 0
[ "AdjustClientIdleTimeout", "adjusts", "requested", "idle", "timeout", "to", "the", "lowest", "max", "allowed", "timeout", "the", "most", "restrictive", "option", "will", "be", "picked", "negative", "values", "will", "be", "assumed", "as", "0" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1439-L1460
train
gravitational/teleport
lib/services/role.go
AdjustDisconnectExpiredCert
func (set RoleSet) AdjustDisconnectExpiredCert(disconnect bool) bool { for _, role := range set { if role.GetOptions().DisconnectExpiredCert.Value() { disconnect = true } } return disconnect }
go
func (set RoleSet) AdjustDisconnectExpiredCert(disconnect bool) bool { for _, role := range set { if role.GetOptions().DisconnectExpiredCert.Value() { disconnect = true } } return disconnect }
[ "func", "(", "set", "RoleSet", ")", "AdjustDisconnectExpiredCert", "(", "disconnect", "bool", ")", "bool", "{", "for", "_", ",", "role", ":=", "range", "set", "{", "if", "role", ".", "GetOptions", "(", ")", ".", "DisconnectExpiredCert", ".", "Value", "(", ...
// AdjustDisconnectExpiredCert adjusts the value based on the role set // the most restrictive option will be picked
[ "AdjustDisconnectExpiredCert", "adjusts", "the", "value", "based", "on", "the", "role", "set", "the", "most", "restrictive", "option", "will", "be", "picked" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1464-L1471
train
gravitational/teleport
lib/services/role.go
CheckKubeGroups
func (set RoleSet) CheckKubeGroups(ttl time.Duration) ([]string, error) { groups := make(map[string]bool) var matchedTTL bool for _, role := range set { maxSessionTTL := role.GetOptions().MaxSessionTTL.Value() if ttl <= maxSessionTTL && maxSessionTTL != 0 { matchedTTL = true for _, group := range role.GetK...
go
func (set RoleSet) CheckKubeGroups(ttl time.Duration) ([]string, error) { groups := make(map[string]bool) var matchedTTL bool for _, role := range set { maxSessionTTL := role.GetOptions().MaxSessionTTL.Value() if ttl <= maxSessionTTL && maxSessionTTL != 0 { matchedTTL = true for _, group := range role.GetK...
[ "func", "(", "set", "RoleSet", ")", "CheckKubeGroups", "(", "ttl", "time", ".", "Duration", ")", "(", "[", "]", "string", ",", "error", ")", "{", "groups", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "var", "matchedTTL", "bool", ...
// CheckKubeGroups check if role can login into kubernetes // and returns a combined list of allowed groups
[ "CheckKubeGroups", "check", "if", "role", "can", "login", "into", "kubernetes", "and", "returns", "a", "combined", "list", "of", "allowed", "groups" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1475-L1498
train
gravitational/teleport
lib/services/role.go
CheckLoginDuration
func (set RoleSet) CheckLoginDuration(ttl time.Duration) ([]string, error) { logins := make(map[string]bool) var matchedTTL bool for _, role := range set { maxSessionTTL := role.GetOptions().MaxSessionTTL.Value() if ttl <= maxSessionTTL && maxSessionTTL != 0 { matchedTTL = true for _, login := range role....
go
func (set RoleSet) CheckLoginDuration(ttl time.Duration) ([]string, error) { logins := make(map[string]bool) var matchedTTL bool for _, role := range set { maxSessionTTL := role.GetOptions().MaxSessionTTL.Value() if ttl <= maxSessionTTL && maxSessionTTL != 0 { matchedTTL = true for _, login := range role....
[ "func", "(", "set", "RoleSet", ")", "CheckLoginDuration", "(", "ttl", "time", ".", "Duration", ")", "(", "[", "]", "string", ",", "error", ")", "{", "logins", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "var", "matchedTTL", "bool...
// CheckLoginDuration checks if role set can login up to given duration and // returns a combined list of allowed logins.
[ "CheckLoginDuration", "checks", "if", "role", "set", "can", "login", "up", "to", "given", "duration", "and", "returns", "a", "combined", "list", "of", "allowed", "logins", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1502-L1526
train
gravitational/teleport
lib/services/role.go
CanForwardAgents
func (set RoleSet) CanForwardAgents() bool { for _, role := range set { if role.GetOptions().ForwardAgent.Value() { return true } } return false }
go
func (set RoleSet) CanForwardAgents() bool { for _, role := range set { if role.GetOptions().ForwardAgent.Value() { return true } } return false }
[ "func", "(", "set", "RoleSet", ")", "CanForwardAgents", "(", ")", "bool", "{", "for", "_", ",", "role", ":=", "range", "set", "{", "if", "role", ".", "GetOptions", "(", ")", ".", "ForwardAgent", ".", "Value", "(", ")", "{", "return", "true", "\n", ...
// CanForwardAgents returns true if role set allows forwarding agents.
[ "CanForwardAgents", "returns", "true", "if", "role", "set", "allows", "forwarding", "agents", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1586-L1593
train
gravitational/teleport
lib/services/role.go
CanPortForward
func (set RoleSet) CanPortForward() bool { for _, role := range set { if BoolDefaultTrue(role.GetOptions().PortForwarding) { return true } } return false }
go
func (set RoleSet) CanPortForward() bool { for _, role := range set { if BoolDefaultTrue(role.GetOptions().PortForwarding) { return true } } return false }
[ "func", "(", "set", "RoleSet", ")", "CanPortForward", "(", ")", "bool", "{", "for", "_", ",", "role", ":=", "range", "set", "{", "if", "BoolDefaultTrue", "(", "role", ".", "GetOptions", "(", ")", ".", "PortForwarding", ")", "{", "return", "true", "\n",...
// CanPortForward returns true if a role in the RoleSet allows port forwarding.
[ "CanPortForward", "returns", "true", "if", "a", "role", "in", "the", "RoleSet", "allows", "port", "forwarding", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1596-L1603
train
gravitational/teleport
lib/services/role.go
CertificateFormat
func (set RoleSet) CertificateFormat() string { var formats []string for _, role := range set { // get the certificate format for each individual role. if a role does not // have a certificate format (like implicit roles) skip over it certificateFormat := role.GetOptions().CertificateFormat if certificateFor...
go
func (set RoleSet) CertificateFormat() string { var formats []string for _, role := range set { // get the certificate format for each individual role. if a role does not // have a certificate format (like implicit roles) skip over it certificateFormat := role.GetOptions().CertificateFormat if certificateFor...
[ "func", "(", "set", "RoleSet", ")", "CertificateFormat", "(", ")", "string", "{", "var", "formats", "[", "]", "string", "\n\n", "for", "_", ",", "role", ":=", "range", "set", "{", "// get the certificate format for each individual role. if a role does not", "// have...
// CertificateFormat returns the most permissive certificate format in a // RoleSet.
[ "CertificateFormat", "returns", "the", "most", "permissive", "certificate", "format", "in", "a", "RoleSet", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1607-L1632
train
gravitational/teleport
lib/services/role.go
CheckAgentForward
func (set RoleSet) CheckAgentForward(login string) error { // check if we have permission to login and forward agent. we don't check // for deny rules because if you can't forward an agent if you can't login // in the first place. for _, role := range set { for _, l := range role.GetLogins(Allow) { if role.Get...
go
func (set RoleSet) CheckAgentForward(login string) error { // check if we have permission to login and forward agent. we don't check // for deny rules because if you can't forward an agent if you can't login // in the first place. for _, role := range set { for _, l := range role.GetLogins(Allow) { if role.Get...
[ "func", "(", "set", "RoleSet", ")", "CheckAgentForward", "(", "login", "string", ")", "error", "{", "// check if we have permission to login and forward agent. we don't check", "// for deny rules because if you can't forward an agent if you can't login", "// in the first place.", "for"...
// CheckAgentForward checks if the role can request to forward the SSH agent // for this user.
[ "CheckAgentForward", "checks", "if", "the", "role", "can", "request", "to", "forward", "the", "SSH", "agent", "for", "this", "user", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1649-L1661
train
gravitational/teleport
lib/services/role.go
Clone
func (l Labels) Clone() Labels { if l == nil { return nil } out := make(Labels, len(l)) for key, vals := range l { cvals := make([]string, len(vals)) copy(cvals, vals) out[key] = cvals } return out }
go
func (l Labels) Clone() Labels { if l == nil { return nil } out := make(Labels, len(l)) for key, vals := range l { cvals := make([]string, len(vals)) copy(cvals, vals) out[key] = cvals } return out }
[ "func", "(", "l", "Labels", ")", "Clone", "(", ")", "Labels", "{", "if", "l", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "make", "(", "Labels", ",", "len", "(", "l", ")", ")", "\n", "for", "key", ",", "vals", ":=", "rang...
// Clone returns non-shallow copy of the labels set
[ "Clone", "returns", "non", "-", "shallow", "copy", "of", "the", "labels", "set" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1816-L1827
train
gravitational/teleport
lib/services/role.go
Equals
func (l Labels) Equals(o Labels) bool { if len(l) != len(o) { return false } for key := range l { if !utils.StringSlicesEqual(l[key], o[key]) { return false } } return true }
go
func (l Labels) Equals(o Labels) bool { if len(l) != len(o) { return false } for key := range l { if !utils.StringSlicesEqual(l[key], o[key]) { return false } } return true }
[ "func", "(", "l", "Labels", ")", "Equals", "(", "o", "Labels", ")", "bool", "{", "if", "len", "(", "l", ")", "!=", "len", "(", "o", ")", "{", "return", "false", "\n", "}", "\n", "for", "key", ":=", "range", "l", "{", "if", "!", "utils", ".", ...
// Equals returns true if two label sets are equal
[ "Equals", "returns", "true", "if", "two", "label", "sets", "are", "equal" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1830-L1840
train
gravitational/teleport
lib/services/role.go
MarshalTo
func (b BoolOption) MarshalTo(data []byte) (int, error) { return b.protoType().MarshalTo(data) }
go
func (b BoolOption) MarshalTo(data []byte) (int, error) { return b.protoType().MarshalTo(data) }
[ "func", "(", "b", "BoolOption", ")", "MarshalTo", "(", "data", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "return", "b", ".", "protoType", "(", ")", ".", "MarshalTo", "(", "data", ")", "\n", "}" ]
// MarshalTo marshals value to the slice
[ "MarshalTo", "marshals", "value", "to", "the", "slice" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L1933-L1935
train
gravitational/teleport
lib/services/role.go
UnmarshalJSON
func (d *Duration) UnmarshalJSON(data []byte) error { if len(data) == 0 { return nil } var stringVar string if err := json.Unmarshal(data, &stringVar); err != nil { return trace.Wrap(err) } if stringVar == teleport.DurationNever { *d = Duration(0) } else { out, err := time.ParseDuration(stringVar) if e...
go
func (d *Duration) UnmarshalJSON(data []byte) error { if len(data) == 0 { return nil } var stringVar string if err := json.Unmarshal(data, &stringVar); err != nil { return trace.Wrap(err) } if stringVar == teleport.DurationNever { *d = Duration(0) } else { out, err := time.ParseDuration(stringVar) if e...
[ "func", "(", "d", "*", "Duration", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "data", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "var", "stringVar", "string", "\n", "if", "err", ":=", "js...
// UnmarshalJSON marshals Duration to string
[ "UnmarshalJSON", "marshals", "Duration", "to", "string" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L2007-L2025
train
gravitational/teleport
lib/services/role.go
GetRoleSchema
func GetRoleSchema(version string, extensionSchema string) string { schemaDefinitions := "," + RoleSpecV3SchemaDefinitions if version == V2 { schemaDefinitions = DefaultDefinitions } schemaTemplate := RoleSpecV3SchemaTemplate if version == V2 { schemaTemplate = RoleSpecV2SchemaTemplate } schema := fmt.Spri...
go
func GetRoleSchema(version string, extensionSchema string) string { schemaDefinitions := "," + RoleSpecV3SchemaDefinitions if version == V2 { schemaDefinitions = DefaultDefinitions } schemaTemplate := RoleSpecV3SchemaTemplate if version == V2 { schemaTemplate = RoleSpecV2SchemaTemplate } schema := fmt.Spri...
[ "func", "GetRoleSchema", "(", "version", "string", ",", "extensionSchema", "string", ")", "string", "{", "schemaDefinitions", ":=", "\"", "\"", "+", "RoleSpecV3SchemaDefinitions", "\n", "if", "version", "==", "V2", "{", "schemaDefinitions", "=", "DefaultDefinitions"...
// GetRoleSchema returns role schema for the version requested with optionally // injected schema for extensions.
[ "GetRoleSchema", "returns", "role", "schema", "for", "the", "version", "requested", "with", "optionally", "injected", "schema", "for", "extensions", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L2158-L2175
train
gravitational/teleport
lib/services/role.go
UnmarshalRole
func UnmarshalRole(data []byte, opts ...MarshalOption) (*RoleV3, error) { var h ResourceHeader err := json.Unmarshal(data, &h) if err != nil { h.Version = V2 } cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } switch h.Version { case V2: var role RoleV2 if err := utils.Un...
go
func UnmarshalRole(data []byte, opts ...MarshalOption) (*RoleV3, error) { var h ResourceHeader err := json.Unmarshal(data, &h) if err != nil { h.Version = V2 } cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } switch h.Version { case V2: var role RoleV2 if err := utils.Un...
[ "func", "UnmarshalRole", "(", "data", "[", "]", "byte", ",", "opts", "...", "MarshalOption", ")", "(", "*", "RoleV3", ",", "error", ")", "{", "var", "h", "ResourceHeader", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "h", ")", ...
// UnmarshalRole unmarshals role from JSON, sets defaults, and checks schema.
[ "UnmarshalRole", "unmarshals", "role", "from", "JSON", "sets", "defaults", "and", "checks", "schema", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L2178-L2230
train
gravitational/teleport
lib/services/role.go
UnmarshalRole
func (*TeleportRoleMarshaler) UnmarshalRole(bytes []byte, opts ...MarshalOption) (Role, error) { return UnmarshalRole(bytes, opts...) }
go
func (*TeleportRoleMarshaler) UnmarshalRole(bytes []byte, opts ...MarshalOption) (Role, error) { return UnmarshalRole(bytes, opts...) }
[ "func", "(", "*", "TeleportRoleMarshaler", ")", "UnmarshalRole", "(", "bytes", "[", "]", "byte", ",", "opts", "...", "MarshalOption", ")", "(", "Role", ",", "error", ")", "{", "return", "UnmarshalRole", "(", "bytes", ",", "opts", "...", ")", "\n", "}" ]
// UnmarshalRole unmarshals role from JSON.
[ "UnmarshalRole", "unmarshals", "role", "from", "JSON", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L2258-L2260
train
gravitational/teleport
lib/services/role.go
MarshalRole
func (*TeleportRoleMarshaler) MarshalRole(r Role, opts ...MarshalOption) ([]byte, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } switch role := r.(type) { case *RoleV3: if !cfg.PreserveResourceID { // avoid modifying the original object // to prevent unexpected da...
go
func (*TeleportRoleMarshaler) MarshalRole(r Role, opts ...MarshalOption) ([]byte, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } switch role := r.(type) { case *RoleV3: if !cfg.PreserveResourceID { // avoid modifying the original object // to prevent unexpected da...
[ "func", "(", "*", "TeleportRoleMarshaler", ")", "MarshalRole", "(", "r", "Role", ",", "opts", "...", "MarshalOption", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "cfg", ",", "err", ":=", "collectOptions", "(", "opts", ")", "\n", "if", "err", ...
// MarshalRole marshalls role into JSON.
[ "MarshalRole", "marshalls", "role", "into", "JSON", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/role.go#L2263-L2281
train
gravitational/teleport
tool/tctl/common/resource_command.go
Initialize
func (g *ResourceCommand) Initialize(app *kingpin.Application, config *service.Config) { g.CreateHandlers = map[ResourceKind]ResourceCreateHandler{ services.KindUser: g.createUser, services.KindTrustedCluster: g.createTrustedCluster, services.KindGithubConnector: g.createGithubConnector, services.K...
go
func (g *ResourceCommand) Initialize(app *kingpin.Application, config *service.Config) { g.CreateHandlers = map[ResourceKind]ResourceCreateHandler{ services.KindUser: g.createUser, services.KindTrustedCluster: g.createTrustedCluster, services.KindGithubConnector: g.createGithubConnector, services.K...
[ "func", "(", "g", "*", "ResourceCommand", ")", "Initialize", "(", "app", "*", "kingpin", ".", "Application", ",", "config", "*", "service", ".", "Config", ")", "{", "g", ".", "CreateHandlers", "=", "map", "[", "ResourceKind", "]", "ResourceCreateHandler", ...
// Initialize allows ResourceCommand to plug itself into the CLI parser
[ "Initialize", "allows", "ResourceCommand", "to", "plug", "itself", "into", "the", "CLI", "parser" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/resource_command.go#L71-L94
train
gravitational/teleport
tool/tctl/common/resource_command.go
IsDeleteSubcommand
func (g *ResourceCommand) IsDeleteSubcommand(cmd string) bool { return cmd == g.deleteCmd.FullCommand() }
go
func (g *ResourceCommand) IsDeleteSubcommand(cmd string) bool { return cmd == g.deleteCmd.FullCommand() }
[ "func", "(", "g", "*", "ResourceCommand", ")", "IsDeleteSubcommand", "(", "cmd", "string", ")", "bool", "{", "return", "cmd", "==", "g", ".", "deleteCmd", ".", "FullCommand", "(", ")", "\n", "}" ]
// IsDeleteSubcommand returns 'true' if the given command is `tctl rm`
[ "IsDeleteSubcommand", "returns", "true", "if", "the", "given", "command", "is", "tctl", "rm" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/resource_command.go#L116-L118
train
gravitational/teleport
tool/tctl/common/resource_command.go
Get
func (g *ResourceCommand) Get(client auth.ClientI) error { collection, err := g.getCollection(client) if err != nil { return trace.Wrap(err) } // Note that only YAML is officially supported. Support for text and JSON // is experimental. switch g.format { case teleport.YAML: return collection.writeYAML(os.St...
go
func (g *ResourceCommand) Get(client auth.ClientI) error { collection, err := g.getCollection(client) if err != nil { return trace.Wrap(err) } // Note that only YAML is officially supported. Support for text and JSON // is experimental. switch g.format { case teleport.YAML: return collection.writeYAML(os.St...
[ "func", "(", "g", "*", "ResourceCommand", ")", "Get", "(", "client", "auth", ".", "ClientI", ")", "error", "{", "collection", ",", "err", ":=", "g", ".", "getCollection", "(", "client", ")", "\n", "if", "err", "!=", "nil", "{", "return", "trace", "."...
// Get prints one or many resources of a certain type
[ "Get", "prints", "one", "or", "many", "resources", "of", "a", "certain", "type" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/resource_command.go#L127-L144
train
gravitational/teleport
tool/tctl/common/resource_command.go
Create
func (u *ResourceCommand) Create(client auth.ClientI) error { reader, err := utils.OpenFile(u.filename) if err != nil { return trace.Wrap(err) } decoder := kyaml.NewYAMLOrJSONDecoder(reader, 32*1024) count := 0 for { var raw services.UnknownResource err := decoder.Decode(&raw) if err != nil { if err ==...
go
func (u *ResourceCommand) Create(client auth.ClientI) error { reader, err := utils.OpenFile(u.filename) if err != nil { return trace.Wrap(err) } decoder := kyaml.NewYAMLOrJSONDecoder(reader, 32*1024) count := 0 for { var raw services.UnknownResource err := decoder.Decode(&raw) if err != nil { if err ==...
[ "func", "(", "u", "*", "ResourceCommand", ")", "Create", "(", "client", "auth", ".", "ClientI", ")", "error", "{", "reader", ",", "err", ":=", "utils", ".", "OpenFile", "(", "u", ".", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Create updates or insterts one or many resources
[ "Create", "updates", "or", "insterts", "one", "or", "many", "resources" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/resource_command.go#L147-L179
train
gravitational/teleport
tool/tctl/common/resource_command.go
createTrustedCluster
func (u *ResourceCommand) createTrustedCluster(client auth.ClientI, raw services.UnknownResource) error { tc, err := services.GetTrustedClusterMarshaler().Unmarshal(raw.Raw) if err != nil { return trace.Wrap(err) } // check if such cluster already exists: name := tc.GetName() _, err = client.GetTrustedCluster(...
go
func (u *ResourceCommand) createTrustedCluster(client auth.ClientI, raw services.UnknownResource) error { tc, err := services.GetTrustedClusterMarshaler().Unmarshal(raw.Raw) if err != nil { return trace.Wrap(err) } // check if such cluster already exists: name := tc.GetName() _, err = client.GetTrustedCluster(...
[ "func", "(", "u", "*", "ResourceCommand", ")", "createTrustedCluster", "(", "client", "auth", ".", "ClientI", ",", "raw", "services", ".", "UnknownResource", ")", "error", "{", "tc", ",", "err", ":=", "services", ".", "GetTrustedClusterMarshaler", "(", ")", ...
// createTrustedCluster implements `tctl create cluster.yaml` command
[ "createTrustedCluster", "implements", "tctl", "create", "cluster", ".", "yaml", "command" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/resource_command.go#L182-L216
train
gravitational/teleport
tool/tctl/common/resource_command.go
createCertAuthority
func (u *ResourceCommand) createCertAuthority(client auth.ClientI, raw services.UnknownResource) error { certAuthority, err := services.GetCertAuthorityMarshaler().UnmarshalCertAuthority(raw.Raw) if err != nil { return trace.Wrap(err) } if err := client.UpsertCertAuthority(certAuthority); err != nil { return tr...
go
func (u *ResourceCommand) createCertAuthority(client auth.ClientI, raw services.UnknownResource) error { certAuthority, err := services.GetCertAuthorityMarshaler().UnmarshalCertAuthority(raw.Raw) if err != nil { return trace.Wrap(err) } if err := client.UpsertCertAuthority(certAuthority); err != nil { return tr...
[ "func", "(", "u", "*", "ResourceCommand", ")", "createCertAuthority", "(", "client", "auth", ".", "ClientI", ",", "raw", "services", ".", "UnknownResource", ")", "error", "{", "certAuthority", ",", "err", ":=", "services", ".", "GetCertAuthorityMarshaler", "(", ...
// createCertAuthority creates certificate authority
[ "createCertAuthority", "creates", "certificate", "authority" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/resource_command.go#L219-L229
train
gravitational/teleport
tool/tctl/common/resource_command.go
createUser
func (u *ResourceCommand) createUser(client auth.ClientI, raw services.UnknownResource) error { user, err := services.GetUserMarshaler().UnmarshalUser(raw.Raw) if err != nil { return trace.Wrap(err) } userName := user.GetName() if err := client.UpsertUser(user); err != nil { return trace.Wrap(err) } fmt.Prin...
go
func (u *ResourceCommand) createUser(client auth.ClientI, raw services.UnknownResource) error { user, err := services.GetUserMarshaler().UnmarshalUser(raw.Raw) if err != nil { return trace.Wrap(err) } userName := user.GetName() if err := client.UpsertUser(user); err != nil { return trace.Wrap(err) } fmt.Prin...
[ "func", "(", "u", "*", "ResourceCommand", ")", "createUser", "(", "client", "auth", ".", "ClientI", ",", "raw", "services", ".", "UnknownResource", ")", "error", "{", "user", ",", "err", ":=", "services", ".", "GetUserMarshaler", "(", ")", ".", "UnmarshalU...
// createUser implements 'tctl create user.yaml' command
[ "createUser", "implements", "tctl", "create", "user", ".", "yaml", "command" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/resource_command.go#L255-L266
train
gravitational/teleport
tool/tctl/common/resource_command.go
Delete
func (d *ResourceCommand) Delete(client auth.ClientI) (err error) { if d.ref.Kind == "" || d.ref.Name == "" { return trace.BadParameter("provide a full resource name to delete, for example:\n$ tctl rm cluster/east\n") } switch d.ref.Kind { case services.KindNode: if err = client.DeleteNode(defaults.Namespace, ...
go
func (d *ResourceCommand) Delete(client auth.ClientI) (err error) { if d.ref.Kind == "" || d.ref.Name == "" { return trace.BadParameter("provide a full resource name to delete, for example:\n$ tctl rm cluster/east\n") } switch d.ref.Kind { case services.KindNode: if err = client.DeleteNode(defaults.Namespace, ...
[ "func", "(", "d", "*", "ResourceCommand", ")", "Delete", "(", "client", "auth", ".", "ClientI", ")", "(", "err", "error", ")", "{", "if", "d", ".", "ref", ".", "Kind", "==", "\"", "\"", "||", "d", ".", "ref", ".", "Name", "==", "\"", "\"", "{",...
// Delete deletes resource by name
[ "Delete", "deletes", "resource", "by", "name" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/resource_command.go#L269-L319
train
gravitational/teleport
lib/reversetunnel/cache.go
NewHostCertificateCache
func NewHostCertificateCache(keygen sshca.Authority, authClient auth.ClientI) (*certificateCache, error) { cache, err := ttlmap.New(defaults.HostCertCacheSize) if err != nil { return nil, trace.Wrap(err) } return &certificateCache{ keygen: keygen, cache: cache, authClient: authClient, }, nil }
go
func NewHostCertificateCache(keygen sshca.Authority, authClient auth.ClientI) (*certificateCache, error) { cache, err := ttlmap.New(defaults.HostCertCacheSize) if err != nil { return nil, trace.Wrap(err) } return &certificateCache{ keygen: keygen, cache: cache, authClient: authClient, }, nil }
[ "func", "NewHostCertificateCache", "(", "keygen", "sshca", ".", "Authority", ",", "authClient", "auth", ".", "ClientI", ")", "(", "*", "certificateCache", ",", "error", ")", "{", "cache", ",", "err", ":=", "ttlmap", ".", "New", "(", "defaults", ".", "HostC...
// NewHostCertificateCache creates a shared host certificate cache that is // used by the forwarding server.
[ "NewHostCertificateCache", "creates", "a", "shared", "host", "certificate", "cache", "that", "is", "used", "by", "the", "forwarding", "server", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/cache.go#L45-L56
train
gravitational/teleport
lib/reversetunnel/cache.go
GetHostCertificate
func (c *certificateCache) GetHostCertificate(addr string, additionalPrincipals []string) (ssh.Signer, error) { var certificate ssh.Signer var err error var ok bool var principals []string principals = append(principals, addr) principals = append(principals, additionalPrincipals...) certificate, ok = c.get(str...
go
func (c *certificateCache) GetHostCertificate(addr string, additionalPrincipals []string) (ssh.Signer, error) { var certificate ssh.Signer var err error var ok bool var principals []string principals = append(principals, addr) principals = append(principals, additionalPrincipals...) certificate, ok = c.get(str...
[ "func", "(", "c", "*", "certificateCache", ")", "GetHostCertificate", "(", "addr", "string", ",", "additionalPrincipals", "[", "]", "string", ")", "(", "ssh", ".", "Signer", ",", "error", ")", "{", "var", "certificate", "ssh", ".", "Signer", "\n", "var", ...
// GetHostCertificate will fetch a certificate from the cache. If the certificate // is not in the cache, it will be generated, put in the cache, and returned. Mul // Multiple callers can arrive and generate a host certificate at the same time. // This is a tradeoff to prevent long delays here due to the expensive // c...
[ "GetHostCertificate", "will", "fetch", "a", "certificate", "from", "the", "cache", ".", "If", "the", "certificate", "is", "not", "in", "the", "cache", "it", "will", "be", "generated", "put", "in", "the", "cache", "and", "returned", ".", "Mul", "Multiple", ...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/cache.go#L63-L86
train
gravitational/teleport
lib/reversetunnel/cache.go
get
func (c *certificateCache) get(addr string) (ssh.Signer, bool) { c.mu.Lock() defer c.mu.Unlock() certificate, ok := c.cache.Get(addr) if !ok { return nil, false } certificateSigner, ok := certificate.(ssh.Signer) if !ok { return nil, false } return certificateSigner, true }
go
func (c *certificateCache) get(addr string) (ssh.Signer, bool) { c.mu.Lock() defer c.mu.Unlock() certificate, ok := c.cache.Get(addr) if !ok { return nil, false } certificateSigner, ok := certificate.(ssh.Signer) if !ok { return nil, false } return certificateSigner, true }
[ "func", "(", "c", "*", "certificateCache", ")", "get", "(", "addr", "string", ")", "(", "ssh", ".", "Signer", ",", "bool", ")", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "certifi...
// get is goroutine safe and will return a ssh.Signer for a principal from // the cache.
[ "get", "is", "goroutine", "safe", "and", "will", "return", "a", "ssh", ".", "Signer", "for", "a", "principal", "from", "the", "cache", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/cache.go#L90-L105
train
gravitational/teleport
lib/reversetunnel/cache.go
set
func (c *certificateCache) set(addr string, certificate ssh.Signer, ttl time.Duration) error { c.mu.Lock() defer c.mu.Unlock() err := c.cache.Set(addr, certificate, ttl) if err != nil { return trace.Wrap(err) } return nil }
go
func (c *certificateCache) set(addr string, certificate ssh.Signer, ttl time.Duration) error { c.mu.Lock() defer c.mu.Unlock() err := c.cache.Set(addr, certificate, ttl) if err != nil { return trace.Wrap(err) } return nil }
[ "func", "(", "c", "*", "certificateCache", ")", "set", "(", "addr", "string", ",", "certificate", "ssh", ".", "Signer", ",", "ttl", "time", ".", "Duration", ")", "error", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ...
// set is goroutine safe and will set a ssh.Signer for a principal in // the cache.
[ "set", "is", "goroutine", "safe", "and", "will", "set", "a", "ssh", ".", "Signer", "for", "a", "principal", "in", "the", "cache", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/cache.go#L109-L119
train
gravitational/teleport
lib/reversetunnel/cache.go
generateHostCert
func (c *certificateCache) generateHostCert(principals []string) (ssh.Signer, error) { if len(principals) == 0 { return nil, trace.BadParameter("at least one principal must be provided") } // Generate public/private keypair. privBytes, pubBytes, err := c.keygen.GetNewKeyPairFromPool() if err != nil { return n...
go
func (c *certificateCache) generateHostCert(principals []string) (ssh.Signer, error) { if len(principals) == 0 { return nil, trace.BadParameter("at least one principal must be provided") } // Generate public/private keypair. privBytes, pubBytes, err := c.keygen.GetNewKeyPairFromPool() if err != nil { return n...
[ "func", "(", "c", "*", "certificateCache", ")", "generateHostCert", "(", "principals", "[", "]", "string", ")", "(", "ssh", ".", "Signer", ",", "error", ")", "{", "if", "len", "(", "principals", ")", "==", "0", "{", "return", "nil", ",", "trace", "."...
// generateHostCert will generate a SSH host certificate for a given // principal.
[ "generateHostCert", "will", "generate", "a", "SSH", "host", "certificate", "for", "a", "given", "principal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/cache.go#L123-L173
train
gravitational/teleport
lib/srv/monitor.go
NewMonitor
func NewMonitor(cfg MonitorConfig) (*Monitor, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } return &Monitor{ MonitorConfig: cfg, }, nil }
go
func NewMonitor(cfg MonitorConfig) (*Monitor, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } return &Monitor{ MonitorConfig: cfg, }, nil }
[ "func", "NewMonitor", "(", "cfg", "MonitorConfig", ")", "(", "*", "Monitor", ",", "error", ")", "{", "if", "err", ":=", "cfg", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "Wrap", "(", "err",...
// NewMonitor returns a new monitor
[ "NewMonitor", "returns", "a", "new", "monitor" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/monitor.go#L107-L114
train
gravitational/teleport
tool/teleport/common/teleport.go
OnStart
func OnStart(config *service.Config) error { return service.Run(context.TODO(), *config, nil) }
go
func OnStart(config *service.Config) error { return service.Run(context.TODO(), *config, nil) }
[ "func", "OnStart", "(", "config", "*", "service", ".", "Config", ")", "error", "{", "return", "service", ".", "Run", "(", "context", ".", "TODO", "(", ")", ",", "*", "config", ",", "nil", ")", "\n", "}" ]
// OnStart is the handler for "start" CLI command
[ "OnStart", "is", "the", "handler", "for", "start", "CLI", "command" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/teleport/common/teleport.go#L169-L171
train
gravitational/teleport
tool/teleport/common/teleport.go
onStatus
func onStatus() error { sshClient := os.Getenv("SSH_CLIENT") systemUser := os.Getenv("USER") teleportUser := os.Getenv(teleport.SSHTeleportUser) proxyHost := os.Getenv(teleport.SSHSessionWebproxyAddr) clusterName := os.Getenv(teleport.SSHTeleportClusterName) hostUUID := os.Getenv(teleport.SSHTeleportHostUUID) si...
go
func onStatus() error { sshClient := os.Getenv("SSH_CLIENT") systemUser := os.Getenv("USER") teleportUser := os.Getenv(teleport.SSHTeleportUser) proxyHost := os.Getenv(teleport.SSHSessionWebproxyAddr) clusterName := os.Getenv(teleport.SSHTeleportClusterName) hostUUID := os.Getenv(teleport.SSHTeleportHostUUID) si...
[ "func", "onStatus", "(", ")", "error", "{", "sshClient", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "systemUser", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "teleportUser", ":=", "os", ".", "Getenv", "(", "teleport", ".", "S...
// onStatus is the handler for "status" CLI command
[ "onStatus", "is", "the", "handler", "for", "status", "CLI", "command" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/teleport/common/teleport.go#L174-L195
train