id
int32
0
167k
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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
24,100
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
24,101
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
24,102
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
24,103
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
24,104
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
24,105
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
24,106
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
24,107
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
24,108
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
24,109
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
24,110
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
24,111
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
24,112
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
24,113
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
24,114
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
24,115
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
24,116
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
24,117
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
24,118
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
24,119
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
24,120
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
24,121
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
24,122
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
24,123
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
24,124
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
24,125
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
24,126
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
24,127
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
24,128
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
24,129
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
24,130
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
24,131
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
24,132
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
24,133
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
24,134
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
24,135
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
24,136
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
24,137
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
24,138
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
24,139
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
24,140
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
24,141
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
24,142
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
24,143
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
24,144
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
24,145
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
24,146
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
24,147
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
24,148
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
24,149
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
24,150
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
24,151
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
24,152
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
24,153
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
24,154
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
24,155
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
24,156
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
24,157
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
24,158
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
24,159
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
24,160
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
24,161
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
24,162
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
24,163
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
24,164
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
24,165
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
24,166
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
24,167
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
24,168
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
24,169
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
24,170
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
24,171
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
24,172
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
24,173
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
24,174
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
24,175
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
24,176
gravitational/teleport
lib/utils/copy.go
CopyByteSlice
func CopyByteSlice(in []byte) []byte { if in == nil { return nil } out := make([]byte, len(in)) copy(out, in) return out }
go
func CopyByteSlice(in []byte) []byte { if in == nil { return nil } out := make([]byte, len(in)) copy(out, in) return out }
[ "func", "CopyByteSlice", "(", "in", "[", "]", "byte", ")", "[", "]", "byte", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "in", ")", ")", "\n", "copy", "(", ...
// CopyByteSlice returns a copy of the byte slice.
[ "CopyByteSlice", "returns", "a", "copy", "of", "the", "byte", "slice", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/copy.go#L20-L27
24,177
gravitational/teleport
lib/utils/copy.go
CopyByteSlices
func CopyByteSlices(in [][]byte) [][]byte { if in == nil { return nil } out := make([][]byte, len(in)) for i := range in { out[i] = CopyByteSlice(in[i]) } return out }
go
func CopyByteSlices(in [][]byte) [][]byte { if in == nil { return nil } out := make([][]byte, len(in)) for i := range in { out[i] = CopyByteSlice(in[i]) } return out }
[ "func", "CopyByteSlices", "(", "in", "[", "]", "[", "]", "byte", ")", "[", "]", "[", "]", "byte", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "make", "(", "[", "]", "[", "]", "byte", ",", "len", "(", "i...
// CopyByteSlices returns a copy of the byte slices.
[ "CopyByteSlices", "returns", "a", "copy", "of", "the", "byte", "slices", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/copy.go#L30-L39
24,178
gravitational/teleport
lib/utils/copy.go
JoinStringSlices
func JoinStringSlices(a []string, b []string) []string { if len(a)+len(b) == 0 { return nil } out := make([]string, 0, len(a)+len(b)) out = append(out, a...) out = append(out, b...) return out }
go
func JoinStringSlices(a []string, b []string) []string { if len(a)+len(b) == 0 { return nil } out := make([]string, 0, len(a)+len(b)) out = append(out, a...) out = append(out, b...) return out }
[ "func", "JoinStringSlices", "(", "a", "[", "]", "string", ",", "b", "[", "]", "string", ")", "[", "]", "string", "{", "if", "len", "(", "a", ")", "+", "len", "(", "b", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "make"...
// JoinStringSlices joins two string slices and returns a resulting slice
[ "JoinStringSlices", "joins", "two", "string", "slices", "and", "returns", "a", "resulting", "slice" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/copy.go#L42-L50
24,179
gravitational/teleport
lib/utils/copy.go
CopyStrings
func CopyStrings(in []string) []string { if in == nil { return nil } out := make([]string, len(in)) copy(out, in) return out }
go
func CopyStrings(in []string) []string { if in == nil { return nil } out := make([]string, len(in)) copy(out, in) return out }
[ "func", "CopyStrings", "(", "in", "[", "]", "string", ")", "[", "]", "string", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "in", ")", ")", "\n", "copy", ...
// CopyStrings makes a deep copy of the passed in string slice and returns // the copy.
[ "CopyStrings", "makes", "a", "deep", "copy", "of", "the", "passed", "in", "string", "slice", "and", "returns", "the", "copy", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/copy.go#L54-L63
24,180
gravitational/teleport
lib/utils/copy.go
ReplaceInSlice
func ReplaceInSlice(s []string, old string, new string) []string { out := make([]string, 0, len(s)) for _, x := range s { if x == old { out = append(out, new) } else { out = append(out, x) } } return out }
go
func ReplaceInSlice(s []string, old string, new string) []string { out := make([]string, 0, len(s)) for _, x := range s { if x == old { out = append(out, new) } else { out = append(out, x) } } return out }
[ "func", "ReplaceInSlice", "(", "s", "[", "]", "string", ",", "old", "string", ",", "new", "string", ")", "[", "]", "string", "{", "out", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "s", ")", ")", "\n\n", "for", "_", ",", ...
// ReplaceInSlice replaces element old with new and returns a new slice.
[ "ReplaceInSlice", "replaces", "element", "old", "with", "new", "and", "returns", "a", "new", "slice", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/copy.go#L112-L124
24,181
gravitational/teleport
lib/service/connect.go
reconnectToAuthService
func (process *TeleportProcess) reconnectToAuthService(role teleport.Role) (*Connector, error) { retryTime := defaults.HighResPollingPeriod for { connector, err := process.connectToAuthService(role) if err == nil { // if connected and client is present, make sure the connector's // client works, by using ca...
go
func (process *TeleportProcess) reconnectToAuthService(role teleport.Role) (*Connector, error) { retryTime := defaults.HighResPollingPeriod for { connector, err := process.connectToAuthService(role) if err == nil { // if connected and client is present, make sure the connector's // client works, by using ca...
[ "func", "(", "process", "*", "TeleportProcess", ")", "reconnectToAuthService", "(", "role", "teleport", ".", "Role", ")", "(", "*", "Connector", ",", "error", ")", "{", "retryTime", ":=", "defaults", ".", "HighResPollingPeriod", "\n", "for", "{", "connector", ...
// reconnectToAuthService continuously attempts to reconnect to the auth // service until succeeds or process gets shut down
[ "reconnectToAuthService", "continuously", "attempts", "to", "reconnect", "to", "the", "auth", "service", "until", "succeeds", "or", "process", "gets", "shut", "down" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L41-L68
24,182
gravitational/teleport
lib/service/connect.go
connectToAuthService
func (process *TeleportProcess) connectToAuthService(role teleport.Role) (*Connector, error) { connector, err := process.connect(role) if err != nil { return nil, trace.Wrap(err) } process.Debugf("Connected client: %v", connector.ClientIdentity) process.Debugf("Connected server: %v", connector.ServerIdentity) p...
go
func (process *TeleportProcess) connectToAuthService(role teleport.Role) (*Connector, error) { connector, err := process.connect(role) if err != nil { return nil, trace.Wrap(err) } process.Debugf("Connected client: %v", connector.ClientIdentity) process.Debugf("Connected server: %v", connector.ServerIdentity) p...
[ "func", "(", "process", "*", "TeleportProcess", ")", "connectToAuthService", "(", "role", "teleport", ".", "Role", ")", "(", "*", "Connector", ",", "error", ")", "{", "connector", ",", "err", ":=", "process", ".", "connect", "(", "role", ")", "\n", "if",...
// connectToAuthService attempts to login into the auth servers specified in the // configuration and receive credentials.
[ "connectToAuthService", "attempts", "to", "login", "into", "the", "auth", "servers", "specified", "in", "the", "configuration", "and", "receive", "credentials", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L72-L82
24,183
gravitational/teleport
lib/service/connect.go
newWatcher
func (process *TeleportProcess) newWatcher(conn *Connector, watch services.Watch) (services.Watcher, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return process.localAuth.NewWatcher(process.ExitContext(), watch) } return conn.Client.NewWatcher(...
go
func (process *TeleportProcess) newWatcher(conn *Connector, watch services.Watch) (services.Watcher, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return process.localAuth.NewWatcher(process.ExitContext(), watch) } return conn.Client.NewWatcher(...
[ "func", "(", "process", "*", "TeleportProcess", ")", "newWatcher", "(", "conn", "*", "Connector", ",", "watch", "services", ".", "Watch", ")", "(", "services", ".", "Watcher", ",", "error", ")", "{", "if", "conn", ".", "ClientIdentity", ".", "ID", ".", ...
// newWatcher returns a new watcher, // either using local auth server connection or remote client
[ "newWatcher", "returns", "a", "new", "watcher", "either", "using", "local", "auth", "server", "connection", "or", "remote", "client" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L279-L284
24,184
gravitational/teleport
lib/service/connect.go
getCertAuthority
func (process *TeleportProcess) getCertAuthority(conn *Connector, id services.CertAuthID, loadPrivateKeys bool) (services.CertAuthority, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return process.localAuth.GetCertAuthority(id, loadPrivateKeys) ...
go
func (process *TeleportProcess) getCertAuthority(conn *Connector, id services.CertAuthID, loadPrivateKeys bool) (services.CertAuthority, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return process.localAuth.GetCertAuthority(id, loadPrivateKeys) ...
[ "func", "(", "process", "*", "TeleportProcess", ")", "getCertAuthority", "(", "conn", "*", "Connector", ",", "id", "services", ".", "CertAuthID", ",", "loadPrivateKeys", "bool", ")", "(", "services", ".", "CertAuthority", ",", "error", ")", "{", "if", "conn"...
// getCertAuthority returns cert authority by ID. // In case if auth servers, the role is 'TeleportAdmin' and instead of using // TLS client this method uses the local auth server.
[ "getCertAuthority", "returns", "cert", "authority", "by", "ID", ".", "In", "case", "if", "auth", "servers", "the", "role", "is", "TeleportAdmin", "and", "instead", "of", "using", "TLS", "client", "this", "method", "uses", "the", "local", "auth", "server", "....
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L289-L294
24,185
gravitational/teleport
lib/service/connect.go
reRegister
func (process *TeleportProcess) reRegister(conn *Connector, additionalPrincipals []string, dnsNames []string, rotation services.Rotation) (*auth.Identity, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return auth.GenerateIdentity(process.localAuth...
go
func (process *TeleportProcess) reRegister(conn *Connector, additionalPrincipals []string, dnsNames []string, rotation services.Rotation) (*auth.Identity, error) { if conn.ClientIdentity.ID.Role == teleport.RoleAdmin || conn.ClientIdentity.ID.Role == teleport.RoleAuth { return auth.GenerateIdentity(process.localAuth...
[ "func", "(", "process", "*", "TeleportProcess", ")", "reRegister", "(", "conn", "*", "Connector", ",", "additionalPrincipals", "[", "]", "string", ",", "dnsNames", "[", "]", "string", ",", "rotation", "services", ".", "Rotation", ")", "(", "*", "auth", "."...
// reRegister receives new identity credentials for proxy, node and auth. // In case if auth servers, the role is 'TeleportAdmin' and instead of using // TLS client this method uses the local auth server.
[ "reRegister", "receives", "new", "identity", "credentials", "for", "proxy", "node", "and", "auth", ".", "In", "case", "if", "auth", "servers", "the", "role", "is", "TeleportAdmin", "and", "instead", "of", "using", "TLS", "client", "this", "method", "uses", "...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L299-L323
24,186
gravitational/teleport
lib/service/connect.go
periodicSyncRotationState
func (process *TeleportProcess) periodicSyncRotationState() error { // start rotation only after teleport process has started eventC := make(chan Event, 1) process.WaitForEvent(process.ExitContext(), TeleportReadyEvent, eventC) select { case <-eventC: process.Infof("The new service has started successfully. Star...
go
func (process *TeleportProcess) periodicSyncRotationState() error { // start rotation only after teleport process has started eventC := make(chan Event, 1) process.WaitForEvent(process.ExitContext(), TeleportReadyEvent, eventC) select { case <-eventC: process.Infof("The new service has started successfully. Star...
[ "func", "(", "process", "*", "TeleportProcess", ")", "periodicSyncRotationState", "(", ")", "error", "{", "// start rotation only after teleport process has started", "eventC", ":=", "make", "(", "chan", "Event", ",", "1", ")", "\n", "process", ".", "WaitForEvent", ...
// periodicSyncRotationState checks rotation state periodically and // takes action if necessary
[ "periodicSyncRotationState", "checks", "rotation", "state", "periodically", "and", "takes", "action", "if", "necessary" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L441-L466
24,187
gravitational/teleport
lib/service/connect.go
syncRotationStateAndBroadcast
func (process *TeleportProcess) syncRotationStateAndBroadcast(conn *Connector) (*rotationStatus, error) { status, err := process.syncRotationState(conn) if err != nil { process.BroadcastEvent(Event{Name: TeleportDegradedEvent, Payload: nil}) if trace.IsConnectionProblem(err) { process.Warningf("Connection prob...
go
func (process *TeleportProcess) syncRotationStateAndBroadcast(conn *Connector) (*rotationStatus, error) { status, err := process.syncRotationState(conn) if err != nil { process.BroadcastEvent(Event{Name: TeleportDegradedEvent, Payload: nil}) if trace.IsConnectionProblem(err) { process.Warningf("Connection prob...
[ "func", "(", "process", "*", "TeleportProcess", ")", "syncRotationStateAndBroadcast", "(", "conn", "*", "Connector", ")", "(", "*", "rotationStatus", ",", "error", ")", "{", "status", ",", "err", ":=", "process", ".", "syncRotationState", "(", "conn", ")", "...
// syncRotationStateAndBroadcast syncs rotation state and broadcasts events // when phase has been changed or reload happened
[ "syncRotationStateAndBroadcast", "syncs", "rotation", "state", "and", "broadcasts", "events", "when", "phase", "has", "been", "changed", "or", "reload", "happened" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L546-L570
24,188
gravitational/teleport
lib/service/connect.go
syncRotationState
func (process *TeleportProcess) syncRotationState(conn *Connector) (*rotationStatus, error) { connectors := process.getConnectors() ca, err := process.getCertAuthority(conn, services.CertAuthID{ DomainName: conn.ClientIdentity.ClusterName, Type: services.HostCA, }, false) if err != nil { return nil, tra...
go
func (process *TeleportProcess) syncRotationState(conn *Connector) (*rotationStatus, error) { connectors := process.getConnectors() ca, err := process.getCertAuthority(conn, services.CertAuthID{ DomainName: conn.ClientIdentity.ClusterName, Type: services.HostCA, }, false) if err != nil { return nil, tra...
[ "func", "(", "process", "*", "TeleportProcess", ")", "syncRotationState", "(", "conn", "*", "Connector", ")", "(", "*", "rotationStatus", ",", "error", ")", "{", "connectors", ":=", "process", ".", "getConnectors", "(", ")", "\n", "ca", ",", "err", ":=", ...
// syncRotationState compares cluster rotation state with the state of // internal services and performs the rotation if necessary.
[ "syncRotationState", "compares", "cluster", "rotation", "state", "with", "the", "state", "of", "internal", "services", "and", "performs", "the", "rotation", "if", "necessary", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L574-L598
24,189
gravitational/teleport
lib/service/connect.go
newClient
func (process *TeleportProcess) newClient(authServers []utils.NetAddr, identity *auth.Identity) (*auth.Client, bool, error) { directClient, err := process.newClientDirect(authServers, identity) if err != nil { return nil, false, trace.Wrap(err) } // Try and connect to the Auth Server. If the request fails, try a...
go
func (process *TeleportProcess) newClient(authServers []utils.NetAddr, identity *auth.Identity) (*auth.Client, bool, error) { directClient, err := process.newClientDirect(authServers, identity) if err != nil { return nil, false, trace.Wrap(err) } // Try and connect to the Auth Server. If the request fails, try a...
[ "func", "(", "process", "*", "TeleportProcess", ")", "newClient", "(", "authServers", "[", "]", "utils", ".", "NetAddr", ",", "identity", "*", "auth", ".", "Identity", ")", "(", "*", "auth", ".", "Client", ",", "bool", ",", "error", ")", "{", "directCl...
// newClient attempts to connect directly to the Auth Server. If it fails, it // falls back to trying to connect to the Auth Server through the proxy.
[ "newClient", "attempts", "to", "connect", "directly", "to", "the", "Auth", "Server", ".", "If", "it", "fails", "it", "falls", "back", "to", "trying", "to", "connect", "to", "the", "Auth", "Server", "through", "the", "proxy", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L778-L806
24,190
gravitational/teleport
lib/service/connect.go
findReverseTunnel
func (process *TeleportProcess) findReverseTunnel(addrs []utils.NetAddr) (string, error) { var errs []error for _, addr := range addrs { // In insecure mode, any certificate is accepted. In secure mode the hosts // CAs are used to validate the certificate on the proxy. clt, err := client.NewCredentialsClient( ...
go
func (process *TeleportProcess) findReverseTunnel(addrs []utils.NetAddr) (string, error) { var errs []error for _, addr := range addrs { // In insecure mode, any certificate is accepted. In secure mode the hosts // CAs are used to validate the certificate on the proxy. clt, err := client.NewCredentialsClient( ...
[ "func", "(", "process", "*", "TeleportProcess", ")", "findReverseTunnel", "(", "addrs", "[", "]", "utils", ".", "NetAddr", ")", "(", "string", ",", "error", ")", "{", "var", "errs", "[", "]", "error", "\n", "for", "_", ",", "addr", ":=", "range", "ad...
// findReverseTunnel uses the web proxy to discover where the SSH reverse tunnel // server is running.
[ "findReverseTunnel", "uses", "the", "web", "proxy", "to", "discover", "where", "the", "SSH", "reverse", "tunnel", "server", "is", "running", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/connect.go#L810-L835
24,191
gravitational/teleport
lib/utils/spki.go
CalculateSPKI
func CalculateSPKI(cert *x509.Certificate) string { sum := sha256.Sum256(cert.RawSubjectPublicKeyInfo) return "sha256:" + hex.EncodeToString(sum[:]) }
go
func CalculateSPKI(cert *x509.Certificate) string { sum := sha256.Sum256(cert.RawSubjectPublicKeyInfo) return "sha256:" + hex.EncodeToString(sum[:]) }
[ "func", "CalculateSPKI", "(", "cert", "*", "x509", ".", "Certificate", ")", "string", "{", "sum", ":=", "sha256", ".", "Sum256", "(", "cert", ".", "RawSubjectPublicKeyInfo", ")", "\n", "return", "\"", "\"", "+", "hex", ".", "EncodeToString", "(", "sum", ...
// CalculateSPKI the hash value of the SPKI header in a certificate.
[ "CalculateSPKI", "the", "hash", "value", "of", "the", "SPKI", "header", "in", "a", "certificate", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/spki.go#L30-L33
24,192
gravitational/teleport
lib/utils/spki.go
CheckSPKI
func CheckSPKI(pin string, cert *x509.Certificate) error { // Check that the format of the pin is valid. parts := strings.Split(pin, ":") if len(parts) != 2 { return trace.BadParameter("invalid format for certificate pin, expected algorithm:pin") } if parts[0] != "sha256" { return trace.BadParameter("sha256 on...
go
func CheckSPKI(pin string, cert *x509.Certificate) error { // Check that the format of the pin is valid. parts := strings.Split(pin, ":") if len(parts) != 2 { return trace.BadParameter("invalid format for certificate pin, expected algorithm:pin") } if parts[0] != "sha256" { return trace.BadParameter("sha256 on...
[ "func", "CheckSPKI", "(", "pin", "string", ",", "cert", "*", "x509", ".", "Certificate", ")", "error", "{", "// Check that the format of the pin is valid.", "parts", ":=", "strings", ".", "Split", "(", "pin", ",", "\"", "\"", ")", "\n", "if", "len", "(", "...
// CheckSPKI the passed in pin against the calculated value from a certificate.
[ "CheckSPKI", "the", "passed", "in", "pin", "against", "the", "calculated", "value", "from", "a", "certificate", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/spki.go#L36-L53
24,193
gravitational/teleport
lib/httplib/httplib.go
MakeHandler
func MakeHandler(fn HandlerFunc) httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { // ensure that neither proxies nor browsers cache http traffic SetNoCacheHeaders(w.Header()) out, err := fn(w, r, p) if err != nil { trace.WriteError(w, err) return } if ou...
go
func MakeHandler(fn HandlerFunc) httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { // ensure that neither proxies nor browsers cache http traffic SetNoCacheHeaders(w.Header()) out, err := fn(w, r, p) if err != nil { trace.WriteError(w, err) return } if ou...
[ "func", "MakeHandler", "(", "fn", "HandlerFunc", ")", "httprouter", ".", "Handle", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "p", "httprouter", ".", "Params", ")", "{", "// ensure that neith...
// MakeHandler returns a new httprouter.Handle func from a handler func
[ "MakeHandler", "returns", "a", "new", "httprouter", ".", "Handle", "func", "from", "a", "handler", "func" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L45-L59
24,194
gravitational/teleport
lib/httplib/httplib.go
MakeStdHandler
func MakeStdHandler(fn StdHandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // ensure that neither proxies nor browsers cache http traffic SetNoCacheHeaders(w.Header()) out, err := fn(w, r) if err != nil { trace.WriteError(w, err) return } if out != nil { round...
go
func MakeStdHandler(fn StdHandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // ensure that neither proxies nor browsers cache http traffic SetNoCacheHeaders(w.Header()) out, err := fn(w, r) if err != nil { trace.WriteError(w, err) return } if out != nil { round...
[ "func", "MakeStdHandler", "(", "fn", "StdHandlerFunc", ")", "http", ".", "HandlerFunc", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "// ensure that neither proxies nor browsers cache http traffic",...
// MakeStdHandler returns a new http.Handle func from http.HandlerFunc
[ "MakeStdHandler", "returns", "a", "new", "http", ".", "Handle", "func", "from", "http", ".", "HandlerFunc" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L62-L76
24,195
gravitational/teleport
lib/httplib/httplib.go
WithCSRFProtection
func WithCSRFProtection(fn HandlerFunc) httprouter.Handle { hanlderFn := MakeHandler(fn) return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { err := csrf.VerifyHTTPHeader(r) if err != nil { log.Warningf("unable to validate CSRF token %v", err) trace.WriteError(w, trace.AccessDenied("ac...
go
func WithCSRFProtection(fn HandlerFunc) httprouter.Handle { hanlderFn := MakeHandler(fn) return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { err := csrf.VerifyHTTPHeader(r) if err != nil { log.Warningf("unable to validate CSRF token %v", err) trace.WriteError(w, trace.AccessDenied("ac...
[ "func", "WithCSRFProtection", "(", "fn", "HandlerFunc", ")", "httprouter", ".", "Handle", "{", "hanlderFn", ":=", "MakeHandler", "(", "fn", ")", "\n", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", ...
// WithCSRFProtection ensures that request to unauthenticated API is checked against CSRF attacks
[ "WithCSRFProtection", "ensures", "that", "request", "to", "unauthenticated", "API", "is", "checked", "against", "CSRF", "attacks" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L79-L90
24,196
gravitational/teleport
lib/httplib/httplib.go
ConvertResponse
func ConvertResponse(re *roundtrip.Response, err error) (*roundtrip.Response, error) { if err != nil { if uerr, ok := err.(*url.Error); ok && uerr != nil && uerr.Err != nil { return nil, trace.ConnectionProblem(uerr.Err, uerr.Error()) } return nil, trace.ConvertSystemError(err) } return re, trace.ReadError(...
go
func ConvertResponse(re *roundtrip.Response, err error) (*roundtrip.Response, error) { if err != nil { if uerr, ok := err.(*url.Error); ok && uerr != nil && uerr.Err != nil { return nil, trace.ConnectionProblem(uerr.Err, uerr.Error()) } return nil, trace.ConvertSystemError(err) } return re, trace.ReadError(...
[ "func", "ConvertResponse", "(", "re", "*", "roundtrip", ".", "Response", ",", "err", "error", ")", "(", "*", "roundtrip", ".", "Response", ",", "error", ")", "{", "if", "err", "!=", "nil", "{", "if", "uerr", ",", "ok", ":=", "err", ".", "(", "*", ...
// ConvertResponse converts http error to internal error type // based on HTTP response code and HTTP body contents
[ "ConvertResponse", "converts", "http", "error", "to", "internal", "error", "type", "based", "on", "HTTP", "response", "code", "and", "HTTP", "body", "contents" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L107-L115
24,197
gravitational/teleport
lib/httplib/httplib.go
ParseBool
func ParseBool(q url.Values, name string) (bool, bool, error) { stringVal := q.Get(name) if stringVal == "" { return false, false, nil } val, err := strconv.ParseBool(stringVal) if err != nil { return false, false, trace.BadParameter( "'%v': expected 'true' or 'false', got %v", name, stringVal) } return ...
go
func ParseBool(q url.Values, name string) (bool, bool, error) { stringVal := q.Get(name) if stringVal == "" { return false, false, nil } val, err := strconv.ParseBool(stringVal) if err != nil { return false, false, trace.BadParameter( "'%v': expected 'true' or 'false', got %v", name, stringVal) } return ...
[ "func", "ParseBool", "(", "q", "url", ".", "Values", ",", "name", "string", ")", "(", "bool", ",", "bool", ",", "error", ")", "{", "stringVal", ":=", "q", ".", "Get", "(", "name", ")", "\n", "if", "stringVal", "==", "\"", "\"", "{", "return", "fa...
// ParseBool will parse boolean variable from url query // returns value, ok, error
[ "ParseBool", "will", "parse", "boolean", "variable", "from", "url", "query", "returns", "value", "ok", "error" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L119-L131
24,198
gravitational/teleport
lib/httplib/httplib.go
Rewrite
func Rewrite(in, out string) RewritePair { return RewritePair{ Expr: regexp.MustCompile(in), Replacement: out, } }
go
func Rewrite(in, out string) RewritePair { return RewritePair{ Expr: regexp.MustCompile(in), Replacement: out, } }
[ "func", "Rewrite", "(", "in", ",", "out", "string", ")", "RewritePair", "{", "return", "RewritePair", "{", "Expr", ":", "regexp", ".", "MustCompile", "(", "in", ")", ",", "Replacement", ":", "out", ",", "}", "\n", "}" ]
// Rewrite creates a rewrite pair, panics if in epxression // is not a valid regular expressoin
[ "Rewrite", "creates", "a", "rewrite", "pair", "panics", "if", "in", "epxression", "is", "not", "a", "valid", "regular", "expressoin" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L143-L148
24,199
gravitational/teleport
lib/httplib/httplib.go
RewritePaths
func RewritePaths(next http.Handler, rewrites ...RewritePair) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { for _, rewrite := range rewrites { req.URL.Path = rewrite.Expr.ReplaceAllString(req.URL.Path, rewrite.Replacement) } next.ServeHTTP(w, req) }) }
go
func RewritePaths(next http.Handler, rewrites ...RewritePair) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { for _, rewrite := range rewrites { req.URL.Path = rewrite.Expr.ReplaceAllString(req.URL.Path, rewrite.Replacement) } next.ServeHTTP(w, req) }) }
[ "func", "RewritePaths", "(", "next", "http", ".", "Handler", ",", "rewrites", "...", "RewritePair", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", "."...
// RewritePaths creates a middleware that rewrites paths in incoming request
[ "RewritePaths", "creates", "a", "middleware", "that", "rewrites", "paths", "in", "incoming", "request" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httplib.go#L151-L158