repo stringlengths 5 67 | sha stringlengths 40 40 | path stringlengths 4 234 | url stringlengths 85 339 | language stringclasses 6
values | split stringclasses 3
values | doc stringlengths 3 51.2k | sign stringlengths 5 8.01k | problem stringlengths 13 51.2k | output stringlengths 0 3.87M |
|---|---|---|---|---|---|---|---|---|---|
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L528-L535 | go | train | // deleteReverseTunnel deletes reverse tunnel | func (s *APIServer) deleteReverseTunnel(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // deleteReverseTunnel deletes reverse tunnel
func (s *APIServer) deleteReverseTunnel(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
domainName := p.ByName("domain")
err := auth.DeleteReverseTunnel(domainName)
if err != nil {
return nil, trace.Wrap(err)
}
return message(fmt.Sprintf("reverse tunnel %v deleted", domainName)), nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L601-L607 | go | train | // getTokens returns a list of active provisioning tokens. expired (inactive) tokens are not returned | func (s *APIServer) getTokens(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // getTokens returns a list of active provisioning tokens. expired (inactive) tokens are not returned
func (s *APIServer) getTokens(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
tokens, err := auth.GetTokens()
if err != nil {
return nil, trace.Wrap(err)
}
return services.ProvisionTokensToV1(tokens), nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L619-L625 | go | train | // deleteToken deletes (revokes) a token by its value | func (s *APIServer) deleteToken(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // deleteToken deletes (revokes) a token by its value
func (s *APIServer) deleteToken(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
token := p.ByName("token")
if err := auth.DeleteToken(token); err != nil {
return nil, trace.Wrap(err)
}
return message(fmt.Sprintf("Token %v deleted", token)), nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1075-L1082 | go | train | // getClusterCACert returns the CAs for the local cluster without signing keys. | func (s *APIServer) getClusterCACert(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // getClusterCACert returns the CAs for the local cluster without signing keys.
func (s *APIServer) getClusterCACert(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
localCA, err := auth.GetClusterCACert()
if err != nil {
return nil, trace.Wrap(err)
}
return localCA, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1085-L1098 | go | train | // getU2FAppID returns the U2F AppID in the auth configuration | func (s *APIServer) getU2FAppID(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // getU2FAppID returns the U2F AppID in the auth configuration
func (s *APIServer) getU2FAppID(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
cap, err := auth.GetAuthPreference()
if err != nil {
return nil, trace.Wrap(err)
}
universalSecondFactor, err := cap.GetU2F()
if err != nil {
return nil, trace.Wrap(err)
}
w.Header().Set("Content-Type", "application/fido.trusted-apps+json")
return universalSecondFactor.AppID, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1185-L1197 | go | train | // getSignupTokenData returns the signup data for a token. | func (s *APIServer) getSignupTokenData(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // getSignupTokenData returns the signup data for a token.
func (s *APIServer) getSignupTokenData(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
token := p.ByName("token")
user, otpQRCode, err := auth.GetSignupTokenData(token)
if err != nil {
return nil, trace.Wrap(err)
}
return &getSignupTokenDataResponse{
User: user,
QRImg: otpQRCode,
}, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1589-L1602 | go | train | /* createGithubConnector creates a new Github connector
POST /:version/github/connectors
Success response: {"message": "ok"}
*/ | func (s *APIServer) createGithubConnector(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | /* createGithubConnector creates a new Github connector
POST /:version/github/connectors
Success response: {"message": "ok"}
*/
func (s *APIServer) createGithubConnector(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
var req createGithubConnectorRawReq
if err := httplib.ReadJSON(r, &req); err != nil {
return nil, trace.Wrap(err)
}
connector, err := services.GetGithubConnectorMarshaler().Unmarshal(req.Connector)
if err != nil {
return nil, trace.Wrap(err)
}
if err := auth.CreateGithubConnector(connector); err != nil {
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1637-L1655 | go | train | /* getGithubConnectors returns a list of all configured Github connectors
GET /:version/github/connectors
Success response: []services.GithubConnector
*/ | func (s *APIServer) getGithubConnectors(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | /* getGithubConnectors returns a list of all configured Github connectors
GET /:version/github/connectors
Success response: []services.GithubConnector
*/
func (s *APIServer) getGithubConnectors(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
withSecrets, _, err := httplib.ParseBool(r.URL.Query(), "with_secrets")
if err != nil {
return nil, trace.Wrap(err)
}
connectors, err := auth.GetGithubConnectors(withSecrets)
if err != nil {
return nil, trace.Wrap(err)
}
items := make([]json.RawMessage, len(connectors))
for i, connector := range connecto... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1663-L1673 | go | train | /* getGithubConnector returns the specified Github connector
GET /:version/github/connectors/:id
Success response: services.GithubConnector
*/ | func (s *APIServer) getGithubConnector(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | /* getGithubConnector returns the specified Github connector
GET /:version/github/connectors/:id
Success response: services.GithubConnector
*/
func (s *APIServer) getGithubConnector(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
withSecrets, _, err := httplib.ParseBool(r.URL.Query(), "with_secrets")
if err != nil {
return nil, trace.Wrap(err)
}
connector, err := auth.GetGithubConnector(p.ByName("id"), withSecrets)
if err != nil {
return nil, trace.Wrap(err)
}
return rawMessage(services.GetGithubConnectorMarshaler().Marshal(connec... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1681-L1686 | go | train | /* deleteGithubConnector deletes the specified Github connector
DELETE /:version/github/connectors/:id
Success response: {"message": "ok"}
*/ | func (s *APIServer) deleteGithubConnector(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | /* deleteGithubConnector deletes the specified Github connector
DELETE /:version/github/connectors/:id
Success response: {"message": "ok"}
*/
func (s *APIServer) deleteGithubConnector(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
if err := auth.DeleteGithubConnector(p.ByName("id")); err != nil {
return nil, trace.Wrap(err)
}
return message("ok"), nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1700-L1710 | go | train | /* createGithubAuthRequest creates a new request for Github OAuth2 flow
POST /:version/github/requests/create
Success response: services.GithubAuthRequest
*/ | func (s *APIServer) createGithubAuthRequest(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | /* createGithubAuthRequest creates a new request for Github OAuth2 flow
POST /:version/github/requests/create
Success response: services.GithubAuthRequest
*/
func (s *APIServer) createGithubAuthRequest(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error... | {
var req createGithubAuthRequestReq
if err := httplib.ReadJSON(r, &req); err != nil {
return nil, trace.Wrap(err)
}
response, err := auth.CreateGithubAuthRequest(req.Req)
if err != nil {
return nil, trace.Wrap(err)
}
return response, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1744-L1778 | go | train | /* validateGithubAuthRequest validates Github auth callback redirect
POST /:version/github/requests/validate
Success response: githubAuthRawResponse
*/ | func (s *APIServer) validateGithubAuthCallback(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | /* validateGithubAuthRequest validates Github auth callback redirect
POST /:version/github/requests/validate
Success response: githubAuthRawResponse
*/
func (s *APIServer) validateGithubAuthCallback(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
var req validateGithubAuthCallbackReq
if err := httplib.ReadJSON(r, &req); err != nil {
return nil, trace.Wrap(err)
}
response, err := auth.ValidateGithubAuthCallback(req.Query)
if err != nil {
return nil, trace.Wrap(err)
}
raw := githubAuthRawResponse{
Username: response.Username,
Identity: response.... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1786-L1824 | go | train | // HTTP GET /:version/events?query
//
// Query fields:
// 'from' : time filter in RFC3339 format
// 'to' : time filter in RFC3339 format
// ... : other fields are passed directly to the audit backend | func (s *APIServer) searchEvents(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // HTTP GET /:version/events?query
//
// Query fields:
// 'from' : time filter in RFC3339 format
// 'to' : time filter in RFC3339 format
// ... : other fields are passed directly to the audit backend
func (s *APIServer) searchEvents(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, ver... | {
var err error
to := time.Now().In(time.UTC)
from := to.AddDate(0, -1, 0) // one month ago
query := r.URL.Query()
// parse 'to' and 'from' params:
fromStr := query.Get("from")
if fromStr != "" {
from, err = time.Parse(time.RFC3339, fromStr)
if err != nil {
return nil, trace.BadParameter("from")
}
}
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1879-L1896 | go | train | // HTTP POST /:version/events | func (s *APIServer) emitAuditEvent(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // HTTP POST /:version/events
func (s *APIServer) emitAuditEvent(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
var req auditEventReq
err := httplib.ReadJSON(r, &req)
if err != nil {
return nil, trace.Wrap(err)
}
// For backwards compatibility, check if the full event struct has
// been sent in the request or just the event type.
if req.Event.Name != "" {
err = auth.EmitAuditEvent(req.Event, req.Fields)
} else {
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1899-L1912 | go | train | // HTTP POST /:version/sessions/:id/slice | func (s *APIServer) postSessionSlice(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // HTTP POST /:version/sessions/:id/slice
func (s *APIServer) postSessionSlice(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
data, err := ioutil.ReadAll(r.Body)
if err != nil {
return nil, trace.Wrap(err)
}
var slice events.SessionSlice
if err := slice.Unmarshal(data); err != nil {
return nil, trace.BadParameter("failed to unmarshal %v", err)
}
if err := auth.PostSessionSlice(slice); err != nil {
return nil, trace.Wrap(err)
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1915-L1945 | go | train | // HTTP POST /:version/sessions/:id/recording | func (s *APIServer) uploadSessionRecording(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // HTTP POST /:version/sessions/:id/recording
func (s *APIServer) uploadSessionRecording(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
var files form.Files
var namespace, sid string
err := form.Parse(r,
form.FileSlice("recording", &files),
form.String("namespace", &namespace, form.Required()),
form.String("sid", &sid, form.Required()),
)
if err != nil {
return nil, trace.Wrap(err)
}
if r.MultipartForm != nil {
defer r.MultipartFor... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1951-L1983 | go | train | // HTTP GET /:version/sessions/:id/stream?offset=x&bytes=y
// Query parameters:
// "offset" : bytes from the beginning
// "bytes" : number of bytes to read (it won't return more than 512Kb) | func (s *APIServer) getSessionChunk(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // HTTP GET /:version/sessions/:id/stream?offset=x&bytes=y
// Query parameters:
// "offset" : bytes from the beginning
// "bytes" : number of bytes to read (it won't return more than 512Kb)
func (s *APIServer) getSessionChunk(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version st... | {
sid, err := session.ParseID(p.ByName("id"))
if err != nil {
return nil, trace.BadParameter("missing parameter id")
}
namespace := p.ByName("namespace")
if !services.IsValidNamespace(namespace) {
return nil, trace.BadParameter("invalid namespace %q", namespace)
}
// "offset bytes" query param
offsetBytes... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L1988-L2007 | go | train | // HTTP GET /:version/sessions/:id/events?maxage=n
// Query:
// 'after' : cursor value to return events newer than N. Defaults to 0, (return all) | func (s *APIServer) getSessionEvents(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // HTTP GET /:version/sessions/:id/events?maxage=n
// Query:
// 'after' : cursor value to return events newer than N. Defaults to 0, (return all)
func (s *APIServer) getSessionEvents(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
sid, err := session.ParseID(p.ByName("id"))
if err != nil {
return nil, trace.Wrap(err)
}
namespace := p.ByName("namespace")
if !services.IsValidNamespace(namespace) {
return nil, trace.BadParameter("invalid namespace %q", namespace)
}
afterN, err := strconv.Atoi(r.URL.Query().Get("after"))
if err != nil... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L2259-L2272 | go | train | // upsertTunnelConnection updates or inserts tunnel connection | func (s *APIServer) upsertTunnelConnection(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // upsertTunnelConnection updates or inserts tunnel connection
func (s *APIServer) upsertTunnelConnection(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
var req upsertTunnelConnectionRawReq
if err := httplib.ReadJSON(r, &req); err != nil {
return nil, trace.Wrap(err)
}
conn, err := services.UnmarshalTunnelConnection(req.TunnelConnection)
if err != nil {
return nil, trace.Wrap(err)
}
if err := auth.UpsertTunnelConnection(conn); err != nil {
return nil, t... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L2275-L2289 | go | train | // getTunnelConnections returns a list of tunnel connections from a cluster | func (s *APIServer) getTunnelConnections(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // getTunnelConnections returns a list of tunnel connections from a cluster
func (s *APIServer) getTunnelConnections(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
conns, err := auth.GetTunnelConnections(p.ByName("cluster"))
if err != nil {
return nil, trace.Wrap(err)
}
items := make([]json.RawMessage, len(conns))
for i, conn := range conns {
data, err := services.MarshalTunnelConnection(conn, services.WithVersion(version), services.PreserveResourceID())
if err != n... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L2341-L2354 | go | train | // createRemoteCluster creates remote cluster | func (s *APIServer) createRemoteCluster(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // createRemoteCluster creates remote cluster
func (s *APIServer) createRemoteCluster(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
var req createRemoteClusterRawReq
if err := httplib.ReadJSON(r, &req); err != nil {
return nil, trace.Wrap(err)
}
conn, err := services.UnmarshalRemoteCluster(req.RemoteCluster)
if err != nil {
return nil, trace.Wrap(err)
}
if err := auth.CreateRemoteCluster(conn); err != nil {
return nil, trace.Wrap(er... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L2357-L2371 | go | train | // getRemoteClusters returns a list of remote clusters | func (s *APIServer) getRemoteClusters(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // getRemoteClusters returns a list of remote clusters
func (s *APIServer) getRemoteClusters(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
clusters, err := auth.GetRemoteClusters()
if err != nil {
return nil, trace.Wrap(err)
}
items := make([]json.RawMessage, len(clusters))
for i, cluster := range clusters {
data, err := services.MarshalRemoteCluster(cluster, services.WithVersion(version), services.PreserveResourceID())
if err != nil {
re... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/apiserver.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/apiserver.go#L2374-L2380 | go | train | // getRemoteCluster returns a remote cluster by name | func (s *APIServer) getRemoteCluster(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | // getRemoteCluster returns a remote cluster by name
func (s *APIServer) getRemoteCluster(auth ClientI, w http.ResponseWriter, r *http.Request, p httprouter.Params, version string) (interface{}, error) | {
cluster, err := auth.GetRemoteCluster(p.ByName("cluster"))
if err != nil {
return nil, trace.Wrap(err)
}
return rawMessage(services.MarshalRemoteCluster(cluster, services.WithVersion(version), services.PreserveResourceID()))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/saml.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/saml.go#L98-L105 | go | train | // buildSAMLRoles takes a connector and claims and returns a slice of roles. | func (a *AuthServer) buildSAMLRoles(connector services.SAMLConnector, assertionInfo saml2.AssertionInfo) ([]string, error) | // buildSAMLRoles takes a connector and claims and returns a slice of roles.
func (a *AuthServer) buildSAMLRoles(connector services.SAMLConnector, assertionInfo saml2.AssertionInfo) ([]string, error) | {
roles := connector.MapAttributes(assertionInfo)
if len(roles) == 0 {
return nil, trace.AccessDenied("unable to map attributes to role for connector: %v", connector.GetName())
}
return roles, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/saml.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/saml.go#L109-L121 | go | train | // assertionsToTraitMap extracts all string assertions and creates a map of traits
// that can be used to populate role variables. | func assertionsToTraitMap(assertionInfo saml2.AssertionInfo) map[string][]string | // assertionsToTraitMap extracts all string assertions and creates a map of traits
// that can be used to populate role variables.
func assertionsToTraitMap(assertionInfo saml2.AssertionInfo) map[string][]string | {
traits := make(map[string][]string)
for _, assr := range assertionInfo.Values {
var vals []string
for _, value := range assr.Values {
vals = append(vals, value.Value)
}
traits[assr.Name] = vals
}
return traits
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/saml.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/saml.go#L278-L294 | go | train | // ValidateSAMLResponse consumes attribute statements from SAML identity provider | func (a *AuthServer) ValidateSAMLResponse(samlResponse string) (*SAMLAuthResponse, error) | // ValidateSAMLResponse consumes attribute statements from SAML identity provider
func (a *AuthServer) ValidateSAMLResponse(samlResponse string) (*SAMLAuthResponse, error) | {
re, err := a.validateSAMLResponse(samlResponse)
if err != nil {
a.EmitAuditEvent(events.UserSSOLoginFailure, events.EventFields{
events.LoginMethod: events.LoginMethodSAML,
events.AuthAttemptSuccess: false,
events.AuthAttemptErr: err.Error(),
})
} else {
a.EmitAuditEvent(events.UserSSOLo... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L37-L54 | go | train | // ForAuth sets up watch configuration for the auth server | func ForAuth(cfg Config) Config | // ForAuth sets up watch configuration for the auth server
func ForAuth(cfg Config) Config | {
cfg.Watches = []services.WatchKind{
{Kind: services.KindCertAuthority, LoadSecrets: true},
{Kind: services.KindClusterName},
{Kind: services.KindClusterConfig},
{Kind: services.KindStaticTokens},
{Kind: services.KindToken},
{Kind: services.KindUser},
{Kind: services.KindRole},
{Kind: services.KindNa... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L57-L73 | go | train | // ForProxy sets up watch configuration for proxy | func ForProxy(cfg Config) Config | // ForProxy sets up watch configuration for proxy
func ForProxy(cfg Config) Config | {
cfg.Watches = []services.WatchKind{
{Kind: services.KindCertAuthority, LoadSecrets: false},
{Kind: services.KindClusterName},
{Kind: services.KindClusterConfig},
{Kind: services.KindUser},
{Kind: services.KindRole},
{Kind: services.KindNamespace},
{Kind: services.KindNode},
{Kind: services.KindProxy... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L76-L90 | go | train | // ForNode sets up watch configuration for node | func ForNode(cfg Config) Config | // ForNode sets up watch configuration for node
func ForNode(cfg Config) Config | {
cfg.Watches = []services.WatchKind{
{Kind: services.KindCertAuthority, LoadSecrets: false},
{Kind: services.KindClusterName},
{Kind: services.KindClusterConfig},
{Kind: services.KindUser},
{Kind: services.KindRole},
// Node only needs to "know" about default
// namespace events to avoid matching too m... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L200-L205 | go | train | // CheckAndSetDefaults checks parameters and sets default values | func (p *PreferRecent) CheckAndSetDefaults() error | // CheckAndSetDefaults checks parameters and sets default values
func (p *PreferRecent) CheckAndSetDefaults() error | {
if p.MaxTTL == 0 {
p.MaxTTL = defaults.CacheTTL
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L208-L240 | go | train | // CheckAndSetDefaults checks parameters and sets default values | func (c *Config) CheckAndSetDefaults() error | // CheckAndSetDefaults checks parameters and sets default values
func (c *Config) CheckAndSetDefaults() error | {
if c.Events == nil {
return trace.BadParameter("missing Events parameter")
}
if c.Backend == nil {
return trace.BadParameter("missing Backend parameter")
}
if c.OnlyRecent.Enabled && c.PreferRecent.Enabled {
return trace.BadParameter("either one of OnlyRecent or PreferRecent should be enabled at a time")
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L261-L300 | go | train | // New creates a new instance of Cache | func New(config Config) (*Cache, error) | // New creates a new instance of Cache
func New(config Config) (*Cache, error) | {
if err := config.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
wrapper := backend.NewWrapper(config.Backend)
ctx, cancel := context.WithCancel(config.Context)
cs := &Cache{
wrapper: wrapper,
ctx: ctx,
cancel: cancel,
Config: config,... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L307-L309 | go | train | // NewWatcher returns a new event watcher. In case of a cache
// this watcher will return events as seen by the cache,
// not the backend. This feature allows auth server
// to handle subscribers connected to the in-memory caches
// instead of reading from the backend. | func (c *Cache) NewWatcher(ctx context.Context, watch services.Watch) (services.Watcher, error) | // NewWatcher returns a new event watcher. In case of a cache
// this watcher will return events as seen by the cache,
// not the backend. This feature allows auth server
// to handle subscribers connected to the in-memory caches
// instead of reading from the backend.
func (c *Cache) NewWatcher(ctx context.Context, wa... | {
return c.eventsCache.NewWatcher(ctx, watch)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L358-L369 | go | train | // setCacheState for "only recent" cache behavior will erase
// the cache and set error mode to refuse to serve stale data,
// otherwise does nothing | func (c *Cache) setCacheState(err error) error | // setCacheState for "only recent" cache behavior will erase
// the cache and set error mode to refuse to serve stale data,
// otherwise does nothing
func (c *Cache) setCacheState(err error) error | {
if !c.OnlyRecent.Enabled {
return err
}
if err := c.eraseAll(); err != nil {
if !c.isClosed() {
c.Warningf("Failed to erase the data: %v.", err)
}
}
c.wrapper.SetReadError(trace.ConnectionProblem(err, "cache is unavailable"))
return err
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L376-L386 | go | train | // setTTL overrides TTL supplied by the resource
// based on the cache behavior:
// - for "only recent", does nothing
// - for "prefer recent", honors TTL set on the resource, otherwise
// sets TTL to max TTL | func (c *Cache) setTTL(r services.Resource) | // setTTL overrides TTL supplied by the resource
// based on the cache behavior:
// - for "only recent", does nothing
// - for "prefer recent", honors TTL set on the resource, otherwise
// sets TTL to max TTL
func (c *Cache) setTTL(r services.Resource) | {
if c.OnlyRecent.Enabled || (c.PreferRecent.Enabled && c.PreferRecent.NeverExpires) {
return
}
// honor expiry set in the resource
if !r.Expiry().IsZero() {
return
}
// set max TTL on the resources
r.SetTTL(c.Clock, c.PreferRecent.MaxTTL)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L435-L498 | go | train | // fetchAndWatch keeps cache up to date by replaying
// events and syncing local cache storage.
//
// Here are some thoughts on consistency in face of errors:
//
// 1. Every client is connected to the database fan-out
// system. This system creates a buffered channel for every
// client and tracks the channel overflow.... | func (c *Cache) fetchAndWatch(retry utils.Retry, reloadC <-chan time.Time) error | // fetchAndWatch keeps cache up to date by replaying
// events and syncing local cache storage.
//
// Here are some thoughts on consistency in face of errors:
//
// 1. Every client is connected to the database fan-out
// system. This system creates a buffered channel for every
// client and tracks the channel overflow.... | {
watcher, err := c.Events.NewWatcher(c.ctx, services.Watch{
QueueSize: c.QueueSize,
Name: c.Component,
Kinds: c.watchKinds(),
MetricComponent: c.MetricComponent,
})
if err != nil {
c.notify(CacheEvent{Type: WatcherFailed})
return trace.Wrap(err)
}
defer watcher.Close()
// ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L501-L507 | go | train | // eraseAll erases all the data from cache collections | func (c *Cache) eraseAll() error | // eraseAll erases all the data from cache collections
func (c *Cache) eraseAll() error | {
var errors []error
for _, collection := range c.collections {
errors = append(errors, collection.erase())
}
return trace.NewAggregate(errors...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L544-L546 | go | train | // GetCertAuthority returns certificate authority by given id. Parameter loadSigningKeys
// controls if signing keys are loaded | func (c *Cache) GetCertAuthority(id services.CertAuthID, loadSigningKeys bool, opts ...services.MarshalOption) (services.CertAuthority, error) | // GetCertAuthority returns certificate authority by given id. Parameter loadSigningKeys
// controls if signing keys are loaded
func (c *Cache) GetCertAuthority(id services.CertAuthID, loadSigningKeys bool, opts ...services.MarshalOption) (services.CertAuthority, error) | {
return c.trustCache.GetCertAuthority(id, loadSigningKeys, services.AddOptions(opts, services.SkipValidation())...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L550-L552 | go | train | // GetCertAuthorities returns a list of authorities of a given type
// loadSigningKeys controls whether signing keys should be loaded or not | func (c *Cache) GetCertAuthorities(caType services.CertAuthType, loadSigningKeys bool, opts ...services.MarshalOption) ([]services.CertAuthority, error) | // GetCertAuthorities returns a list of authorities of a given type
// loadSigningKeys controls whether signing keys should be loaded or not
func (c *Cache) GetCertAuthorities(caType services.CertAuthType, loadSigningKeys bool, opts ...services.MarshalOption) ([]services.CertAuthority, error) | {
return c.trustCache.GetCertAuthorities(caType, loadSigningKeys, services.AddOptions(opts, services.SkipValidation())...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L560-L562 | go | train | // GetTokens returns all active (non-expired) provisioning tokens | func (c *Cache) GetTokens(opts ...services.MarshalOption) ([]services.ProvisionToken, error) | // GetTokens returns all active (non-expired) provisioning tokens
func (c *Cache) GetTokens(opts ...services.MarshalOption) ([]services.ProvisionToken, error) | {
return c.provisionerCache.GetTokens(services.AddOptions(opts, services.SkipValidation())...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L565-L567 | go | train | // GetToken finds and returns token by ID | func (c *Cache) GetToken(token string) (services.ProvisionToken, error) | // GetToken finds and returns token by ID
func (c *Cache) GetToken(token string) (services.ProvisionToken, error) | {
return c.provisionerCache.GetToken(token)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L570-L576 | go | train | // GetClusterConfig gets services.ClusterConfig from the backend. | func (c *Cache) GetClusterConfig(opts ...services.MarshalOption) (services.ClusterConfig, error) | // GetClusterConfig gets services.ClusterConfig from the backend.
func (c *Cache) GetClusterConfig(opts ...services.MarshalOption) (services.ClusterConfig, error) | {
config, err := c.clusterConfigCache.GetClusterConfig(services.AddOptions(opts, services.SkipValidation())...)
if trace.IsNotFound(err) {
return c.ClusterConfig.GetClusterConfig(opts...)
}
return config, err
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L579-L585 | go | train | // GetClusterName gets the name of the cluster from the backend. | func (c *Cache) GetClusterName(opts ...services.MarshalOption) (services.ClusterName, error) | // GetClusterName gets the name of the cluster from the backend.
func (c *Cache) GetClusterName(opts ...services.MarshalOption) (services.ClusterName, error) | {
clusterName, err := c.clusterConfigCache.GetClusterName(services.AddOptions(opts, services.SkipValidation())...)
if trace.IsNotFound(err) {
return c.ClusterConfig.GetClusterName(opts...)
}
return clusterName, err
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L593-L599 | go | train | // GetRole is a part of auth.AccessPoint implementation | func (c *Cache) GetRole(name string) (services.Role, error) | // GetRole is a part of auth.AccessPoint implementation
func (c *Cache) GetRole(name string) (services.Role, error) | {
role, err := c.accessCache.GetRole(name)
if trace.IsNotFound(err) {
return c.Access.GetRole(name)
}
return role, err
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L602-L604 | go | train | // GetNamespace returns namespace | func (c *Cache) GetNamespace(name string) (*services.Namespace, error) | // GetNamespace returns namespace
func (c *Cache) GetNamespace(name string) (*services.Namespace, error) | {
return c.presenceCache.GetNamespace(name)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L612-L614 | go | train | // GetNodes is a part of auth.AccessPoint implementation | func (c *Cache) GetNodes(namespace string, opts ...services.MarshalOption) ([]services.Server, error) | // GetNodes is a part of auth.AccessPoint implementation
func (c *Cache) GetNodes(namespace string, opts ...services.MarshalOption) ([]services.Server, error) | {
return c.presenceCache.GetNodes(namespace, opts...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L622-L624 | go | train | // GetReverseTunnels is a part of auth.AccessPoint implementation | func (c *Cache) GetReverseTunnels(opts ...services.MarshalOption) ([]services.ReverseTunnel, error) | // GetReverseTunnels is a part of auth.AccessPoint implementation
func (c *Cache) GetReverseTunnels(opts ...services.MarshalOption) ([]services.ReverseTunnel, error) | {
return c.presenceCache.GetReverseTunnels(services.AddOptions(opts, services.SkipValidation())...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L632-L638 | go | train | // GetUser is a part of auth.AccessPoint implementation. | func (c *Cache) GetUser(name string) (user services.User, err error) | // GetUser is a part of auth.AccessPoint implementation.
func (c *Cache) GetUser(name string) (user services.User, err error) | {
u, err := c.usersCache.GetUser(name)
if trace.IsNotFound(err) {
return c.Users.GetUser(name)
}
return u, err
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L641-L643 | go | train | // GetUsers is a part of auth.AccessPoint implementation | func (c *Cache) GetUsers() (users []services.User, err error) | // GetUsers is a part of auth.AccessPoint implementation
func (c *Cache) GetUsers() (users []services.User, err error) | {
return c.usersCache.GetUsers()
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L648-L650 | go | train | // GetTunnelConnections is a part of auth.AccessPoint implementation
// GetTunnelConnections are not using recent cache as they are designed
// to be called periodically and always return fresh data | func (c *Cache) GetTunnelConnections(clusterName string, opts ...services.MarshalOption) ([]services.TunnelConnection, error) | // GetTunnelConnections is a part of auth.AccessPoint implementation
// GetTunnelConnections are not using recent cache as they are designed
// to be called periodically and always return fresh data
func (c *Cache) GetTunnelConnections(clusterName string, opts ...services.MarshalOption) ([]services.TunnelConnection, er... | {
return c.presenceCache.GetTunnelConnections(clusterName, opts...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/cache/cache.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/cache/cache.go#L655-L657 | go | train | // GetAllTunnelConnections is a part of auth.AccessPoint implementation
// GetAllTunnelConnections are not using recent cache, as they are designed
// to be called periodically and always return fresh data | func (c *Cache) GetAllTunnelConnections(opts ...services.MarshalOption) (conns []services.TunnelConnection, err error) | // GetAllTunnelConnections is a part of auth.AccessPoint implementation
// GetAllTunnelConnections are not using recent cache, as they are designed
// to be called periodically and always return fresh data
func (c *Cache) GetAllTunnelConnections(opts ...services.MarshalOption) (conns []services.TunnelConnection, err er... | {
return c.presenceCache.GetAllTunnelConnections(opts...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/reversetunnel/localsite.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/localsite.go#L244-L252 | go | train | // findMatchingConn iterates over passed in principals looking for matching
// remote connections. | func (s *localSite) findMatchingConn(principals []string) (*remoteConn, bool) | // findMatchingConn iterates over passed in principals looking for matching
// remote connections.
func (s *localSite) findMatchingConn(principals []string) (*remoteConn, bool) | {
for _, principal := range principals {
rconn, err := s.getConn(principal)
if err == nil {
return rconn, true
}
}
return nil, false
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | examples/go-client/main.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/examples/go-client/main.go#L64-L77 | go | train | // setupClientTLS sets up client TLS authentiction between TLS client
// and Teleport Auth server. This function uses hardcoded certificate paths,
// assuming program runs alongside auth server, but it can be ran
// on a remote location, assuming client has all the client certificates. | func setupClientTLS() (*tls.Config, error) | // setupClientTLS sets up client TLS authentiction between TLS client
// and Teleport Auth server. This function uses hardcoded certificate paths,
// assuming program runs alongside auth server, but it can be ran
// on a remote location, assuming client has all the client certificates.
func setupClientTLS() (*tls.Confi... | {
storage, err := auth.NewProcessStorage(filepath.Join("/var/lib/teleport", teleport.ComponentProcess))
if err != nil {
return nil, trace.Wrap(err)
}
defer storage.Close()
identity, err := storage.ReadIdentity(auth.IdentityCurrent, teleport.RoleAdmin)
if err != nil {
return nil, trace.Wrap(err)
}
return ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L41-L46 | go | train | // NewPresenceService returns new presence service instance | func NewPresenceService(b backend.Backend) *PresenceService | // NewPresenceService returns new presence service instance
func NewPresenceService(b backend.Backend) *PresenceService | {
return &PresenceService{
log: logrus.WithFields(logrus.Fields{trace.Component: "Presence"}),
Backend: b,
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L53-L59 | go | train | // UpsertLocalClusterName upserts local cluster name | func (s *PresenceService) UpsertLocalClusterName(name string) error | // UpsertLocalClusterName upserts local cluster name
func (s *PresenceService) UpsertLocalClusterName(name string) error | {
_, err := s.Put(context.TODO(), backend.Item{
Key: backend.Key(localClusterPrefix, valPrefix),
Value: []byte(name),
})
return trace.Wrap(err)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L62-L68 | go | train | // GetLocalClusterName upserts local domain | func (s *PresenceService) GetLocalClusterName() (string, error) | // GetLocalClusterName upserts local domain
func (s *PresenceService) GetLocalClusterName() (string, error) | {
item, err := s.Get(context.TODO(), backend.Key(localClusterPrefix, valPrefix))
if err != nil {
return "", trace.Wrap(err)
}
return string(item.Value), nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L71-L73 | go | train | // DeleteAllNamespaces deletes all namespaces | func (s *PresenceService) DeleteAllNamespaces() error | // DeleteAllNamespaces deletes all namespaces
func (s *PresenceService) DeleteAllNamespaces() error | {
return s.DeleteRange(context.TODO(), backend.Key(namespacesPrefix), backend.RangeEnd(backend.Key(namespacesPrefix)))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L76-L95 | go | train | // GetNamespaces returns a list of namespaces | func (s *PresenceService) GetNamespaces() ([]services.Namespace, error) | // GetNamespaces returns a list of namespaces
func (s *PresenceService) GetNamespaces() ([]services.Namespace, error) | {
result, err := s.GetRange(context.TODO(), backend.Key(namespacesPrefix), backend.RangeEnd(backend.Key(namespacesPrefix)), backend.NoLimit)
if err != nil {
return nil, trace.Wrap(err)
}
out := make([]services.Namespace, 0, len(result.Items))
for _, item := range result.Items {
if !bytes.HasSuffix(item.Key, [... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L98-L118 | go | train | // UpsertNamespace upserts namespace | func (s *PresenceService) UpsertNamespace(n services.Namespace) error | // UpsertNamespace upserts namespace
func (s *PresenceService) UpsertNamespace(n services.Namespace) error | {
if err := n.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err)
}
value, err := services.MarshalNamespace(n)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(namespacesPrefix, n.Metadata.Name, paramsPrefix),
Value: value,
Expires: n.Metadata.Expiry(),
ID:... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L121-L134 | go | train | // GetNamespace returns a namespace by name | func (s *PresenceService) GetNamespace(name string) (*services.Namespace, error) | // GetNamespace returns a namespace by name
func (s *PresenceService) GetNamespace(name string) (*services.Namespace, error) | {
if name == "" {
return nil, trace.BadParameter("missing namespace name")
}
item, err := s.Get(context.TODO(), backend.Key(namespacesPrefix, name, paramsPrefix))
if err != nil {
if trace.IsNotFound(err) {
return nil, trace.NotFound("namespace %q is not found", name)
}
return nil, trace.Wrap(err)
}
re... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L137-L148 | go | train | // DeleteNamespace deletes a namespace with all the keys from the backend | func (s *PresenceService) DeleteNamespace(namespace string) error | // DeleteNamespace deletes a namespace with all the keys from the backend
func (s *PresenceService) DeleteNamespace(namespace string) error | {
if namespace == "" {
return trace.BadParameter("missing namespace name")
}
err := s.Delete(context.TODO(), backend.Key(namespacesPrefix, namespace, paramsPrefix))
if err != nil {
if trace.IsNotFound(err) {
return trace.NotFound("namespace %q is not found", namespace)
}
}
return trace.Wrap(err)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L188-L191 | go | train | // DeleteAllNodes deletes all nodes in a namespace | func (s *PresenceService) DeleteAllNodes(namespace string) error | // DeleteAllNodes deletes all nodes in a namespace
func (s *PresenceService) DeleteAllNodes(namespace string) error | {
startKey := backend.Key(nodesPrefix, namespace)
return s.DeleteRange(context.TODO(), startKey, backend.RangeEnd(startKey))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L194-L197 | go | train | // DeleteNode deletes node | func (s *PresenceService) DeleteNode(namespace string, name string) error | // DeleteNode deletes node
func (s *PresenceService) DeleteNode(namespace string, name string) error | {
key := backend.Key(nodesPrefix, namespace, name)
return s.Delete(context.TODO(), key)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L200-L227 | go | train | // GetNodes returns a list of registered servers | func (s *PresenceService) GetNodes(namespace string, opts ...services.MarshalOption) ([]services.Server, error) | // GetNodes returns a list of registered servers
func (s *PresenceService) GetNodes(namespace string, opts ...services.MarshalOption) ([]services.Server, error) | {
if namespace == "" {
return nil, trace.BadParameter("missing namespace value")
}
// Get all items in the bucket.
startKey := backend.Key(nodesPrefix, namespace)
result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit)
if err != nil {
return nil, trace.Wrap(err)
}
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L231-L252 | go | train | // UpsertNode registers node presence, permanently if TTL is 0 or for the
// specified duration with second resolution if it's >= 1 second. | func (s *PresenceService) UpsertNode(server services.Server) (*services.KeepAlive, error) | // UpsertNode registers node presence, permanently if TTL is 0 or for the
// specified duration with second resolution if it's >= 1 second.
func (s *PresenceService) UpsertNode(server services.Server) (*services.KeepAlive, error) | {
if server.GetNamespace() == "" {
return nil, trace.BadParameter("missing node namespace")
}
value, err := services.GetServerMarshaler().MarshalServer(server)
if err != nil {
return nil, trace.Wrap(err)
}
lease, err := s.Put(context.TODO(), backend.Item{
Key: backend.Key(nodesPrefix, server.GetNamespa... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L255-L264 | go | train | // KeepAliveNode updates node expiry | func (s *PresenceService) KeepAliveNode(ctx context.Context, h services.KeepAlive) error | // KeepAliveNode updates node expiry
func (s *PresenceService) KeepAliveNode(ctx context.Context, h services.KeepAlive) error | {
if err := h.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err)
}
err := s.KeepAlive(ctx, backend.Lease{
ID: h.LeaseID,
Key: backend.Key(nodesPrefix, h.Namespace, h.ServerName),
}, h.Expires)
return trace.Wrap(err)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L268-L302 | go | train | // UpsertNodes is used for bulk insertion of nodes. Schema validation is
// always skipped during bulk insertion. | func (s *PresenceService) UpsertNodes(namespace string, servers []services.Server) error | // UpsertNodes is used for bulk insertion of nodes. Schema validation is
// always skipped during bulk insertion.
func (s *PresenceService) UpsertNodes(namespace string, servers []services.Server) error | {
batch, ok := s.Backend.(backend.Batch)
if !ok {
return trace.BadParameter("backend does not support batch interface")
}
if namespace == "" {
return trace.BadParameter("missing node namespace")
}
start := time.Now()
items := make([]backend.Item, len(servers))
for i, server := range servers {
value, er... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L305-L307 | go | train | // GetAuthServers returns a list of registered servers | func (s *PresenceService) GetAuthServers() ([]services.Server, error) | // GetAuthServers returns a list of registered servers
func (s *PresenceService) GetAuthServers() ([]services.Server, error) | {
return s.getServers(services.KindAuthServer, authServersPrefix)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L311-L313 | go | train | // UpsertAuthServer registers auth server presence, permanently if ttl is 0 or
// for the specified duration with second resolution if it's >= 1 second | func (s *PresenceService) UpsertAuthServer(server services.Server) error | // UpsertAuthServer registers auth server presence, permanently if ttl is 0 or
// for the specified duration with second resolution if it's >= 1 second
func (s *PresenceService) UpsertAuthServer(server services.Server) error | {
return s.upsertServer(authServersPrefix, server)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L316-L319 | go | train | // DeleteAllAuthServers deletes all auth servers | func (s *PresenceService) DeleteAllAuthServers() error | // DeleteAllAuthServers deletes all auth servers
func (s *PresenceService) DeleteAllAuthServers() error | {
startKey := backend.Key(authServersPrefix)
return s.DeleteRange(context.TODO(), startKey, backend.RangeEnd(startKey))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L322-L325 | go | train | // DeleteAuthServer deletes auth server by name | func (s *PresenceService) DeleteAuthServer(name string) error | // DeleteAuthServer deletes auth server by name
func (s *PresenceService) DeleteAuthServer(name string) error | {
key := backend.Key(authServersPrefix, name)
return s.Delete(context.TODO(), key)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L329-L331 | go | train | // UpsertProxy registers proxy server presence, permanently if ttl is 0 or
// for the specified duration with second resolution if it's >= 1 second | func (s *PresenceService) UpsertProxy(server services.Server) error | // UpsertProxy registers proxy server presence, permanently if ttl is 0 or
// for the specified duration with second resolution if it's >= 1 second
func (s *PresenceService) UpsertProxy(server services.Server) error | {
return s.upsertServer(proxiesPrefix, server)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L334-L336 | go | train | // GetProxies returns a list of registered proxies | func (s *PresenceService) GetProxies() ([]services.Server, error) | // GetProxies returns a list of registered proxies
func (s *PresenceService) GetProxies() ([]services.Server, error) | {
return s.getServers(services.KindProxy, proxiesPrefix)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L339-L342 | go | train | // DeleteAllProxies deletes all proxies | func (s *PresenceService) DeleteAllProxies() error | // DeleteAllProxies deletes all proxies
func (s *PresenceService) DeleteAllProxies() error | {
startKey := backend.Key(proxiesPrefix)
return s.DeleteRange(context.TODO(), startKey, backend.RangeEnd(startKey))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L345-L348 | go | train | // DeleteProxy deletes proxy | func (s *PresenceService) DeleteProxy(name string) error | // DeleteProxy deletes proxy
func (s *PresenceService) DeleteProxy(name string) error | {
key := backend.Key(proxiesPrefix, name)
return s.Delete(context.TODO(), key)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L351-L354 | go | train | // DeleteAllReverseTunnels deletes all reverse tunnels | func (s *PresenceService) DeleteAllReverseTunnels() error | // DeleteAllReverseTunnels deletes all reverse tunnels
func (s *PresenceService) DeleteAllReverseTunnels() error | {
startKey := backend.Key(reverseTunnelsPrefix)
return s.DeleteRange(context.TODO(), startKey, backend.RangeEnd(startKey))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L357-L372 | go | train | // UpsertReverseTunnel upserts reverse tunnel entry temporarily or permanently | func (s *PresenceService) UpsertReverseTunnel(tunnel services.ReverseTunnel) error | // UpsertReverseTunnel upserts reverse tunnel entry temporarily or permanently
func (s *PresenceService) UpsertReverseTunnel(tunnel services.ReverseTunnel) error | {
if err := tunnel.Check(); err != nil {
return trace.Wrap(err)
}
value, err := services.GetReverseTunnelMarshaler().MarshalReverseTunnel(tunnel)
if err != nil {
return trace.Wrap(err)
}
_, err = s.Put(context.TODO(), backend.Item{
Key: backend.Key(reverseTunnelsPrefix, tunnel.GetName()),
Value: va... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L375-L382 | go | train | // GetReverseTunnel returns reverse tunnel by name | func (s *PresenceService) GetReverseTunnel(name string, opts ...services.MarshalOption) (services.ReverseTunnel, error) | // GetReverseTunnel returns reverse tunnel by name
func (s *PresenceService) GetReverseTunnel(name string, opts ...services.MarshalOption) (services.ReverseTunnel, error) | {
item, err := s.Get(context.TODO(), backend.Key(reverseTunnelsPrefix, name))
if err != nil {
return nil, trace.Wrap(err)
}
return services.GetReverseTunnelMarshaler().UnmarshalReverseTunnel(item.Value,
services.AddOptions(opts, services.WithResourceID(item.ID), services.WithExpires(item.Expires))...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L385-L403 | go | train | // GetReverseTunnels returns a list of registered servers | func (s *PresenceService) GetReverseTunnels(opts ...services.MarshalOption) ([]services.ReverseTunnel, error) | // GetReverseTunnels returns a list of registered servers
func (s *PresenceService) GetReverseTunnels(opts ...services.MarshalOption) ([]services.ReverseTunnel, error) | {
startKey := backend.Key(reverseTunnelsPrefix)
result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit)
if err != nil {
return nil, trace.Wrap(err)
}
tunnels := make([]services.ReverseTunnel, len(result.Items))
for i, item := range result.Items {
tunnel, err := servic... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L406-L409 | go | train | // DeleteReverseTunnel deletes reverse tunnel by it's cluster name | func (s *PresenceService) DeleteReverseTunnel(clusterName string) error | // DeleteReverseTunnel deletes reverse tunnel by it's cluster name
func (s *PresenceService) DeleteReverseTunnel(clusterName string) error | {
err := s.Delete(context.TODO(), backend.Key(reverseTunnelsPrefix, clusterName))
return trace.Wrap(err)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L412-L430 | go | train | // UpsertTrustedCluster creates or updates a TrustedCluster in the backend. | func (s *PresenceService) UpsertTrustedCluster(trustedCluster services.TrustedCluster) (services.TrustedCluster, error) | // UpsertTrustedCluster creates or updates a TrustedCluster in the backend.
func (s *PresenceService) UpsertTrustedCluster(trustedCluster services.TrustedCluster) (services.TrustedCluster, error) | {
if err := trustedCluster.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
value, err := services.GetTrustedClusterMarshaler().Marshal(trustedCluster)
if err != nil {
return nil, trace.Wrap(err)
}
_, err = s.Put(context.TODO(), backend.Item{
Key: backend.Key(trustedClustersPrefix, tru... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L433-L442 | go | train | // GetTrustedCluster returns a single TrustedCluster by name. | func (s *PresenceService) GetTrustedCluster(name string) (services.TrustedCluster, error) | // GetTrustedCluster returns a single TrustedCluster by name.
func (s *PresenceService) GetTrustedCluster(name string) (services.TrustedCluster, error) | {
if name == "" {
return nil, trace.BadParameter("missing trusted cluster name")
}
item, err := s.Get(context.TODO(), backend.Key(trustedClustersPrefix, name))
if err != nil {
return nil, trace.Wrap(err)
}
return services.GetTrustedClusterMarshaler().Unmarshal(item.Value, services.WithResourceID(item.ID), se... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L445-L463 | go | train | // GetTrustedClusters returns all TrustedClusters in the backend. | func (s *PresenceService) GetTrustedClusters() ([]services.TrustedCluster, error) | // GetTrustedClusters returns all TrustedClusters in the backend.
func (s *PresenceService) GetTrustedClusters() ([]services.TrustedCluster, error) | {
startKey := backend.Key(trustedClustersPrefix)
result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit)
if err != nil {
return nil, trace.Wrap(err)
}
out := make([]services.TrustedCluster, len(result.Items))
for i, item := range result.Items {
tc, err := services.Get... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L466-L477 | go | train | // DeleteTrustedCluster removes a TrustedCluster from the backend by name. | func (s *PresenceService) DeleteTrustedCluster(name string) error | // DeleteTrustedCluster removes a TrustedCluster from the backend by name.
func (s *PresenceService) DeleteTrustedCluster(name string) error | {
if name == "" {
return trace.BadParameter("missing trusted cluster name")
}
err := s.Delete(context.TODO(), backend.Key(trustedClustersPrefix, name))
if err != nil {
if trace.IsNotFound(err) {
return trace.NotFound("trusted cluster %q is not found", name)
}
}
return trace.Wrap(err)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L480-L498 | go | train | // UpsertTunnelConnection updates or creates tunnel connection | func (s *PresenceService) UpsertTunnelConnection(conn services.TunnelConnection) error | // UpsertTunnelConnection updates or creates tunnel connection
func (s *PresenceService) UpsertTunnelConnection(conn services.TunnelConnection) error | {
if err := conn.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err)
}
value, err := services.MarshalTunnelConnection(conn)
if err != nil {
return trace.Wrap(err)
}
_, err = s.Put(context.TODO(), backend.Item{
Key: backend.Key(tunnelConnectionsPrefix, conn.GetClusterName(), conn.GetName()),
Va... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L501-L515 | go | train | // GetTunnelConnection returns connection by cluster name and connection name | func (s *PresenceService) GetTunnelConnection(clusterName, connectionName string, opts ...services.MarshalOption) (services.TunnelConnection, error) | // GetTunnelConnection returns connection by cluster name and connection name
func (s *PresenceService) GetTunnelConnection(clusterName, connectionName string, opts ...services.MarshalOption) (services.TunnelConnection, error) | {
item, err := s.Get(context.TODO(), backend.Key(tunnelConnectionsPrefix, clusterName, connectionName))
if err != nil {
if trace.IsNotFound(err) {
return nil, trace.NotFound("trusted cluster connection %q is not found", connectionName)
}
return nil, trace.Wrap(err)
}
conn, err := services.UnmarshalTunnelC... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L518-L538 | go | train | // GetTunnelConnections returns connections for a trusted cluster | func (s *PresenceService) GetTunnelConnections(clusterName string, opts ...services.MarshalOption) ([]services.TunnelConnection, error) | // GetTunnelConnections returns connections for a trusted cluster
func (s *PresenceService) GetTunnelConnections(clusterName string, opts ...services.MarshalOption) ([]services.TunnelConnection, error) | {
if clusterName == "" {
return nil, trace.BadParameter("missing cluster name")
}
startKey := backend.Key(tunnelConnectionsPrefix, clusterName)
result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit)
if err != nil {
return nil, trace.Wrap(err)
}
conns := make([]servi... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L564-L572 | go | train | // DeleteTunnelConnection deletes tunnel connection by name | func (s *PresenceService) DeleteTunnelConnection(clusterName, connectionName string) error | // DeleteTunnelConnection deletes tunnel connection by name
func (s *PresenceService) DeleteTunnelConnection(clusterName, connectionName string) error | {
if clusterName == "" {
return trace.BadParameter("missing cluster name")
}
if connectionName == "" {
return trace.BadParameter("missing connection name")
}
return s.Delete(context.TODO(), backend.Key(tunnelConnectionsPrefix, clusterName, connectionName))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L575-L582 | go | train | // DeleteTunnelConnections deletes all tunnel connections for cluster | func (s *PresenceService) DeleteTunnelConnections(clusterName string) error | // DeleteTunnelConnections deletes all tunnel connections for cluster
func (s *PresenceService) DeleteTunnelConnections(clusterName string) error | {
if clusterName == "" {
return trace.BadParameter("missing cluster name")
}
startKey := backend.Key(tunnelConnectionsPrefix, clusterName)
err := s.DeleteRange(context.TODO(), startKey, backend.RangeEnd(startKey))
return trace.Wrap(err)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L585-L589 | go | train | // DeleteAllTunnelConnections deletes all tunnel connections | func (s *PresenceService) DeleteAllTunnelConnections() error | // DeleteAllTunnelConnections deletes all tunnel connections
func (s *PresenceService) DeleteAllTunnelConnections() error | {
startKey := backend.Key(tunnelConnectionsPrefix)
err := s.DeleteRange(context.TODO(), startKey, backend.RangeEnd(startKey))
return trace.Wrap(err)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L592-L607 | go | train | // CreateRemoteCluster creates remote cluster | func (s *PresenceService) CreateRemoteCluster(rc services.RemoteCluster) error | // CreateRemoteCluster creates remote cluster
func (s *PresenceService) CreateRemoteCluster(rc services.RemoteCluster) error | {
value, err := json.Marshal(rc)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(remoteClustersPrefix, rc.GetName()),
Value: value,
Expires: rc.Expiry(),
}
_, err = s.Create(context.TODO(), item)
if err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L610-L627 | go | train | // GetRemoteClusters returns a list of remote clusters | func (s *PresenceService) GetRemoteClusters(opts ...services.MarshalOption) ([]services.RemoteCluster, error) | // GetRemoteClusters returns a list of remote clusters
func (s *PresenceService) GetRemoteClusters(opts ...services.MarshalOption) ([]services.RemoteCluster, error) | {
startKey := backend.Key(remoteClustersPrefix)
result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit)
if err != nil {
return nil, trace.Wrap(err)
}
clusters := make([]services.RemoteCluster, len(result.Items))
for i, item := range result.Items {
cluster, err := ser... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L630-L643 | go | train | // GetRemoteCluster returns a remote cluster by name | func (s *PresenceService) GetRemoteCluster(clusterName string) (services.RemoteCluster, error) | // GetRemoteCluster returns a remote cluster by name
func (s *PresenceService) GetRemoteCluster(clusterName string) (services.RemoteCluster, error) | {
if clusterName == "" {
return nil, trace.BadParameter("missing parameter cluster name")
}
item, err := s.Get(context.TODO(), backend.Key(remoteClustersPrefix, clusterName))
if err != nil {
if trace.IsNotFound(err) {
return nil, trace.NotFound("remote cluster %q is not found", clusterName)
}
return nil... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L646-L651 | go | train | // DeleteRemoteCluster deletes remote cluster by name | func (s *PresenceService) DeleteRemoteCluster(clusterName string) error | // DeleteRemoteCluster deletes remote cluster by name
func (s *PresenceService) DeleteRemoteCluster(clusterName string) error | {
if clusterName == "" {
return trace.BadParameter("missing parameter cluster name")
}
return s.Delete(context.TODO(), backend.Key(remoteClustersPrefix, clusterName))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/presence.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/presence.go#L654-L658 | go | train | // DeleteAllRemoteClusters deletes all remote clusters | func (s *PresenceService) DeleteAllRemoteClusters() error | // DeleteAllRemoteClusters deletes all remote clusters
func (s *PresenceService) DeleteAllRemoteClusters() error | {
startKey := backend.Key(remoteClustersPrefix)
err := s.DeleteRange(context.TODO(), startKey, backend.RangeEnd(startKey))
return trace.Wrap(err)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/player.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/player.go#L119-L137 | go | train | // timestampFrame prints 'event timestamp' in the top right corner of the
// terminal after playing every 'print' event | func timestampFrame(message string) | // timestampFrame prints 'event timestamp' in the top right corner of the
// terminal after playing every 'print' event
func timestampFrame(message string) | {
const (
saveCursor = "7"
restoreCursor = "8"
)
sz, err := term.GetWinsize(0)
if err != nil {
return
}
esc := func(s string) {
os.Stdout.Write([]byte("\x1b" + s))
}
esc(saveCursor)
defer esc(restoreCursor)
// move cursor to -10:0
esc(fmt.Sprintf("[%d;%df", 0, int(sz.Width)-len(message)))
os.St... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/player.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/player.go#L143-L217 | go | train | // playRange plays events from a given from:to range. In order for the replay
// to render correctly, playRange always plays from the beginning, but starts
// applying timing info (delays) only after 'from' event, creating an impression
// that playback starts from there. | func (p *sessionPlayer) playRange(from, to int) | // playRange plays events from a given from:to range. In order for the replay
// to render correctly, playRange always plays from the beginning, but starts
// applying timing info (delays) only after 'from' event, creating an impression
// that playback starts from there.
func (p *sessionPlayer) playRange(from, to int) | {
if to > len(p.sessionEvents) || from < 0 {
p.state = stateStopped
return
}
if to == 0 {
to = len(p.sessionEvents)
}
// clear screen between runs:
os.Stdout.Write([]byte("\x1bc"))
// wait: waits between events during playback
prev := time.Duration(0)
wait := func(i int, e events.EventFields) {
ms := ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/utils/jsontools.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/jsontools.go#L61-L71 | go | train | // FastUnmarshal uses the json-iterator library for fast JSON unmarshalling.
// Note, this function marshals floats with 6 digits precision. | func FastUnmarshal(data []byte, v interface{}) error | // FastUnmarshal uses the json-iterator library for fast JSON unmarshalling.
// Note, this function marshals floats with 6 digits precision.
func FastUnmarshal(data []byte, v interface{}) error | {
iter := jsoniter.ConfigFastest.BorrowIterator(data)
defer jsoniter.ConfigFastest.ReturnIterator(iter)
iter.ReadVal(v)
if iter.Error != nil {
return trace.Wrap(iter.Error)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/utils/jsontools.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/jsontools.go#L75-L82 | go | train | // FastMarshal uses the json-iterator library for fast JSON marshalling.
// Note, this function marshals floats with 6 digits precision. | func FastMarshal(v interface{}) ([]byte, error) | // FastMarshal uses the json-iterator library for fast JSON marshalling.
// Note, this function marshals floats with 6 digits precision.
func FastMarshal(v interface{}) ([]byte, error) | {
data, err := jsoniter.ConfigFastest.Marshal(v)
if err != nil {
return nil, trace.Wrap(err)
}
return data, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/utils/jsontools.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/jsontools.go#L89-L119 | go | train | // WriteYAML detects whether value is a list
// and marshals multiple documents delimited by `---`, otherwise, marshals
// a single value | func WriteYAML(w io.Writer, values interface{}) error | // WriteYAML detects whether value is a list
// and marshals multiple documents delimited by `---`, otherwise, marshals
// a single value
func WriteYAML(w io.Writer, values interface{}) error | {
if reflect.TypeOf(values).Kind() != reflect.Slice {
return trace.Wrap(writeYAML(w, values))
}
// first pass makes sure that all values are documents (objects or maps)
slice := reflect.ValueOf(values)
allDocs := func() bool {
for i := 0; i < slice.Len(); i++ {
if !isDoc(slice.Index(i)) {
return false
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.