id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c24200
url.Parse(redirectURL) if err != nil { return trace.Wrap(err) } http.Redirect(w, r, parsedURL.RequestURI(), http.StatusFound) return nil }
c24201
} // update ctx with a session ID c.session, _ = findSession() if c.session == nil { log.Debugf("Will create new session for SSH connection %v.", c.Conn.RemoteAddr()) } else { log.Debugf("Will join session %v for SSH connection %v.", c.session, c.Conn.RemoteAddr()) } return nil }
c24202
c.clientLastActive = c.srv.GetClock().Now().UTC() }
c24203
defer c.RUnlock() return c.agent }
c24204
defer c.RUnlock() return c.agentChannel }
c24205
previous agent channel") c.agentChannel.Close() } c.agentChannel = channel c.agent = a }
c24206
defer c.RUnlock() return c.term }
c24207
defer c.Unlock() c.term = t }
c24208
{ c.env[key] = val }
c24209
val, ok := c.env[key] return val, ok }
c24210
log.Infof("blocked on sending exec result %v", r) } }
c24211
c.Infof("blocked on sending subsystem result") } }
c24212
proxy list: %v", err) } if len(proxies) > 0 { proxyHost = proxies[0].GetPublicAddr() if proxyHost == "" { proxyHost = fmt.Sprintf("%v:%v", proxies[0].GetHostname(), defaults.HTTPListenPort) c.Debugf("public_address not set for proxy, returning proxyHost: %q", proxyHost) } } return proxyHost }
c24213
*TrackingReader { return &TrackingReader{ctx: ctx, r: r} }
c24214
error) { a.ctx.UpdateClientActivity() return a.r.Read(b) }
c24215
} if c.Stdout == nil { return trace.BadParameter("required parameter Stdout missing") } if c.Stderr == nil { return trace.BadParameter("required parameter Stderr missing") } return nil }
c24216
if err != nil { return nil, trace.Wrap(err) } return authContext, nil }
c24217
err != nil { return nil, trace.Wrap(err) } return &contextAuthorizer{authContext: *authContext}, nil }
c24218
nil { return nil, trace.Wrap(err) } return &contextAuthorizer{authContext: *authContext}, nil }
c24219
} if trust == nil { return nil, trace.BadParameter("missing parameter trust") } return &authorizer{access: access, identity: identity, trust: trust}, nil }
c24220
contextForLocalUser(u.Username, a.identity, a.access) }
c24221
%q to local roles %v and traits %v.", u.RemoteRoles, u.Username, roleNames, traits) checker, err := services.FetchRoles(roleNames, a.access, traits) if err != nil { return nil, trace.Wrap(err) } // The user is prefixed with "remote-" and suffixed with cluster name with // the hope that it does not match a real ...
c24222
if err != nil { return nil, trace.Wrap(err) } return contextForBuiltinRole(r.ClusterName, config, r.Role, r.Username) }
c24223
%v hours", int(defaults.SignupTokenTTL/time.Hour), int(defaults.MaxSignupTokenTTL/time.Hour))). Default(fmt.Sprintf("%v", defaults.SignupTokenTTL)).DurationVar(&u.ttl) u.userAdd.Flag("format", "Output format, 'text' or 'json'").Hidden().Default(teleport.Text).StringVar(&u.format) u.userAdd.Alias(AddUserHelp) u...
c24224
err := client.CreateSignupToken(user, u.ttl) if err != nil { return err } // try to auto-suggest the activation link return u.PrintSignupURL(client, token, u.ttl, u.format) }
c24225
with the user:\n%v\n\n", int(ttl/time.Hour), signupURL) fmt.Printf("NOTE: Make sure %v points at a Teleport proxy which users can access.\n", proxyHost) } else { out, err := json.MarshalIndent(services.NewInviteToken(token, signupURL, time.Now().Add(ttl).UTC()), "", " ") if err != nil { return trace.Wrap...
c24226
} } user.SetRoles(roles) if err := client.UpsertUser(user); err != nil { return trace.Wrap(err) } fmt.Printf("%v has been updated with roles %v\n", user.GetName(), strings.Join(user.GetRoles(), ",")) return nil }
c24227
t.AddRow([]string{u.GetName(), strings.Join(logins, ",")}) } fmt.Println(t.AsBuffer().String()) } else { out, err := json.MarshalIndent(users, "", " ") if err != nil { return trace.Wrap(err, "failed to marshal users") } fmt.Printf(string(out)) } return nil }
c24228
return trace.ConvertSystemError(err) } if err := os.Chmod(path, mode); err != nil { l.Close() return trace.ConvertSystemError(err) } a.listener = l a.path = path return nil }
c24229
time.Second; tempDelay > max { tempDelay = max } log.Errorf("got temp error: %v, will sleep %v", err, tempDelay) time.Sleep(tempDelay) continue } tempDelay = 0 go func() { if err := agent.ServeAgent(a.Agent, conn); err != nil { if err != io.EOF { log.Errorf(err.Error()) } } }...
c24230
return trace.Wrap(err) } a.listener = l return a.Serve() }
c24231
a.path != "" { if err := os.Remove(a.path); err != nil { errors = append(errors, trace.ConvertSystemError(err)) } } return trace.NewAggregate(errors...) }
c24232
} err := VerifyToken(token, r) if err != nil { return trace.Wrap(err) } return nil }
c24233
err != nil { return trace.Wrap(err, "unable to decode CSRF token") } decodedTokenB, err := decode(realToken) if err != nil { return trace.Wrap(err, "unable to decode cookie CSRF token") } if !compareTokens(decodedTokenA, decodedTokenB) { return trace.BadParameter("CSRF tokens do not match") } return ni...
c24234
return "", trace.Wrap(err) } return cookie.Value, nil }
c24235
"/", } // write the authenticated cookie to the response. http.SetCookie(w, cookie) w.Header().Add("Vary", "Cookie") return encodedToken }
c24236
events.AuthAttemptSuccess: false, // log the original internal error in audit log events.AuthAttemptErr: trace.Unwrap(err).Error(), }) } else { a.EmitAuditEvent(events.UserSSOLogin, events.EventFields{ events.EventUser: re.Username, events.AuthAttemptSuccess: true, events.LoginMethod: ...
c24237
return nil, trace.AccessDenied("unable to map claims to role for connector: %v", connector.GetName()) } return roles, nil }
c24238
claimValues, ok, _ := claims.StringsClaim(claimName) if ok { traits[claimName] = claimValues } } return traits }
c24239
} log.Debugf("Extracting OIDC claims from ID token.") claims, err := jwt.Claims() if err != nil { return nil, trace.Wrap(err) } return claims, nil }
c24240
collect } response, err := g.fetchGroupsPage(nextPageToken) if err != nil { return nil, trace.Wrap(err) } groups = append(groups, response.groups()...) if response.NextPageToken == "" { break collect } count++ nextPageToken = response.NextPageToken } return jose.Claims{"groups": groups}, nil ...
c24241
for k, v := range b { _, ok := a[k] if !ok { a[k] = v } } return a, nil }
c24242
break } } if !acrValueMatched { log.Debugf("No OIDC ACR match found for '%v' in '%v'.", acrValue, tokenAcrValues) return trace.BadParameter("acr claim does not match") } default: log.Debugf("Validating OIDC ACR values with default rules.") claimValue, exists, err := claims.StringClaim("acr") ...
c24243
case <-doneC: // give it a couple of seconds to wrap up the goroutines, // set up the timer that will fire up if the all goroutines were not finished doneC = nil waitTime := time.Duration(result.Histogram.Max()) * time.Millisecond // going to wait latency + buffer to give requests in flight to wrap up...
c24244
*CloserConn { return &CloserConn{ Conn: conn, closers: closers, } }
c24245
tlsCert, err := tls.X509KeyPair(k.TLSCert, k.Priv) if err != nil { return nil, trace.Wrap(err, "failed to parse TLS cert and key") } tlsConfig.Certificates = append(tlsConfig.Certificates, tlsCert) return tlsConfig, nil }
c24246
trace.Wrap(err) } cert, ok := pubKey.(*ssh.Certificate) if !ok { return "", trace.BadParameter("expected SSH certificate, got public key") } return cert.KeyId, nil }
c24247
return nil, trace.BadParameter("no certificate found") } return cert.ValidPrincipals, nil }
c24248
bytes.Equal(k.Pub, other.Pub) && bytes.Equal(k.TLSCert, other.TLSCert) }
c24249
return t, trace.Wrap(err) } return cert.NotAfter, nil }
c24250
return t, trace.Errorf("not supported certificate type") } return time.Unix(int64(cert.ValidBefore), 0), nil }
c24251
ssh.NewCertSigner(keys[0].Certificate, signer); err != nil { return nil, trace.Wrap(err) } return NewAuthMethodForCert(signer), nil }
c24252
{ return trace.BadParameter("principals are required") } // A valid principal is always passed in because the principals are not being // checked here, but rather the validity period, signature, and algorithms. certChecker := utils.CertChecker{} err = certChecker.CheckCert(cert.ValidPrincipals[0], cert) if er...
c24253
} out = append(out, streamInfo.StreamDescription.Shards...) if streamInfo.StreamDescription.LastEvaluatedShardId == nil { return filterActiveShards(out), nil } input.ExclusiveStartShardId = streamInfo.StreamDescription.LastEvaluatedShardId } }
c24254
result, err := b.getAllRecords(ctx, startKey, endKey, limit) if err != nil { return nil, trace.Wrap(err) } sort.Sort(records(result.records)) values := make([]backend.Item, len(result.records)) for i, r := range result.records { values[i] = backend.Item{ Key: trimPrefix(r.FullPath), Value: r.Value, ...
c24255
time.Now().UTC().UnixNano(), } if !replaceWith.Expires.IsZero() { r.Expires = aws.Int64(replaceWith.Expires.UTC().Unix()) } av, err := dynamodbattribute.MarshalMap(r) if err != nil { return nil, trace.Wrap(err) } input := dynamodb.PutItemInput{ Item: av, TableName: aws.String(b.Tablename), }...
c24256
b.cancel() return b.buf.Close() }
c24257
return trace.Wrap( b.svc.WaitUntilTableNotExists(&dynamodb.DescribeTableInput{TableName: tn})) } return nil }
c24258
aws.Bool(true), ExclusiveStartKey: lastEvaluatedKey, } if limit > 0 { input.Limit = aws.Int64(int64(limit)) } out, err := b.svc.Query(&input) if err != nil { return nil, trace.Wrap(err) } var result getResult for _, item := range out.Items { var r record dynamodbattribute.Unmarshal...
c24259
ctx: ctx, cancel: cancel, events: make([]Event, size), start: -1, end: -1, size: 0, watchers: newWatcherTree(), } return buf, nil }
c24260
{ w.Close() }) c.watchers = newWatcherTree() c.start = -1 c.end = -1 c.size = 0 for i := 0; i < len(c.events); i++ { c.events[i] = Event{} } }
c24261
defer c.Unlock() return c.eventsCopy() }
c24262
nil { out = make([]Event, 0, c.size) } out = append(out, c.events[index]) } return out }
c24263
:= range events { c.push(events[i]) } }
c24264
defer c.Unlock() c.push(r) }
c24265
} else { // if watcher's prefixes are redundant, keep only shorter prefixes // to avoid double fan out watch.Prefixes = removeRedundantPrefixes(watch.Prefixes) } closeCtx, cancel := context.WithCancel(ctx) w := &BufferWatcher{ Watch: watch, eventsC: make(chan Event, watch.QueueSize), ctx: clos...
c24266
capacity=%v, size=%v)", w.Name, string(bytes.Join(w.Prefixes, []byte(", "))), w.capacity, len(w.eventsC)) }
c24267
var watchers []*BufferWatcher if ok { watchers = val.([]*BufferWatcher) } watchers = append(watchers, w) t.Tree.Insert(prefix, watchers) } }
c24268
true break } } if len(buffers) == 0 { t.Tree.Delete(prefix) } else if len(buffers) != prevLen { t.Tree.Insert(prefix, buffers) } } return found }
c24269
val.([]*BufferWatcher) for _, w := range watchers { fn(w) } return false }) }
c24270
for _, w := range watchers { fn(w) } return false }) }
c24271
tc.LocalAgent().GetKey() if err != nil { return trace.Wrap(err) } certAuthorities, err := tc.LocalAgent().GetCertsPEM() if err != nil { return trace.Wrap(err) } config.AuthInfos[clusterName] = &clientcmdapi.AuthInfo{ ClientCertificateData: creds.TLSCert, ClientKeyData: creds.Priv, } config.Clu...
c24272
delete(config.Clusters, clusterName) delete(config.Contexts, clusterName) // Take an element from the list of contexts and make it the current context. if len(config.Contexts) > 0 { var currentContext *clientcmdapi.Context for _, cc := range config.Contexts { currentContext = cc break } config.Curren...
c24273
!= nil && !os.IsNotExist(err) { return nil, trace.ConvertSystemError(err) } if config == nil { config = clientcmdapi.NewConfig() } return config, nil }
c24274
= clientcmd.WriteToFile(config, filename) if err != nil { return trace.ConvertSystemError(err) } return nil }
c24275
} // Default behavior of kubectl is to return the first file from list. var configpath string if len(parts) > 0 { configpath = parts[0] } log.Debugf("Found kubeconfig in environment at '%v'.", configpath) return configpath }
c24276
return trace.BadParameter("rotation period %v is not a multiple of 24 hours, e.g. '24h' or '48h'", cfg.RotationPeriod) } if cfg.Clock == nil { cfg.Clock = clockwork.NewRealClock() } if cfg.UIDGenerator == nil { cfg.UIDGenerator = utils.NewRealUID() } return nil }
c24277
trace.Wrap(err) } f := &FileLog{ FileLogConfig: cfg, Entry: log.WithFields(log.Fields{ trace.Component: teleport.ComponentAuditLog, }), } return f, nil }
c24278
the text to be logged line, err := json.Marshal(fields) if err != nil { return trace.Wrap(err) } // log it to the main log file: if l.file != nil { fmt.Fprintln(l.file, string(line)) } return nil }
c24279
var err error if l.file != nil { err = l.file.Close() l.file = nil } return err }
c24280
err != nil { log.Error(err) } l.fileTime = fileTime return trace.Wrap(err) } linkFilename := filepath.Join(l.SymlinkDir, SymlinkFilename) createSymlink := func() error { err = trace.ConvertSystemError(os.Remove(linkFilename)) if err != nil { if !trace.IsNotFound(err) { return trace.Wrap(err) ...
c24281
rotateLog can round up to the lowest // or the highest period. That's why this has to check both // periods. // Previous logic used modification time what was flaky // as it could be changed by migrations or simply moving files if fd.After(fromUTC.Add(-1*l.RotationPeriod)) && fd.Before(toUTC.Add(l.Rotat...
c24282
return time.Parse(defaults.AuditLogTimeFormat, base) }
c24283
time.Time{} } t, err := time.Parse(time.RFC3339, sval) if err != nil { return time.Time{} } return t }
c24284
return false } for key := range a { if a[key] != b[key] { return false } } return true }
c24285
return false } for key := range a { if !StringSlicesEqual(a[key], b[key]) { return false } } return true }
c24286
Name: name, Namespace: defaults.Namespace, }, Spec: spec, } }
c24287
err != nil { return nil, trace.BadParameter(err.Error()) } } if err := c.Metadata.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } if cfg.ID != 0 { c.SetResourceID(cfg.ID) } if !cfg.Expires.IsZero() { c.SetExpiry(cfg.Expires) } return &c, nil } return nil, trace.B...
c24288
if !cfg.PreserveResourceID { // avoid modifying the original object // to prevent unexpected data races copy := *v2 copy.SetResourceID(0) v2 = &copy } return utils.FastMarshal(v2) default: return nil, trace.BadParameter("version %v is not supported", version) } }
c24289
b := mappings[i], otherMappings[i] if a.Name != b.Name || a.Value != b.Value || !utils.StringSlicesEqual(a.Roles, b.Roles) { return false } if (a.RoleTemplate != nil && b.RoleTemplate == nil) || (a.RoleTemplate == nil && b.RoleTemplate != nil) { return false } if a.RoleTemplate != nil && !a.RoleTemplat...
c24290
append(out, mapping.Name) } return utils.Deduplicate(out) }
c24291
switch { case err != nil: if !trace.IsNotFound(err) { log.Debugf("Failed to match expression %v, replace with: %v input: %v, err: %v", mapping.Value, role, value.Value, err) } // if value input did not match, no need to apply // to all roles continue mappingLoop case...
c24292
:= range attributes { out = append(out, attr.Name) } return out }
c24293
Version: V2, Metadata: Metadata{ Name: name, }, } }
c24294
make([]MarshalOption, len(opts), len(opts)+len(add)) copy(out, opts) return append(opts, add...) }
c24295
error { c.ID = id return nil } }
c24296
{ c.Expires = expires return nil } }
c24297
default: return trace.BadParameter("version '%v' is not supported", v) } } }
c24298
ttl time.Duration) { h.Metadata.SetTTL(clock, ttl) }
c24299
} u.Raw = make([]byte, len(raw)) u.ResourceHeader = h copy(u.Raw, raw) return nil }