id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c24100
}, Allow: RoleConditions{ Namespaces: []string{defaults.Namespace}, Rules: CopyRulesSlice(DefaultImplicitRules), }, }, } }
c24101
MaxSessionTTL: NewDuration(defaults.MaxCertDuration), PortForwarding: NewBoolOption(true), ForwardAgent: NewBool(true), }, Allow: RoleConditions{ Namespaces: []string{defaults.Namespace}, NodeLabels: Labels{Wildcard: []string{Wildcard}}, Rules: CopyRulesSlice(AdminUserRule...
c24102
}, Spec: RoleSpecV3{ Options: RoleOptions{ MaxSessionTTL: NewDuration(defaults.MaxCertDuration), }, Allow: RoleConditions{ Namespaces: []string{defaults.Namespace}, NodeLabels: Labels{Wildcard: []string{Wildcard}}, Rules: CopyRulesSlice(DefaultCertAuthorityRules), }, }, } }
c24103
role.SetLogins(Allow, v1.AllowedLogins) ca.AddRole(role.GetName()) return ca, role }
c24104
is supported at the moment. if variablePrefix == teleport.TraitInternalPrefix { if variableName != teleport.TraitLogins && variableName != teleport.TraitKubeGroups { return nil, trace.BadParameter("unsupported variable %q", variableName) } } // If the variable is not found in the traits, skip it. variableV...
c24105
return false } if !r.GetNodeLabels(condition).Equals(other.GetNodeLabels(condition)) { return false } if !RuleSlicesEqual(r.GetRules(condition), other.GetRules(condition)) { return false } } return true }
c24106
return r.Spec.Allow.Logins } return r.Spec.Deny.Logins }
c24107
r.Spec.Allow.Logins = lcopy } else { r.Spec.Deny.Logins = lcopy } }
c24108
return r.Spec.Allow.KubeGroups } return r.Spec.Deny.KubeGroups }
c24109
r.Spec.Allow.KubeGroups = lcopy } else { r.Spec.Deny.KubeGroups = lcopy } }
c24110
return r.Spec.Allow.Namespaces } return r.Spec.Deny.Namespaces }
c24111
r.Spec.Allow.Namespaces = ncopy } else { r.Spec.Deny.Namespaces = ncopy } }
c24112
return r.Spec.Allow.NodeLabels } return r.Spec.Deny.NodeLabels }
c24113
== Allow { r.Spec.Allow.NodeLabels = labels.Clone() } else { r.Spec.Deny.NodeLabels = labels.Clone() } }
c24114
return r.Spec.Allow.Rules } return r.Spec.Deny.Rules }
c24115
r.Spec.Allow.Rules = rcopy } else { r.Spec.Deny.Rules = rcopy } }
c24116
r.GetName(), r.Spec.Options, r.Spec.Allow, r.Spec.Deny) }
c24117
{ return Rule{ Resources: []string{resource}, Verbs: verbs, } }
c24118
if len(r.Actions) != 0 { parser, err := GetActionsParserFn()(&Context{}) if err != nil { return trace.Wrap(err) } for i, action := range r.Actions { _, err = parser.Parse(action) if err != nil { return trace.BadParameter("could not parse action %v %q, error: %v", i, action, err) } } } retur...
c24119
than // whether the rules are wildcard or not, so here we have +8 vs // -4 and -2 score penalty for wildcards in resources and verbs if len(r.Where) > 0 { score += 8 } // rules featuring actions are more specific if len(r.Actions) > 0 { score += 8 } return score }
c24120
if err != nil { return false, trace.Wrap(err) } fn, ok := ifn.(predicate.BoolPredicate) if !ok { return false, trace.BadParameter("unsupported type: %T", ifn) } return fn(), nil }
c24121
ok := ifn.(predicate.BoolPredicate) if !ok { return trace.BadParameter("unsupported type: %T", ifn) } fn() } return nil }
c24122
== resource { return true } } return false }
c24123
== VerbRead { return true } continue } if v == verb { return true } } return false }
c24124
if !utils.StringSlicesEqual(r.Actions, other.Actions) { return false } if r.Where != other.Where { return false } return true }
c24125
out = append(out, rules...) } return out }
c24126
specific rule, the rule that has actions // is more specific than the one that has no actions sort.Slice(rules, func(i, j int) bool { return rules[i].IsMoreSpecificThan(rules[j]) }) set[resource] = rules } return set }
c24127
len(in)) copy(out, in) return out }
c24128
{ if !a[i].Equals(b[i]) { return false } } return true }
c24129
return r.V3().Equals(other) }
c24130
== nil { r.Spec.Resources = make(map[string][]string) } r.Spec.Resources[kind] = actions }
c24131
string) { delete(r.Spec.Resources, kind) }
c24132
map[string]string) { r.Spec.NodeLabels = labels }
c24133
time.Duration) { r.Spec.MaxSessionTTL = Duration(duration) }
c24134
return nil, trace.Wrap(err) } return NewRoleSet(role), nil }
c24135
Spec: spec, } if err := role.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } return &role, nil }
c24136
return nil, trace.Wrap(err) } roles = append(roles, role.ApplyTraits(traits)) } return NewRoleSet(roles...), nil }
c24137
1 && roles[0].GetName() == string(teleport.RoleNop) { return roles } return append(roles, NewImplicitRole()) }
c24138
return false, fmt.Sprintf("no match, role selectors %v, server namespace: %v", selectors, namespace) }
c24139
} return false, fmt.Sprintf("no match, role selectors %v, login: %v", selectors, login) }
c24140
match: '%v'", key), nil } if !utils.SliceContainsStr(selectorValues, Wildcard) { result, err := utils.SliceMatchesRegex(targetVal, selectorValues) if err != nil { return false, "", trace.Wrap(err) } else if !result { return false, fmt.Sprintf("no value match: got '%v' want: '%v'", targetVal, sele...
c24141
len(set)) for i, r := range set { out[i] = r.GetName() } return out }
c24142
== role { return true } } return false }
c24143
if maxSessionTTL != 0 && ttl > maxSessionTTL { ttl = maxSessionTTL } } return ttl }
c24144
// does not restrict the idle timeout, pick any other value // set by the role case timeout == 0: timeout = roleTimeout.Duration() case roleTimeout.Duration() < timeout: timeout = roleTimeout.Duration() } } return timeout }
c24145
:= range set { if role.GetOptions().DisconnectExpiredCert.Value() { disconnect = true } } return disconnect }
c24146
%v", ttl) } if len(groups) == 0 { return nil, trace.AccessDenied("this user cannot request kubernetes access, has no assigned groups") } out := make([]string, 0, len(groups)) for group := range groups { out = append(out, group) } return out, nil }
c24147
user cannot request a certificate for %v", ttl) } if len(logins) == 0 { return nil, trace.AccessDenied("this user cannot create SSH sessions, has no allowed logins") } out := make([]string, 0, len(logins)) for login := range logins { out = append(out, login) } return out, nil }
c24148
if role.GetOptions().ForwardAgent.Value() { return true } } return false }
c24149
BoolDefaultTrue(role.GetOptions().PortForwarding) { return true } } return false }
c24150
== 0 { return teleport.CertificateFormatStandard } // sort the slice so the most permissive is the first element sort.Slice(formats, func(i, j int) bool { return certificatePriority(formats[i]) < certificatePriority(formats[j]) }) return formats[0] }
c24151
can't login // in the first place. for _, role := range set { for _, l := range role.GetLogins(Allow) { if role.GetOptions().ForwardAgent.Value() && l == login { return nil } } } return trace.AccessDenied("%v can not forward agent for %v", set, login) }
c24152
cvals := make([]string, len(vals)) copy(cvals, vals) out[key] = cvals } return out }
c24153
if !utils.StringSlicesEqual(l[key], o[key]) { return false } } return true }
c24154
return b.protoType().MarshalTo(data) }
c24155
} else { out, err := time.ParseDuration(stringVar) if err != nil { return trace.BadParameter(err.Error()) } *d = Duration(out) } return nil }
c24156
fmt.Sprintf(schemaTemplate, ``) if extensionSchema != "" { schema = fmt.Sprintf(schemaTemplate, ","+extensionSchema) } return fmt.Sprintf(V2SchemaTemplate, MetadataSchema, schema, schemaDefinitions) }
c24157
nil { return nil, trace.BadParameter(err.Error()) } } if err := role.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } if cfg.ID != 0 { role.SetResourceID(cfg.ID) } if !cfg.Expires.IsZero() { role.SetExpiry(cfg.Expires) } return &role, nil } return nil, trace.BadPar...
c24158
{ return UnmarshalRole(bytes, opts...) }
c24159
if !cfg.PreserveResourceID { // avoid modifying the original object // to prevent unexpected data races copy := *role copy.SetResourceID(0) role = &copy } return utils.FastMarshal(role) default: return nil, trace.BadParameter("unrecognized role version %T", r) } }
c24160
"Resource spec: 'type/[name]'").SetValue(&g.ref) g.getCmd.Flag("format", "Output format: 'yaml', 'json' or 'text'").Default(formatYAML).StringVar(&g.format) g.getCmd.Flag("namespace", "Namespace of the resources").Hidden().Default(defaults.Namespace).StringVar(&g.namespace) g.getCmd.Flag("with-secrets", "Include se...
c24161
return cmd == g.deleteCmd.FullCommand() }
c24162
collection.writeYAML(os.Stdout) case teleport.Text: return collection.writeText(os.Stdout) case teleport.JSON: return collection.writeJSON(os.Stdout) } return trace.BadParameter("unsupported format") }
c24163
the creator function for a given resource kind: creator, found := u.CreateHandlers[ResourceKind(raw.Kind)] if !found { return trace.BadParameter("creating resources of type %q is not supported", raw.Kind) } // only return in case of error, to create multiple resources // in case if yaml spec is a list i...
c24164
} out, err := client.UpsertTrustedCluster(tc) if err != nil { // If force is used and UpsertTrustedCluster returns trace.AlreadyExists, // this means the user tried to upsert a cluster whose exact match already // exists in the backend, nothing needs to occur other than happy message // that the trusted cl...
c24165
!= nil { return trace.Wrap(err) } fmt.Printf("certificate authority '%s' has been updated\n", certAuthority.GetName()) return nil }
c24166
err := client.UpsertUser(user); err != nil { return trace.Wrap(err) } fmt.Printf("user '%s' has been updated\n", userName) return nil }
c24167
client.DeleteReverseTunnel(d.ref.Name); err != nil { return trace.Wrap(err) } fmt.Printf("reverse tunnel %v has been deleted\n", d.ref.Name) case services.KindTrustedCluster: if err = client.DeleteTrustedCluster(d.ref.Name); err != nil { return trace.Wrap(err) } fmt.Printf("trusted cluster %q has been...
c24168
if err != nil { return nil, trace.Wrap(err) } return &certificateCache{ keygen: keygen, cache: cache, authClient: authClient, }, nil }
c24169
= c.generateHostCert(principals) if err != nil { return nil, trace.Wrap(err) } err = c.set(addr, certificate, defaults.HostCertCacheTime) if err != nil { return nil, trace.Wrap(err) } } return certificate, nil }
c24170
certificate.(ssh.Signer) if !ok { return nil, false } return certificateSigner, true }
c24171
c.cache.Set(addr, certificate, ttl) if err != nil { return trace.Wrap(err) } return nil }
c24172
certBytes, err := c.authClient.GenerateHostCert( pubBytes, principals[0], principals[0], principals, clusterName, teleport.Roles{teleport.RoleNode}, 0) if err != nil { return nil, trace.Wrap(err) } // create a *ssh.Certificate privateKey, err := ssh.ParsePrivateKey(privBytes) if err != nil { re...
c24173
err != nil { return nil, trace.Wrap(err) } return &Monitor{ MonitorConfig: cfg, }, nil }
c24174
{ return service.Run(context.TODO(), *config, nil) }
c24175
: %s, logged in as %s from %s\n", teleportUser, systemUser, sshClient) fmt.Printf("Cluster Name: %s\n", clusterName) fmt.Printf("Host UUID : %s\n", hostUUID) fmt.Printf("Session ID : %s\n", sid) fmt.Printf("Session URL : https://%s/web/cluster/%v/node/%v/%v/%v\n", proxyHost, clusterName, hostUUID, systemUser, s...
c24176
:= make([]byte, len(in)) copy(out, in) return out }
c24177
i := range in { out[i] = CopyByteSlice(in[i]) } return out }
c24178
make([]string, 0, len(a)+len(b)) out = append(out, a...) out = append(out, b...) return out }
c24179
out := make([]string, len(in)) copy(out, in) return out }
c24180
out = append(out, new) } else { out = append(out, x) } } return out }
c24181
} } } process.Infof("%v failed attempt connecting to auth server: %v.", role, err) // Wait in between attempts, but return if teleport is shutting down select { case <-time.After(retryTime): case <-process.ExitContext().Done(): process.Infof("%v stopping connection attempts, teleport is shutting down...
c24182
process.Debugf("Connected client: %v", connector.ClientIdentity) process.Debugf("Connected server: %v", connector.ServerIdentity) process.addConnector(connector) return connector, nil }
c24183
return process.localAuth.NewWatcher(process.ExitContext(), watch) } return conn.Client.NewWatcher(process.ExitContext(), watch) }
c24184
return process.localAuth.GetCertAuthority(id, loadPrivateKeys) } return conn.Client.GetCertAuthority(id, loadPrivateKeys) }
c24185
keyPair.PrivateKey, PublicTLSKey: keyPair.PublicTLSKey, PublicSSHKey: keyPair.PublicSSHKey, DNSNames: dnsNames, Rotation: rotation, }) if err != nil { return nil, trace.Wrap(err) } process.deleteKeyPair(conn.ClientIdentity.ID.Role, reason) return identity, nil...
c24186
period %v.", process.Config.PollingPeriod) case <-process.ExitContext().Done(): return nil } retryTicker := time.NewTicker(defaults.HighResPollingPeriod) defer retryTicker.Stop() for { err := process.syncRotationStateCycle() if err == nil { return nil } process.Warningf("Sync rotation state cycle fa...
c24187
detected cert authority reload phase update.") } if status.phaseChanged { process.BroadcastEvent(Event{Name: TeleportPhaseChangeEvent}) } if status.needsReload { process.Debugf("Triggering reload process.") process.BroadcastEvent(Event{Name: TeleportReloadEvent}) } return status, nil }
c24188
conn) if err != nil { return nil, trace.Wrap(err) } if serviceStatus.needsReload { status.needsReload = true } if serviceStatus.phaseChanged { status.phaseChanged = true } } return &status, nil }
c24189
trace.Wrap(err) } log.Debugf("Attempting to connect to Auth Server through tunnel.") tunnelClient, er := process.newClientThroughTunnel(authServers, identity) if er != nil { return nil, false, trace.NewAggregate(err, er) } log.Debugf("Connected to Auth Server through tunnel.") return tunnelClient, t...
c24190
nil { // If a tunnel public address is set, return it otherwise return the // tunnel listen address. if resp.Proxy.SSH.TunnelPublicAddr != "" { return resp.Proxy.SSH.TunnelPublicAddr, nil } return resp.Proxy.SSH.TunnelListenAddr, nil } errs = append(errs, err) } return "", trace.NewAggregate(e...
c24191
return "sha256:" + hex.EncodeToString(sum[:]) }
c24192
if parts[0] != "sha256" { return trace.BadParameter("sha256 only supported hashing algorithm for certificate pin") } // Check that that pin itself matches that value calculated from the passed // in certificate. if subtle.ConstantTimeCompare([]byte(CalculateSPKI(cert)), []byte(pin)) != 1 { return trace.BadPa...
c24193
if err != nil { trace.WriteError(w, err) return } if out != nil { roundtrip.ReplyJSON(w, http.StatusOK, out) } } }
c24194
err != nil { trace.WriteError(w, err) return } if out != nil { roundtrip.ReplyJSON(w, http.StatusOK, out) } } }
c24195
validate CSRF token %v", err) trace.WriteError(w, trace.AccessDenied("access denied")) return } hanlderFn(w, r, p) } }
c24196
&& uerr != nil && uerr.Err != nil { return nil, trace.ConnectionProblem(uerr.Err, uerr.Error()) } return nil, trace.ConvertSystemError(err) } return re, trace.ReadError(re.Code(), re.Bytes()) }
c24197
false, false, trace.BadParameter( "'%v': expected 'true' or 'false', got %v", name, stringVal) } return val, true, nil }
c24198
regexp.MustCompile(in), Replacement: out, } }
c24199
*http.Request) { for _, rewrite := range rewrites { req.URL.Path = rewrite.Expr.ReplaceAllString(req.URL.Path, rewrite.Replacement) } next.ServeHTTP(w, req) }) }