id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
23,100
gravitational/teleport
lib/utils/loadbalancer.go
dropConnections
func (l *LoadBalancer) dropConnections(backend NetAddr) { tracker := l.connections[backend] for _, conn := range tracker { conn.Close() } delete(l.connections, backend) }
go
func (l *LoadBalancer) dropConnections(backend NetAddr) { tracker := l.connections[backend] for _, conn := range tracker { conn.Close() } delete(l.connections, backend) }
[ "func", "(", "l", "*", "LoadBalancer", ")", "dropConnections", "(", "backend", "NetAddr", ")", "{", "tracker", ":=", "l", ".", "connections", "[", "backend", "]", "\n", "for", "_", ",", "conn", ":=", "range", "tracker", "{", "conn", ".", "Close", "(", ...
// dropConnections drops connections associated with backend
[ "dropConnections", "drops", "connections", "associated", "with", "backend" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L97-L103
23,101
gravitational/teleport
lib/utils/loadbalancer.go
AddBackend
func (l *LoadBalancer) AddBackend(b NetAddr) { l.Lock() defer l.Unlock() l.backends = append(l.backends, b) l.Debugf("backends %v", l.backends) }
go
func (l *LoadBalancer) AddBackend(b NetAddr) { l.Lock() defer l.Unlock() l.backends = append(l.backends, b) l.Debugf("backends %v", l.backends) }
[ "func", "(", "l", "*", "LoadBalancer", ")", "AddBackend", "(", "b", "NetAddr", ")", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n", "l", ".", "backends", "=", "append", "(", "l", ".", "backends", ",", "b", ")...
// AddBackend adds backend
[ "AddBackend", "adds", "backend" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L106-L111
23,102
gravitational/teleport
lib/utils/loadbalancer.go
RemoveBackend
func (l *LoadBalancer) RemoveBackend(b NetAddr) { l.Lock() defer l.Unlock() l.currentIndex = -1 for i := range l.backends { if l.backends[i].Equals(b) { l.backends = append(l.backends[:i], l.backends[i+1:]...) l.dropConnections(b) return } } }
go
func (l *LoadBalancer) RemoveBackend(b NetAddr) { l.Lock() defer l.Unlock() l.currentIndex = -1 for i := range l.backends { if l.backends[i].Equals(b) { l.backends = append(l.backends[:i], l.backends[i+1:]...) l.dropConnections(b) return } } }
[ "func", "(", "l", "*", "LoadBalancer", ")", "RemoveBackend", "(", "b", "NetAddr", ")", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n", "l", ".", "currentIndex", "=", "-", "1", "\n", "for", "i", ":=", "range", ...
// RemoveBackend removes backend
[ "RemoveBackend", "removes", "backend" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L114-L125
23,103
gravitational/teleport
lib/utils/loadbalancer.go
ListenAndServe
func (l *LoadBalancer) ListenAndServe() error { if err := l.Listen(); err != nil { return trace.Wrap(err) } return l.Serve() }
go
func (l *LoadBalancer) ListenAndServe() error { if err := l.Listen(); err != nil { return trace.Wrap(err) } return l.Serve() }
[ "func", "(", "l", "*", "LoadBalancer", ")", "ListenAndServe", "(", ")", "error", "{", "if", "err", ":=", "l", ".", "Listen", "(", ")", ";", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", "err", ")", "\n", "}", "\n", "return", "l", ...
// ListenAndServe starts listening socket and serves connections on it
[ "ListenAndServe", "starts", "listening", "socket", "and", "serves", "connections", "on", "it" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L162-L167
23,104
gravitational/teleport
lib/utils/loadbalancer.go
Listen
func (l *LoadBalancer) Listen() error { var err error l.listener, err = net.Listen(l.frontend.AddrNetwork, l.frontend.Addr) if err != nil { return trace.ConvertSystemError(err) } l.Debugf("created listening socket") return nil }
go
func (l *LoadBalancer) Listen() error { var err error l.listener, err = net.Listen(l.frontend.AddrNetwork, l.frontend.Addr) if err != nil { return trace.ConvertSystemError(err) } l.Debugf("created listening socket") return nil }
[ "func", "(", "l", "*", "LoadBalancer", ")", "Listen", "(", ")", "error", "{", "var", "err", "error", "\n", "l", ".", "listener", ",", "err", "=", "net", ".", "Listen", "(", "l", ".", "frontend", ".", "AddrNetwork", ",", "l", ".", "frontend", ".", ...
// Listen creates a listener on the frontend addr
[ "Listen", "creates", "a", "listener", "on", "the", "frontend", "addr" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L170-L178
23,105
gravitational/teleport
lib/utils/loadbalancer.go
Serve
func (l *LoadBalancer) Serve() error { defer l.waitCancel() backoffTimer := time.NewTicker(5 * time.Second) defer backoffTimer.Stop() for { conn, err := l.listener.Accept() if err != nil { if l.isClosed() { return trace.ConnectionProblem(nil, "listener is closed") } select { case <-backoffTimer....
go
func (l *LoadBalancer) Serve() error { defer l.waitCancel() backoffTimer := time.NewTicker(5 * time.Second) defer backoffTimer.Stop() for { conn, err := l.listener.Accept() if err != nil { if l.isClosed() { return trace.ConnectionProblem(nil, "listener is closed") } select { case <-backoffTimer....
[ "func", "(", "l", "*", "LoadBalancer", ")", "Serve", "(", ")", "error", "{", "defer", "l", ".", "waitCancel", "(", ")", "\n", "backoffTimer", ":=", "time", ".", "NewTicker", "(", "5", "*", "time", ".", "Second", ")", "\n", "defer", "backoffTimer", "....
// Serve starts accepting connections
[ "Serve", "starts", "accepting", "connections" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/loadbalancer.go#L181-L200
23,106
gravitational/teleport
lib/events/sessionlog.go
NewDiskSessionLogger
func NewDiskSessionLogger(cfg DiskSessionLoggerConfig) (*DiskSessionLogger, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } var err error sessionDir := filepath.Join(cfg.DataDir, cfg.ServerID, SessionLogsDir, cfg.Namespace) indexFile, err := os.OpenFile( filepath.Join(...
go
func NewDiskSessionLogger(cfg DiskSessionLoggerConfig) (*DiskSessionLogger, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } var err error sessionDir := filepath.Join(cfg.DataDir, cfg.ServerID, SessionLogsDir, cfg.Namespace) indexFile, err := os.OpenFile( filepath.Join(...
[ "func", "NewDiskSessionLogger", "(", "cfg", "DiskSessionLoggerConfig", ")", "(", "*", "DiskSessionLogger", ",", "error", ")", "{", "if", "err", ":=", "cfg", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ...
// NewDiskSessionLogger creates new disk based session logger
[ "NewDiskSessionLogger", "creates", "new", "disk", "based", "session", "logger" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L80-L107
23,107
gravitational/teleport
lib/events/sessionlog.go
Finalize
func (sl *DiskSessionLogger) Finalize() error { sl.Lock() defer sl.Unlock() return sl.finalize() }
go
func (sl *DiskSessionLogger) Finalize() error { sl.Lock() defer sl.Unlock() return sl.finalize() }
[ "func", "(", "sl", "*", "DiskSessionLogger", ")", "Finalize", "(", ")", "error", "{", "sl", ".", "Lock", "(", ")", "\n", "defer", "sl", ".", "Unlock", "(", ")", "\n\n", "return", "sl", ".", "finalize", "(", ")", "\n", "}" ]
// Finalize is called by the session when it's closing. This is where we're // releasing audit resources associated with the session
[ "Finalize", "is", "called", "by", "the", "session", "when", "it", "s", "closing", ".", "This", "is", "where", "we", "re", "releasing", "audit", "resources", "associated", "with", "the", "session" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L163-L168
23,108
gravitational/teleport
lib/events/sessionlog.go
flush
func (sl *DiskSessionLogger) flush() error { var err, err2 error if sl.RecordSessions && sl.chunksFile != nil { err = sl.chunksFile.Flush() } if sl.eventsFile != nil { err2 = sl.eventsFile.Flush() } return trace.NewAggregate(err, err2) }
go
func (sl *DiskSessionLogger) flush() error { var err, err2 error if sl.RecordSessions && sl.chunksFile != nil { err = sl.chunksFile.Flush() } if sl.eventsFile != nil { err2 = sl.eventsFile.Flush() } return trace.NewAggregate(err, err2) }
[ "func", "(", "sl", "*", "DiskSessionLogger", ")", "flush", "(", ")", "error", "{", "var", "err", ",", "err2", "error", "\n\n", "if", "sl", ".", "RecordSessions", "&&", "sl", ".", "chunksFile", "!=", "nil", "{", "err", "=", "sl", ".", "chunksFile", "....
// flush is used to flush gzip frames to file, otherwise // some attempts to read the file could fail
[ "flush", "is", "used", "to", "flush", "gzip", "frames", "to", "file", "otherwise", "some", "attempts", "to", "read", "the", "file", "could", "fail" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L172-L182
23,109
gravitational/teleport
lib/events/sessionlog.go
eventsFileName
func eventsFileName(dataDir string, sessionID session.ID, eventIndex int64) string { return filepath.Join(dataDir, fmt.Sprintf("%v-%v.events.gz", sessionID.String(), eventIndex)) }
go
func eventsFileName(dataDir string, sessionID session.ID, eventIndex int64) string { return filepath.Join(dataDir, fmt.Sprintf("%v-%v.events.gz", sessionID.String(), eventIndex)) }
[ "func", "eventsFileName", "(", "dataDir", "string", ",", "sessionID", "session", ".", "ID", ",", "eventIndex", "int64", ")", "string", "{", "return", "filepath", ".", "Join", "(", "dataDir", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "sessionID", ...
// eventsFileName consists of session id and the first global event index recorded there
[ "eventsFileName", "consists", "of", "session", "id", "and", "the", "first", "global", "event", "index", "recorded", "there" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L215-L217
23,110
gravitational/teleport
lib/events/sessionlog.go
chunksFileName
func chunksFileName(dataDir string, sessionID session.ID, offset int64) string { return filepath.Join(dataDir, fmt.Sprintf("%v-%v.chunks.gz", sessionID.String(), offset)) }
go
func chunksFileName(dataDir string, sessionID session.ID, offset int64) string { return filepath.Join(dataDir, fmt.Sprintf("%v-%v.chunks.gz", sessionID.String(), offset)) }
[ "func", "chunksFileName", "(", "dataDir", "string", ",", "sessionID", "session", ".", "ID", ",", "offset", "int64", ")", "string", "{", "return", "filepath", ".", "Join", "(", "dataDir", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "sessionID", ".",...
// chunksFileName consists of session id and the first global offset recorded
[ "chunksFileName", "consists", "of", "session", "id", "and", "the", "first", "global", "offset", "recorded" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L220-L222
23,111
gravitational/teleport
lib/events/sessionlog.go
PostSessionSlice
func (sl *DiskSessionLogger) PostSessionSlice(slice SessionSlice) error { sl.Lock() defer sl.Unlock() for i := range slice.Chunks { _, err := sl.writeChunk(slice.SessionID, slice.Chunks[i]) if err != nil { return trace.Wrap(err) } } return sl.flush() }
go
func (sl *DiskSessionLogger) PostSessionSlice(slice SessionSlice) error { sl.Lock() defer sl.Unlock() for i := range slice.Chunks { _, err := sl.writeChunk(slice.SessionID, slice.Chunks[i]) if err != nil { return trace.Wrap(err) } } return sl.flush() }
[ "func", "(", "sl", "*", "DiskSessionLogger", ")", "PostSessionSlice", "(", "slice", "SessionSlice", ")", "error", "{", "sl", ".", "Lock", "(", ")", "\n", "defer", "sl", ".", "Unlock", "(", ")", "\n\n", "for", "i", ":=", "range", "slice", ".", "Chunks",...
// PostSessionSlice takes series of events associated with the session // and writes them to events files and data file for future replays
[ "PostSessionSlice", "takes", "series", "of", "events", "associated", "with", "the", "session", "and", "writes", "them", "to", "events", "files", "and", "data", "file", "for", "future", "replays" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L292-L303
23,112
gravitational/teleport
lib/events/sessionlog.go
EventFromChunk
func EventFromChunk(sessionID string, chunk *SessionChunk) (EventFields, error) { var fields EventFields eventStart := time.Unix(0, chunk.Time).In(time.UTC).Round(time.Millisecond) err := json.Unmarshal(chunk.Data, &fields) if err != nil { return nil, trace.Wrap(err) } fields[SessionEventID] = sessionID fields...
go
func EventFromChunk(sessionID string, chunk *SessionChunk) (EventFields, error) { var fields EventFields eventStart := time.Unix(0, chunk.Time).In(time.UTC).Round(time.Millisecond) err := json.Unmarshal(chunk.Data, &fields) if err != nil { return nil, trace.Wrap(err) } fields[SessionEventID] = sessionID fields...
[ "func", "EventFromChunk", "(", "sessionID", "string", ",", "chunk", "*", "SessionChunk", ")", "(", "EventFields", ",", "error", ")", "{", "var", "fields", "EventFields", "\n", "eventStart", ":=", "time", ".", "Unix", "(", "0", ",", "chunk", ".", "Time", ...
// EventFromChunk returns event converted from session chunk
[ "EventFromChunk", "returns", "event", "converted", "from", "session", "chunk" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L306-L321
23,113
gravitational/teleport
lib/events/sessionlog.go
Close
func (f *gzipWriter) Close() error { var errors []error if f.Writer != nil { errors = append(errors, f.Writer.Close()) f.Writer.Reset(ioutil.Discard) writerPool.Put(f.Writer) f.Writer = nil } if f.file != nil { errors = append(errors, f.file.Close()) f.file = nil } return trace.NewAggregate(errors...)...
go
func (f *gzipWriter) Close() error { var errors []error if f.Writer != nil { errors = append(errors, f.Writer.Close()) f.Writer.Reset(ioutil.Discard) writerPool.Put(f.Writer) f.Writer = nil } if f.file != nil { errors = append(errors, f.file.Close()) f.file = nil } return trace.NewAggregate(errors...)...
[ "func", "(", "f", "*", "gzipWriter", ")", "Close", "(", ")", "error", "{", "var", "errors", "[", "]", "error", "\n", "if", "f", ".", "Writer", "!=", "nil", "{", "errors", "=", "append", "(", "errors", ",", "f", ".", "Writer", ".", "Close", "(", ...
// Close closes gzip writer and file
[ "Close", "closes", "gzip", "writer", "and", "file" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L421-L434
23,114
gravitational/teleport
lib/events/sessionlog.go
Close
func (f *gzipReader) Close() error { var errors []error if f.ReadCloser != nil { errors = append(errors, f.ReadCloser.Close()) f.ReadCloser = nil } if f.file != nil { errors = append(errors, f.file.Close()) f.file = nil } return trace.NewAggregate(errors...) }
go
func (f *gzipReader) Close() error { var errors []error if f.ReadCloser != nil { errors = append(errors, f.ReadCloser.Close()) f.ReadCloser = nil } if f.file != nil { errors = append(errors, f.file.Close()) f.file = nil } return trace.NewAggregate(errors...) }
[ "func", "(", "f", "*", "gzipReader", ")", "Close", "(", ")", "error", "{", "var", "errors", "[", "]", "error", "\n", "if", "f", ".", "ReadCloser", "!=", "nil", "{", "errors", "=", "append", "(", "errors", ",", "f", ".", "ReadCloser", ".", "Close", ...
// Close closes file and gzip writer
[ "Close", "closes", "file", "and", "gzip", "writer" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/sessionlog.go#L463-L474
23,115
gravitational/teleport
lib/srv/heartbeat.go
String
func (h HeartbeatMode) String() string { switch h { case HeartbeatModeNode: return "Node" case HeartbeatModeProxy: return "Proxy" case HeartbeatModeAuth: return "Auth" default: return fmt.Sprintf("<unknown: %v>", int(h)) } }
go
func (h HeartbeatMode) String() string { switch h { case HeartbeatModeNode: return "Node" case HeartbeatModeProxy: return "Proxy" case HeartbeatModeAuth: return "Auth" default: return fmt.Sprintf("<unknown: %v>", int(h)) } }
[ "func", "(", "h", "HeartbeatMode", ")", "String", "(", ")", "string", "{", "switch", "h", "{", "case", "HeartbeatModeNode", ":", "return", "\"", "\"", "\n", "case", "HeartbeatModeProxy", ":", "return", "\"", "\"", "\n", "case", "HeartbeatModeAuth", ":", "r...
// String returns user-friendly representation of the mode
[ "String", "returns", "user", "-", "friendly", "representation", "of", "the", "mode" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L88-L99
23,116
gravitational/teleport
lib/srv/heartbeat.go
NewHeartbeat
func NewHeartbeat(cfg HeartbeatConfig) (*Heartbeat, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } ctx, cancel := context.WithCancel(cfg.Context) h := &Heartbeat{ cancelCtx: ctx, cancel: cancel, HeartbeatConfig: cfg, Entry: log.WithFields(log.Fields...
go
func NewHeartbeat(cfg HeartbeatConfig) (*Heartbeat, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } ctx, cancel := context.WithCancel(cfg.Context) h := &Heartbeat{ cancelCtx: ctx, cancel: cancel, HeartbeatConfig: cfg, Entry: log.WithFields(log.Fields...
[ "func", "NewHeartbeat", "(", "cfg", "HeartbeatConfig", ")", "(", "*", "Heartbeat", ",", "error", ")", "{", "if", "err", ":=", "cfg", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "Wrap", "(", ...
// NewHeartbeat returns a new instance of heartbeat
[ "NewHeartbeat", "returns", "a", "new", "instance", "of", "heartbeat" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L114-L132
23,117
gravitational/teleport
lib/srv/heartbeat.go
Run
func (h *Heartbeat) Run() error { defer func() { h.reset(HeartbeatStateInit) h.checkTicker.Stop() }() for { if err := h.fetchAndAnnounce(); err != nil { h.Warningf("Heartbeat failed %v.", err) } select { case <-h.checkTicker.C: case <-h.sendC: h.Debugf("Asked check out of cycle") case <-h.cance...
go
func (h *Heartbeat) Run() error { defer func() { h.reset(HeartbeatStateInit) h.checkTicker.Stop() }() for { if err := h.fetchAndAnnounce(); err != nil { h.Warningf("Heartbeat failed %v.", err) } select { case <-h.checkTicker.C: case <-h.sendC: h.Debugf("Asked check out of cycle") case <-h.cance...
[ "func", "(", "h", "*", "Heartbeat", ")", "Run", "(", ")", "error", "{", "defer", "func", "(", ")", "{", "h", ".", "reset", "(", "HeartbeatStateInit", ")", "\n", "h", ".", "checkTicker", ".", "Stop", "(", ")", "\n", "}", "(", ")", "\n", "for", "...
// Run periodically calls to announce presence, // should be called explicitly in a separate goroutine
[ "Run", "periodically", "calls", "to", "announce", "presence", "should", "be", "called", "explicitly", "in", "a", "separate", "goroutine" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L233-L251
23,118
gravitational/teleport
lib/srv/heartbeat.go
reset
func (h *Heartbeat) reset(state KeepAliveState) { h.setState(state) h.nextAnnounce = time.Time{} h.nextKeepAlive = time.Time{} h.keepAlive = nil if h.keepAliver != nil { if err := h.keepAliver.Close(); err != nil { h.Warningf("Failed to close keep aliver: %v", err) } h.keepAliver = nil } }
go
func (h *Heartbeat) reset(state KeepAliveState) { h.setState(state) h.nextAnnounce = time.Time{} h.nextKeepAlive = time.Time{} h.keepAlive = nil if h.keepAliver != nil { if err := h.keepAliver.Close(); err != nil { h.Warningf("Failed to close keep aliver: %v", err) } h.keepAliver = nil } }
[ "func", "(", "h", "*", "Heartbeat", ")", "reset", "(", "state", "KeepAliveState", ")", "{", "h", ".", "setState", "(", "state", ")", "\n", "h", ".", "nextAnnounce", "=", "time", ".", "Time", "{", "}", "\n", "h", ".", "nextKeepAlive", "=", "time", "...
// reset resets keep alive state // and sends the state back to the initial state // of sending full update
[ "reset", "resets", "keep", "alive", "state", "and", "sends", "the", "state", "back", "to", "the", "initial", "state", "of", "sending", "full", "update" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L276-L287
23,119
gravitational/teleport
lib/srv/heartbeat.go
fetch
func (h *Heartbeat) fetch() error { // failed to fetch server info? // reset to init state regardless of the current state server, err := h.GetServerInfo() if err != nil { h.reset(HeartbeatStateInit) return trace.Wrap(err) } switch h.state { // in case of successfull state fetch, move to announce from init ...
go
func (h *Heartbeat) fetch() error { // failed to fetch server info? // reset to init state regardless of the current state server, err := h.GetServerInfo() if err != nil { h.reset(HeartbeatStateInit) return trace.Wrap(err) } switch h.state { // in case of successfull state fetch, move to announce from init ...
[ "func", "(", "h", "*", "Heartbeat", ")", "fetch", "(", ")", "error", "{", "// failed to fetch server info?", "// reset to init state regardless of the current state", "server", ",", "err", ":=", "h", ".", "GetServerInfo", "(", ")", "\n", "if", "err", "!=", "nil", ...
// fetch, if succeeded updates or sets current server // to the last received server
[ "fetch", "if", "succeeded", "updates", "or", "sets", "current", "server", "to", "the", "last", "received", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L291-L343
23,120
gravitational/teleport
lib/srv/heartbeat.go
fetchAndAnnounce
func (h *Heartbeat) fetchAndAnnounce() error { if err := h.fetch(); err != nil { return trace.Wrap(err) } if err := h.announce(); err != nil { return trace.Wrap(err) } return nil }
go
func (h *Heartbeat) fetchAndAnnounce() error { if err := h.fetch(); err != nil { return trace.Wrap(err) } if err := h.announce(); err != nil { return trace.Wrap(err) } return nil }
[ "func", "(", "h", "*", "Heartbeat", ")", "fetchAndAnnounce", "(", ")", "error", "{", "if", "err", ":=", "h", ".", "fetch", "(", ")", ";", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", "err", ")", "\n", "}", "\n", "if", "err", ":...
// fetchAndAnnounce fetches data about server // and announces it to the server
[ "fetchAndAnnounce", "fetches", "data", "about", "server", "and", "announces", "it", "to", "the", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L433-L441
23,121
gravitational/teleport
lib/srv/heartbeat.go
ForceSend
func (h *Heartbeat) ForceSend(timeout time.Duration) error { timeoutC := time.After(timeout) select { case h.sendC <- struct{}{}: case <-timeoutC: return trace.ConnectionProblem(nil, "timeout waiting for send") } select { case <-h.announceC: return nil case <-timeoutC: return trace.ConnectionProblem(nil, ...
go
func (h *Heartbeat) ForceSend(timeout time.Duration) error { timeoutC := time.After(timeout) select { case h.sendC <- struct{}{}: case <-timeoutC: return trace.ConnectionProblem(nil, "timeout waiting for send") } select { case <-h.announceC: return nil case <-timeoutC: return trace.ConnectionProblem(nil, ...
[ "func", "(", "h", "*", "Heartbeat", ")", "ForceSend", "(", "timeout", "time", ".", "Duration", ")", "error", "{", "timeoutC", ":=", "time", ".", "After", "(", "timeout", ")", "\n", "select", "{", "case", "h", ".", "sendC", "<-", "struct", "{", "}", ...
// ForceSend forces send cycle, used in tests, returns // nil in case of success, error otherwise
[ "ForceSend", "forces", "send", "cycle", "used", "in", "tests", "returns", "nil", "in", "case", "of", "success", "error", "otherwise" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/heartbeat.go#L445-L458
23,122
gravitational/teleport
lib/events/dynamoevents/dynamoevents.go
deleteAllItems
func (b *Log) deleteAllItems() error { out, err := b.svc.Scan(&dynamodb.ScanInput{TableName: aws.String(b.Tablename)}) if err != nil { return trace.Wrap(err) } var requests []*dynamodb.WriteRequest for _, item := range out.Items { requests = append(requests, &dynamodb.WriteRequest{ DeleteRequest: &dynamodb....
go
func (b *Log) deleteAllItems() error { out, err := b.svc.Scan(&dynamodb.ScanInput{TableName: aws.String(b.Tablename)}) if err != nil { return trace.Wrap(err) } var requests []*dynamodb.WriteRequest for _, item := range out.Items { requests = append(requests, &dynamodb.WriteRequest{ DeleteRequest: &dynamodb....
[ "func", "(", "b", "*", "Log", ")", "deleteAllItems", "(", ")", "error", "{", "out", ",", "err", ":=", "b", ".", "svc", ".", "Scan", "(", "&", "dynamodb", ".", "ScanInput", "{", "TableName", ":", "aws", ".", "String", "(", "b", ".", "Tablename", "...
// deleteAllItems deletes all items from the database, used in tests
[ "deleteAllItems", "deletes", "all", "items", "from", "the", "database", "used", "in", "tests" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/dynamoevents/dynamoevents.go#L572-L602
23,123
gravitational/teleport
lib/services/local/events.go
NewEventsService
func NewEventsService(b backend.Backend) *EventsService { return &EventsService{ Entry: logrus.WithFields(logrus.Fields{trace.Component: "Events"}), backend: b, } }
go
func NewEventsService(b backend.Backend) *EventsService { return &EventsService{ Entry: logrus.WithFields(logrus.Fields{trace.Component: "Events"}), backend: b, } }
[ "func", "NewEventsService", "(", "b", "backend", ".", "Backend", ")", "*", "EventsService", "{", "return", "&", "EventsService", "{", "Entry", ":", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "trace", ".", "Component", ":", "\"", "\"", ...
// NewEventsService returns new events service instance
[ "NewEventsService", "returns", "new", "events", "service", "instance" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/events.go#L39-L44
23,124
gravitational/teleport
lib/services/local/events.go
base
func base(key []byte, offset int) ([]byte, error) { parts := bytes.Split(key, []byte{backend.Separator}) if len(parts) < offset+1 { return nil, trace.NotFound("failed parsing %v", string(key)) } return parts[len(parts)-offset-1], nil }
go
func base(key []byte, offset int) ([]byte, error) { parts := bytes.Split(key, []byte{backend.Separator}) if len(parts) < offset+1 { return nil, trace.NotFound("failed parsing %v", string(key)) } return parts[len(parts)-offset-1], nil }
[ "func", "base", "(", "key", "[", "]", "byte", ",", "offset", "int", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "parts", ":=", "bytes", ".", "Split", "(", "key", ",", "[", "]", "byte", "{", "backend", ".", "Separator", "}", ")", "\n", ...
// base returns last element delimited by separator, index is // is an index of the key part to get counting from the end
[ "base", "returns", "last", "element", "delimited", "by", "separator", "index", "is", "is", "an", "index", "of", "the", "key", "part", "to", "get", "counting", "from", "the", "end" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/events.go#L715-L721
23,125
gravitational/teleport
lib/services/local/events.go
baseTwoKeys
func baseTwoKeys(key []byte) (string, string, error) { parts := bytes.Split(key, []byte{backend.Separator}) if len(parts) < 2 { return "", "", trace.NotFound("failed parsing %v", string(key)) } return string(parts[len(parts)-2]), string(parts[len(parts)-1]), nil }
go
func baseTwoKeys(key []byte) (string, string, error) { parts := bytes.Split(key, []byte{backend.Separator}) if len(parts) < 2 { return "", "", trace.NotFound("failed parsing %v", string(key)) } return string(parts[len(parts)-2]), string(parts[len(parts)-1]), nil }
[ "func", "baseTwoKeys", "(", "key", "[", "]", "byte", ")", "(", "string", ",", "string", ",", "error", ")", "{", "parts", ":=", "bytes", ".", "Split", "(", "key", ",", "[", "]", "byte", "{", "backend", ".", "Separator", "}", ")", "\n", "if", "len"...
// baseTwoKeys returns two last keys
[ "baseTwoKeys", "returns", "two", "last", "keys" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/events.go#L724-L730
23,126
gravitational/teleport
lib/auth/api.go
NewWrapper
func NewWrapper(writer AccessPoint, cache ReadAccessPoint) AccessPoint { return &Wrapper{ Write: writer, ReadAccessPoint: cache, } }
go
func NewWrapper(writer AccessPoint, cache ReadAccessPoint) AccessPoint { return &Wrapper{ Write: writer, ReadAccessPoint: cache, } }
[ "func", "NewWrapper", "(", "writer", "AccessPoint", ",", "cache", "ReadAccessPoint", ")", "AccessPoint", "{", "return", "&", "Wrapper", "{", "Write", ":", "writer", ",", "ReadAccessPoint", ":", "cache", ",", "}", "\n", "}" ]
// NewWrapper returns new access point wrapper
[ "NewWrapper", "returns", "new", "access", "point", "wrapper" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L142-L147
23,127
gravitational/teleport
lib/auth/api.go
UpsertNode
func (w *Wrapper) UpsertNode(s services.Server) (*services.KeepAlive, error) { return w.Write.UpsertNode(s) }
go
func (w *Wrapper) UpsertNode(s services.Server) (*services.KeepAlive, error) { return w.Write.UpsertNode(s) }
[ "func", "(", "w", "*", "Wrapper", ")", "UpsertNode", "(", "s", "services", ".", "Server", ")", "(", "*", "services", ".", "KeepAlive", ",", "error", ")", "{", "return", "w", ".", "Write", ".", "UpsertNode", "(", "s", ")", "\n", "}" ]
// UpsertNode is part of auth.AccessPoint implementation
[ "UpsertNode", "is", "part", "of", "auth", ".", "AccessPoint", "implementation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L158-L160
23,128
gravitational/teleport
lib/auth/api.go
UpsertAuthServer
func (w *Wrapper) UpsertAuthServer(s services.Server) error { return w.Write.UpsertAuthServer(s) }
go
func (w *Wrapper) UpsertAuthServer(s services.Server) error { return w.Write.UpsertAuthServer(s) }
[ "func", "(", "w", "*", "Wrapper", ")", "UpsertAuthServer", "(", "s", "services", ".", "Server", ")", "error", "{", "return", "w", ".", "Write", ".", "UpsertAuthServer", "(", "s", ")", "\n", "}" ]
// UpsertAuthServer is part of auth.AccessPoint implementation
[ "UpsertAuthServer", "is", "part", "of", "auth", ".", "AccessPoint", "implementation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L163-L165
23,129
gravitational/teleport
lib/auth/api.go
UpsertProxy
func (w *Wrapper) UpsertProxy(s services.Server) error { return w.Write.UpsertProxy(s) }
go
func (w *Wrapper) UpsertProxy(s services.Server) error { return w.Write.UpsertProxy(s) }
[ "func", "(", "w", "*", "Wrapper", ")", "UpsertProxy", "(", "s", "services", ".", "Server", ")", "error", "{", "return", "w", ".", "Write", ".", "UpsertProxy", "(", "s", ")", "\n", "}" ]
// UpsertProxy is part of auth.AccessPoint implementation
[ "UpsertProxy", "is", "part", "of", "auth", ".", "AccessPoint", "implementation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L173-L175
23,130
gravitational/teleport
lib/auth/api.go
UpsertTunnelConnection
func (w *Wrapper) UpsertTunnelConnection(conn services.TunnelConnection) error { return w.Write.UpsertTunnelConnection(conn) }
go
func (w *Wrapper) UpsertTunnelConnection(conn services.TunnelConnection) error { return w.Write.UpsertTunnelConnection(conn) }
[ "func", "(", "w", "*", "Wrapper", ")", "UpsertTunnelConnection", "(", "conn", "services", ".", "TunnelConnection", ")", "error", "{", "return", "w", ".", "Write", ".", "UpsertTunnelConnection", "(", "conn", ")", "\n", "}" ]
// UpsertTunnelConnection is a part of auth.AccessPoint implementation
[ "UpsertTunnelConnection", "is", "a", "part", "of", "auth", ".", "AccessPoint", "implementation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L178-L180
23,131
gravitational/teleport
lib/auth/api.go
DeleteTunnelConnection
func (w *Wrapper) DeleteTunnelConnection(clusterName, connName string) error { return w.Write.DeleteTunnelConnection(clusterName, connName) }
go
func (w *Wrapper) DeleteTunnelConnection(clusterName, connName string) error { return w.Write.DeleteTunnelConnection(clusterName, connName) }
[ "func", "(", "w", "*", "Wrapper", ")", "DeleteTunnelConnection", "(", "clusterName", ",", "connName", "string", ")", "error", "{", "return", "w", ".", "Write", ".", "DeleteTunnelConnection", "(", "clusterName", ",", "connName", ")", "\n", "}" ]
// DeleteTunnelConnection is a part of auth.AccessPoint implementation
[ "DeleteTunnelConnection", "is", "a", "part", "of", "auth", ".", "AccessPoint", "implementation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/api.go#L183-L185
23,132
gravitational/teleport
lib/sshutils/server.go
SetShutdownPollPeriod
func SetShutdownPollPeriod(period time.Duration) ServerOption { return func(s *Server) error { s.shutdownPollPeriod = period return nil } }
go
func SetShutdownPollPeriod(period time.Duration) ServerOption { return func(s *Server) error { s.shutdownPollPeriod = period return nil } }
[ "func", "SetShutdownPollPeriod", "(", "period", "time", ".", "Duration", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "error", "{", "s", ".", "shutdownPollPeriod", "=", "period", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetShutdownPollPeriod sets a polling period for graceful shutdowns of SSH servers
[ "SetShutdownPollPeriod", "sets", "a", "polling", "period", "for", "graceful", "shutdowns", "of", "SSH", "servers" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/server.go#L113-L118
23,133
gravitational/teleport
lib/sshutils/server.go
Wait
func (s *Server) Wait(ctx context.Context) { select { case <-s.closeContext.Done(): case <-ctx.Done(): } }
go
func (s *Server) Wait(ctx context.Context) { select { case <-s.closeContext.Done(): case <-ctx.Done(): } }
[ "func", "(", "s", "*", "Server", ")", "Wait", "(", "ctx", "context", ".", "Context", ")", "{", "select", "{", "case", "<-", "s", ".", "closeContext", ".", "Done", "(", ")", ":", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "}", "\n", "}" ]
// Wait waits until server stops serving new connections // on the listener socket
[ "Wait", "waits", "until", "server", "stops", "serving", "new", "connections", "on", "the", "listener", "socket" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/server.go#L268-L273
23,134
gravitational/teleport
lib/sshutils/server.go
Shutdown
func (s *Server) Shutdown(ctx context.Context) error { // close listener to stop receiving new connections err := s.Close() s.Wait(ctx) activeConnections := s.trackConnections(0) if activeConnections == 0 { return err } s.Infof("Shutdown: waiting for %v connections to finish.", activeConnections) lastReport :...
go
func (s *Server) Shutdown(ctx context.Context) error { // close listener to stop receiving new connections err := s.Close() s.Wait(ctx) activeConnections := s.trackConnections(0) if activeConnections == 0 { return err } s.Infof("Shutdown: waiting for %v connections to finish.", activeConnections) lastReport :...
[ "func", "(", "s", "*", "Server", ")", "Shutdown", "(", "ctx", "context", ".", "Context", ")", "error", "{", "// close listener to stop receiving new connections", "err", ":=", "s", ".", "Close", "(", ")", "\n", "s", ".", "Wait", "(", "ctx", ")", "\n", "a...
// Shutdown initiates graceful shutdown - waiting until all active // connections will get closed
[ "Shutdown", "initiates", "graceful", "shutdown", "-", "waiting", "until", "all", "active", "connections", "will", "get", "closed" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/server.go#L277-L305
23,135
gravitational/teleport
lib/sshutils/server.go
validateHostSigner
func validateHostSigner(signer ssh.Signer) error { cert, ok := signer.PublicKey().(*ssh.Certificate) if !ok { return trace.BadParameter("only host certificates supported") } if len(cert.ValidPrincipals) == 0 { return trace.BadParameter("at least one valid principal is required in host certificate") } certChe...
go
func validateHostSigner(signer ssh.Signer) error { cert, ok := signer.PublicKey().(*ssh.Certificate) if !ok { return trace.BadParameter("only host certificates supported") } if len(cert.ValidPrincipals) == 0 { return trace.BadParameter("at least one valid principal is required in host certificate") } certChe...
[ "func", "validateHostSigner", "(", "signer", "ssh", ".", "Signer", ")", "error", "{", "cert", ",", "ok", ":=", "signer", ".", "PublicKey", "(", ")", ".", "(", "*", "ssh", ".", "Certificate", ")", "\n", "if", "!", "ok", "{", "return", "trace", ".", ...
// validateHostSigner make sure the signer is a valid certificate.
[ "validateHostSigner", "make", "sure", "the", "signer", "is", "a", "valid", "certificate", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/server.go#L506-L522
23,136
gravitational/teleport
lib/sshutils/server.go
KeysEqual
func KeysEqual(ak, bk ssh.PublicKey) bool { a := ssh.Marshal(ak) b := ssh.Marshal(bk) return (len(a) == len(b) && subtle.ConstantTimeCompare(a, b) == 1) }
go
func KeysEqual(ak, bk ssh.PublicKey) bool { a := ssh.Marshal(ak) b := ssh.Marshal(bk) return (len(a) == len(b) && subtle.ConstantTimeCompare(a, b) == 1) }
[ "func", "KeysEqual", "(", "ak", ",", "bk", "ssh", ".", "PublicKey", ")", "bool", "{", "a", ":=", "ssh", ".", "Marshal", "(", "ak", ")", "\n", "b", ":=", "ssh", ".", "Marshal", "(", "bk", ")", "\n", "return", "(", "len", "(", "a", ")", "==", "...
// KeysEqual is constant time compare of the keys to avoid timing attacks
[ "KeysEqual", "is", "constant", "time", "compare", "of", "the", "keys", "to", "avoid", "timing", "attacks" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/sshutils/server.go#L528-L532
23,137
gravitational/teleport
lib/backend/backend.go
String
func (w *Watch) String() string { return fmt.Sprintf("Watcher(name=%v, prefixes=%v)", w.Name, string(bytes.Join(w.Prefixes, []byte(", ")))) }
go
func (w *Watch) String() string { return fmt.Sprintf("Watcher(name=%v, prefixes=%v)", w.Name, string(bytes.Join(w.Prefixes, []byte(", ")))) }
[ "func", "(", "w", "*", "Watch", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "w", ".", "Name", ",", "string", "(", "bytes", ".", "Join", "(", "w", ".", "Prefixes", ",", "[", "]", "byte", "(", ...
// String returns a user-friendly description // of the watcher
[ "String", "returns", "a", "user", "-", "friendly", "description", "of", "the", "watcher" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L132-L134
23,138
gravitational/teleport
lib/backend/backend.go
GetString
func (p Params) GetString(key string) string { v, ok := p[key] if !ok { return "" } s, _ := v.(string) return s }
go
func (p Params) GetString(key string) string { v, ok := p[key] if !ok { return "" } s, _ := v.(string) return s }
[ "func", "(", "p", "Params", ")", "GetString", "(", "key", "string", ")", "string", "{", "v", ",", "ok", ":=", "p", "[", "key", "]", "\n", "if", "!", "ok", "{", "return", "\"", "\"", "\n", "}", "\n", "s", ",", "_", ":=", "v", ".", "(", "stri...
// GetString returns a string value stored in Params map, or an empty string // if nothing is found
[ "GetString", "returns", "a", "string", "value", "stored", "in", "Params", "map", "or", "an", "empty", "string", "if", "nothing", "is", "found" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L229-L236
23,139
gravitational/teleport
lib/backend/backend.go
RangeEnd
func RangeEnd(key []byte) []byte { end := make([]byte, len(key)) copy(end, key) for i := len(end) - 1; i >= 0; i-- { if end[i] < 0xff { end[i] = end[i] + 1 end = end[:i+1] return end } } // next key does not exist (e.g., 0xffff); return noEnd }
go
func RangeEnd(key []byte) []byte { end := make([]byte, len(key)) copy(end, key) for i := len(end) - 1; i >= 0; i-- { if end[i] < 0xff { end[i] = end[i] + 1 end = end[:i+1] return end } } // next key does not exist (e.g., 0xffff); return noEnd }
[ "func", "RangeEnd", "(", "key", "[", "]", "byte", ")", "[", "]", "byte", "{", "end", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "key", ")", ")", "\n", "copy", "(", "end", ",", "key", ")", "\n", "for", "i", ":=", "len", "(", "end"...
// RangeEnd returns end of the range for given key
[ "RangeEnd", "returns", "end", "of", "the", "range", "for", "given", "key" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L242-L254
23,140
gravitational/teleport
lib/backend/backend.go
TTL
func TTL(clock clockwork.Clock, expires time.Time) time.Duration { ttl := expires.Sub(clock.Now()) if ttl < time.Second { return time.Second } return ttl }
go
func TTL(clock clockwork.Clock, expires time.Time) time.Duration { ttl := expires.Sub(clock.Now()) if ttl < time.Second { return time.Second } return ttl }
[ "func", "TTL", "(", "clock", "clockwork", ".", "Clock", ",", "expires", "time", ".", "Time", ")", "time", ".", "Duration", "{", "ttl", ":=", "expires", ".", "Sub", "(", "clock", ".", "Now", "(", ")", ")", "\n", "if", "ttl", "<", "time", ".", "Sec...
// TTL returns TTL in duration units, rounds up to one second
[ "TTL", "returns", "TTL", "in", "duration", "units", "rounds", "up", "to", "one", "second" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L279-L285
23,141
gravitational/teleport
lib/backend/backend.go
EarliestExpiry
func EarliestExpiry(times ...time.Time) time.Time { if len(times) == 0 { return time.Time{} } sort.Sort(earliest(times)) return times[0] }
go
func EarliestExpiry(times ...time.Time) time.Time { if len(times) == 0 { return time.Time{} } sort.Sort(earliest(times)) return times[0] }
[ "func", "EarliestExpiry", "(", "times", "...", "time", ".", "Time", ")", "time", ".", "Time", "{", "if", "len", "(", "times", ")", "==", "0", "{", "return", "time", ".", "Time", "{", "}", "\n", "}", "\n", "sort", ".", "Sort", "(", "earliest", "("...
// EarliestExpiry returns first of the // otherwise returns empty
[ "EarliestExpiry", "returns", "first", "of", "the", "otherwise", "returns", "empty" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L289-L295
23,142
gravitational/teleport
lib/backend/backend.go
Expiry
func Expiry(clock clockwork.Clock, ttl time.Duration) time.Time { if ttl == 0 { return time.Time{} } return clock.Now().UTC().Add(ttl) }
go
func Expiry(clock clockwork.Clock, ttl time.Duration) time.Time { if ttl == 0 { return time.Time{} } return clock.Now().UTC().Add(ttl) }
[ "func", "Expiry", "(", "clock", "clockwork", ".", "Clock", ",", "ttl", "time", ".", "Duration", ")", "time", ".", "Time", "{", "if", "ttl", "==", "0", "{", "return", "time", ".", "Time", "{", "}", "\n", "}", "\n", "return", "clock", ".", "Now", "...
// Expiry converts ttl to expiry time, if ttl is 0 // returns empty time
[ "Expiry", "converts", "ttl", "to", "expiry", "time", "if", "ttl", "is", "0", "returns", "empty", "time" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/backend.go#L299-L304
23,143
gravitational/teleport
lib/utils/agentconn/agent_unix.go
Dial
func Dial(socket string) (net.Conn, error) { conn, err := net.Dial("unix", socket) if err != nil { return nil, trace.Wrap(err) } return conn, nil }
go
func Dial(socket string) (net.Conn, error) { conn, err := net.Dial("unix", socket) if err != nil { return nil, trace.Wrap(err) } return conn, nil }
[ "func", "Dial", "(", "socket", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "conn", ",", "err", ":=", "net", ".", "Dial", "(", "\"", "\"", ",", "socket", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "trace"...
// Dial creates net.Conn to a SSH agent listening on a Unix socket.
[ "Dial", "creates", "net", ".", "Conn", "to", "a", "SSH", "agent", "listening", "on", "a", "Unix", "socket", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/agentconn/agent_unix.go#L28-L35
23,144
gravitational/teleport
lib/services/authentication.go
NewAuthPreference
func NewAuthPreference(spec AuthPreferenceSpecV2) (AuthPreference, error) { return &AuthPreferenceV2{ Kind: KindClusterAuthPreference, Version: V2, Metadata: Metadata{ Name: MetaNameClusterAuthPreference, Namespace: defaults.Namespace, }, Spec: spec, }, nil }
go
func NewAuthPreference(spec AuthPreferenceSpecV2) (AuthPreference, error) { return &AuthPreferenceV2{ Kind: KindClusterAuthPreference, Version: V2, Metadata: Metadata{ Name: MetaNameClusterAuthPreference, Namespace: defaults.Namespace, }, Spec: spec, }, nil }
[ "func", "NewAuthPreference", "(", "spec", "AuthPreferenceSpecV2", ")", "(", "AuthPreference", ",", "error", ")", "{", "return", "&", "AuthPreferenceV2", "{", "Kind", ":", "KindClusterAuthPreference", ",", "Version", ":", "V2", ",", "Metadata", ":", "Metadata", "...
// NewAuthPreference is a convenience method to to create AuthPreferenceV2.
[ "NewAuthPreference", "is", "a", "convenience", "method", "to", "to", "create", "AuthPreferenceV2", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authentication.go#L77-L87
23,145
gravitational/teleport
lib/services/authentication.go
GetU2F
func (c *AuthPreferenceV2) GetU2F() (*U2F, error) { if c.Spec.U2F == nil { return nil, trace.NotFound("U2F configuration not found") } return c.Spec.U2F, nil }
go
func (c *AuthPreferenceV2) GetU2F() (*U2F, error) { if c.Spec.U2F == nil { return nil, trace.NotFound("U2F configuration not found") } return c.Spec.U2F, nil }
[ "func", "(", "c", "*", "AuthPreferenceV2", ")", "GetU2F", "(", ")", "(", "*", "U2F", ",", "error", ")", "{", "if", "c", ".", "Spec", ".", "U2F", "==", "nil", "{", "return", "nil", ",", "trace", ".", "NotFound", "(", "\"", "\"", ")", "\n", "}", ...
// GetU2F gets the U2F configuration settings.
[ "GetU2F", "gets", "the", "U2F", "configuration", "settings", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authentication.go#L175-L180
23,146
gravitational/teleport
lib/services/authentication.go
CheckAndSetDefaults
func (c *AuthPreferenceV2) CheckAndSetDefaults() error { // if nothing is passed in, set defaults if c.Spec.Type == "" { c.Spec.Type = teleport.Local } if c.Spec.SecondFactor == "" { c.Spec.SecondFactor = teleport.OTP } // make sure type makes sense switch c.Spec.Type { case teleport.Local, teleport.OIDC, ...
go
func (c *AuthPreferenceV2) CheckAndSetDefaults() error { // if nothing is passed in, set defaults if c.Spec.Type == "" { c.Spec.Type = teleport.Local } if c.Spec.SecondFactor == "" { c.Spec.SecondFactor = teleport.OTP } // make sure type makes sense switch c.Spec.Type { case teleport.Local, teleport.OIDC, ...
[ "func", "(", "c", "*", "AuthPreferenceV2", ")", "CheckAndSetDefaults", "(", ")", "error", "{", "// if nothing is passed in, set defaults", "if", "c", ".", "Spec", ".", "Type", "==", "\"", "\"", "{", "c", ".", "Spec", ".", "Type", "=", "teleport", ".", "Loc...
// CheckAndSetDefaults verifies the constraints for AuthPreference.
[ "CheckAndSetDefaults", "verifies", "the", "constraints", "for", "AuthPreference", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authentication.go#L188-L212
23,147
gravitational/teleport
lib/services/authentication.go
String
func (c *AuthPreferenceV2) String() string { return fmt.Sprintf("AuthPreference(Type=%q,SecondFactor=%q)", c.Spec.Type, c.Spec.SecondFactor) }
go
func (c *AuthPreferenceV2) String() string { return fmt.Sprintf("AuthPreference(Type=%q,SecondFactor=%q)", c.Spec.Type, c.Spec.SecondFactor) }
[ "func", "(", "c", "*", "AuthPreferenceV2", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "Spec", ".", "Type", ",", "c", ".", "Spec", ".", "SecondFactor", ")", "\n", "}" ]
// String represents a human readable version of authentication settings.
[ "String", "represents", "a", "human", "readable", "version", "of", "authentication", "settings", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authentication.go#L215-L217
23,148
gravitational/teleport
lib/services/authentication.go
GetAuthPreferenceSchema
func GetAuthPreferenceSchema(extensionSchema string) string { var authPreferenceSchema string if authPreferenceSchema == "" { authPreferenceSchema = fmt.Sprintf(AuthPreferenceSpecSchemaTemplate, "") } else { authPreferenceSchema = fmt.Sprintf(AuthPreferenceSpecSchemaTemplate, ","+extensionSchema) } return fmt....
go
func GetAuthPreferenceSchema(extensionSchema string) string { var authPreferenceSchema string if authPreferenceSchema == "" { authPreferenceSchema = fmt.Sprintf(AuthPreferenceSpecSchemaTemplate, "") } else { authPreferenceSchema = fmt.Sprintf(AuthPreferenceSpecSchemaTemplate, ","+extensionSchema) } return fmt....
[ "func", "GetAuthPreferenceSchema", "(", "extensionSchema", "string", ")", "string", "{", "var", "authPreferenceSchema", "string", "\n", "if", "authPreferenceSchema", "==", "\"", "\"", "{", "authPreferenceSchema", "=", "fmt", ".", "Sprintf", "(", "AuthPreferenceSpecSch...
// GetAuthPreferenceSchema returns the schema with optionally injected // schema for extensions.
[ "GetAuthPreferenceSchema", "returns", "the", "schema", "with", "optionally", "injected", "schema", "for", "extensions", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authentication.go#L277-L285
23,149
gravitational/teleport
lib/srv/regular/proxy.go
proxyToSite
func (t *proxySubsys) proxyToSite( ctx *srv.ServerContext, site reversetunnel.RemoteSite, remoteAddr net.Addr, ch ssh.Channel) error { conn, err := site.DialAuthServer() if err != nil { return trace.Wrap(err) } t.log.Infof("Connected to auth server: %v", conn.RemoteAddr()) go func() { var err error defer ...
go
func (t *proxySubsys) proxyToSite( ctx *srv.ServerContext, site reversetunnel.RemoteSite, remoteAddr net.Addr, ch ssh.Channel) error { conn, err := site.DialAuthServer() if err != nil { return trace.Wrap(err) } t.log.Infof("Connected to auth server: %v", conn.RemoteAddr()) go func() { var err error defer ...
[ "func", "(", "t", "*", "proxySubsys", ")", "proxyToSite", "(", "ctx", "*", "srv", ".", "ServerContext", ",", "site", "reversetunnel", ".", "RemoteSite", ",", "remoteAddr", "net", ".", "Addr", ",", "ch", "ssh", ".", "Channel", ")", "error", "{", "conn", ...
// proxyToSite establishes a proxy connection from the connected SSH client to the // auth server of the requested remote site
[ "proxyToSite", "establishes", "a", "proxy", "connection", "from", "the", "connected", "SSH", "client", "to", "the", "auth", "server", "of", "the", "requested", "remote", "site" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/regular/proxy.go#L198-L226
23,150
gravitational/teleport
lib/utils/tls.go
ListenTLS
func ListenTLS(address string, certFile, keyFile string, cipherSuites []uint16) (net.Listener, error) { tlsConfig, err := CreateTLSConfiguration(certFile, keyFile, cipherSuites) if err != nil { return nil, trace.Wrap(err) } return tls.Listen("tcp", address, tlsConfig) }
go
func ListenTLS(address string, certFile, keyFile string, cipherSuites []uint16) (net.Listener, error) { tlsConfig, err := CreateTLSConfiguration(certFile, keyFile, cipherSuites) if err != nil { return nil, trace.Wrap(err) } return tls.Listen("tcp", address, tlsConfig) }
[ "func", "ListenTLS", "(", "address", "string", ",", "certFile", ",", "keyFile", "string", ",", "cipherSuites", "[", "]", "uint16", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "tlsConfig", ",", "err", ":=", "CreateTLSConfiguration", "(", "cert...
// ListenTLS sets up TLS listener for the http handler, starts listening // on a TCP socket and returns the socket which is ready to be used // for http.Serve
[ "ListenTLS", "sets", "up", "TLS", "listener", "for", "the", "http", "handler", "starts", "listening", "on", "a", "TCP", "socket", "and", "returns", "the", "socket", "which", "is", "ready", "to", "be", "used", "for", "http", ".", "Serve" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/tls.go#L41-L47
23,151
gravitational/teleport
lib/utils/tls.go
TLSConfig
func TLSConfig(cipherSuites []uint16) *tls.Config { config := &tls.Config{} // If ciphers suites were passed in, use them. Otherwise use the the // Go defaults. if len(cipherSuites) > 0 { config.CipherSuites = cipherSuites } // Pick the servers preferred ciphersuite, not the clients. config.PreferServerCiphe...
go
func TLSConfig(cipherSuites []uint16) *tls.Config { config := &tls.Config{} // If ciphers suites were passed in, use them. Otherwise use the the // Go defaults. if len(cipherSuites) > 0 { config.CipherSuites = cipherSuites } // Pick the servers preferred ciphersuite, not the clients. config.PreferServerCiphe...
[ "func", "TLSConfig", "(", "cipherSuites", "[", "]", "uint16", ")", "*", "tls", ".", "Config", "{", "config", ":=", "&", "tls", ".", "Config", "{", "}", "\n\n", "// If ciphers suites were passed in, use them. Otherwise use the the", "// Go defaults.", "if", "len", ...
// TLSConfig returns default TLS configuration strong defaults.
[ "TLSConfig", "returns", "default", "TLS", "configuration", "strong", "defaults", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/tls.go#L50-L67
23,152
gravitational/teleport
lib/utils/tls.go
CreateTLSConfiguration
func CreateTLSConfiguration(certFile, keyFile string, cipherSuites []uint16) (*tls.Config, error) { config := TLSConfig(cipherSuites) if _, err := os.Stat(certFile); err != nil { return nil, trace.BadParameter("certificate is not accessible by '%v'", certFile) } if _, err := os.Stat(keyFile); err != nil { retu...
go
func CreateTLSConfiguration(certFile, keyFile string, cipherSuites []uint16) (*tls.Config, error) { config := TLSConfig(cipherSuites) if _, err := os.Stat(certFile); err != nil { return nil, trace.BadParameter("certificate is not accessible by '%v'", certFile) } if _, err := os.Stat(keyFile); err != nil { retu...
[ "func", "CreateTLSConfiguration", "(", "certFile", ",", "keyFile", "string", ",", "cipherSuites", "[", "]", "uint16", ")", "(", "*", "tls", ".", "Config", ",", "error", ")", "{", "config", ":=", "TLSConfig", "(", "cipherSuites", ")", "\n\n", "if", "_", "...
// CreateTLSConfiguration sets up default TLS configuration
[ "CreateTLSConfiguration", "sets", "up", "default", "TLS", "configuration" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/tls.go#L70-L87
23,153
gravitational/teleport
lib/utils/tls.go
GenerateSelfSignedCert
func GenerateSelfSignedCert(hostNames []string) (*TLSCredentials, error) { priv, err := rsa.GenerateKey(rand.Reader, teleport.RSAKeySize) if err != nil { return nil, trace.Wrap(err) } notBefore := time.Now() notAfter := notBefore.Add(time.Hour * 24 * 365 * 10) // 10 years serialNumberLimit := new(big.Int).Lsh(...
go
func GenerateSelfSignedCert(hostNames []string) (*TLSCredentials, error) { priv, err := rsa.GenerateKey(rand.Reader, teleport.RSAKeySize) if err != nil { return nil, trace.Wrap(err) } notBefore := time.Now() notAfter := notBefore.Add(time.Hour * 24 * 365 * 10) // 10 years serialNumberLimit := new(big.Int).Lsh(...
[ "func", "GenerateSelfSignedCert", "(", "hostNames", "[", "]", "string", ")", "(", "*", "TLSCredentials", ",", "error", ")", "{", "priv", ",", "err", ":=", "rsa", ".", "GenerateKey", "(", "rand", ".", "Reader", ",", "teleport", ".", "RSAKeySize", ")", "\n...
// GenerateSelfSignedCert generates a self signed certificate that // is valid for given domain names and ips, returns PEM-encoded bytes with key and cert
[ "GenerateSelfSignedCert", "generates", "a", "self", "signed", "certificate", "that", "is", "valid", "for", "given", "domain", "names", "and", "ips", "returns", "PEM", "-", "encoded", "bytes", "with", "key", "and", "cert" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/tls.go#L100-L153
23,154
gravitational/teleport
lib/utils/tls.go
CipherSuiteMapping
func CipherSuiteMapping(cipherSuites []string) ([]uint16, error) { out := make([]uint16, 0, len(cipherSuites)) for _, cs := range cipherSuites { c, ok := cipherSuiteMapping[cs] if !ok { return nil, trace.BadParameter("cipher suite not supported: %v", cs) } out = append(out, c) } return out, nil }
go
func CipherSuiteMapping(cipherSuites []string) ([]uint16, error) { out := make([]uint16, 0, len(cipherSuites)) for _, cs := range cipherSuites { c, ok := cipherSuiteMapping[cs] if !ok { return nil, trace.BadParameter("cipher suite not supported: %v", cs) } out = append(out, c) } return out, nil }
[ "func", "CipherSuiteMapping", "(", "cipherSuites", "[", "]", "string", ")", "(", "[", "]", "uint16", ",", "error", ")", "{", "out", ":=", "make", "(", "[", "]", "uint16", ",", "0", ",", "len", "(", "cipherSuites", ")", ")", "\n\n", "for", "_", ",",...
// CipherSuiteMapping transforms Teleport formatted cipher suites strings // into uint16 IDs.
[ "CipherSuiteMapping", "transforms", "Teleport", "formatted", "cipher", "suites", "strings", "into", "uint16", "IDs", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/tls.go#L157-L170
23,155
gravitational/teleport
lib/srv/term.go
NewTerminal
func NewTerminal(ctx *ServerContext) (Terminal, error) { // It doesn't matter what mode the cluster is in, if this is a Teleport node // return a local terminal. if ctx.srv.Component() == teleport.ComponentNode { return newLocalTerminal(ctx) } // If this is not a Teleport node, find out what mode the cluster is...
go
func NewTerminal(ctx *ServerContext) (Terminal, error) { // It doesn't matter what mode the cluster is in, if this is a Teleport node // return a local terminal. if ctx.srv.Component() == teleport.ComponentNode { return newLocalTerminal(ctx) } // If this is not a Teleport node, find out what mode the cluster is...
[ "func", "NewTerminal", "(", "ctx", "*", "ServerContext", ")", "(", "Terminal", ",", "error", ")", "{", "// It doesn't matter what mode the cluster is in, if this is a Teleport node", "// return a local terminal.", "if", "ctx", ".", "srv", ".", "Component", "(", ")", "==...
// NewTerminal returns a new terminal. Terminal can be local or remote // depending on cluster configuration.
[ "NewTerminal", "returns", "a", "new", "terminal", ".", "Terminal", "can", "be", "local", "or", "remote", "depending", "on", "cluster", "configuration", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L95-L108
23,156
gravitational/teleport
lib/srv/term.go
newLocalTerminal
func newLocalTerminal(ctx *ServerContext) (*terminal, error) { var err error t := &terminal{ log: log.WithFields(log.Fields{ trace.Component: teleport.ComponentLocalTerm, }), ctx: ctx, } // Open PTY and corresponding TTY. t.pty, t.tty, err = pty.Open() if err != nil { log.Warnf("Could not start PTY %...
go
func newLocalTerminal(ctx *ServerContext) (*terminal, error) { var err error t := &terminal{ log: log.WithFields(log.Fields{ trace.Component: teleport.ComponentLocalTerm, }), ctx: ctx, } // Open PTY and corresponding TTY. t.pty, t.tty, err = pty.Open() if err != nil { log.Warnf("Could not start PTY %...
[ "func", "newLocalTerminal", "(", "ctx", "*", "ServerContext", ")", "(", "*", "terminal", ",", "error", ")", "{", "var", "err", "error", "\n\n", "t", ":=", "&", "terminal", "{", "log", ":", "log", ".", "WithFields", "(", "log", ".", "Fields", "{", "tr...
// NewLocalTerminal creates and returns a local PTY.
[ "NewLocalTerminal", "creates", "and", "returns", "a", "local", "PTY", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L128-L153
23,157
gravitational/teleport
lib/srv/term.go
Run
func (t *terminal) Run() error { defer t.closeTTY() cmd, err := prepareInteractiveCommand(t.ctx) if err != nil { return trace.Wrap(err) } t.cmd = cmd cmd.Stdout = t.tty cmd.Stdin = t.tty cmd.Stderr = t.tty cmd.SysProcAttr.Setctty = true cmd.SysProcAttr.Setsid = true err = cmd.Start() if err != nil { ...
go
func (t *terminal) Run() error { defer t.closeTTY() cmd, err := prepareInteractiveCommand(t.ctx) if err != nil { return trace.Wrap(err) } t.cmd = cmd cmd.Stdout = t.tty cmd.Stdin = t.tty cmd.Stderr = t.tty cmd.SysProcAttr.Setctty = true cmd.SysProcAttr.Setsid = true err = cmd.Start() if err != nil { ...
[ "func", "(", "t", "*", "terminal", ")", "Run", "(", ")", "error", "{", "defer", "t", ".", "closeTTY", "(", ")", "\n\n", "cmd", ",", "err", ":=", "prepareInteractiveCommand", "(", "t", ".", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Run will run the terminal.
[ "Run", "will", "run", "the", "terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L162-L183
23,158
gravitational/teleport
lib/srv/term.go
Wait
func (t *terminal) Wait() (*ExecResult, error) { err := t.cmd.Wait() if err != nil { if exitErr, ok := err.(*exec.ExitError); ok { status := exitErr.Sys().(syscall.WaitStatus) return &ExecResult{Code: status.ExitStatus(), Command: t.cmd.Path}, nil } return nil, err } status, ok := t.cmd.ProcessState.Sy...
go
func (t *terminal) Wait() (*ExecResult, error) { err := t.cmd.Wait() if err != nil { if exitErr, ok := err.(*exec.ExitError); ok { status := exitErr.Sys().(syscall.WaitStatus) return &ExecResult{Code: status.ExitStatus(), Command: t.cmd.Path}, nil } return nil, err } status, ok := t.cmd.ProcessState.Sy...
[ "func", "(", "t", "*", "terminal", ")", "Wait", "(", ")", "(", "*", "ExecResult", ",", "error", ")", "{", "err", ":=", "t", ".", "cmd", ".", "Wait", "(", ")", "\n", "if", "err", "!=", "nil", "{", "if", "exitErr", ",", "ok", ":=", "err", ".", ...
// Wait will block until the terminal is complete.
[ "Wait", "will", "block", "until", "the", "terminal", "is", "complete", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L186-L205
23,159
gravitational/teleport
lib/srv/term.go
Kill
func (t *terminal) Kill() error { if t.cmd.Process != nil { if err := t.cmd.Process.Kill(); err != nil { if err.Error() != "os: process already finished" { return trace.Wrap(err) } } } return nil }
go
func (t *terminal) Kill() error { if t.cmd.Process != nil { if err := t.cmd.Process.Kill(); err != nil { if err.Error() != "os: process already finished" { return trace.Wrap(err) } } } return nil }
[ "func", "(", "t", "*", "terminal", ")", "Kill", "(", ")", "error", "{", "if", "t", ".", "cmd", ".", "Process", "!=", "nil", "{", "if", "err", ":=", "t", ".", "cmd", ".", "Process", ".", "Kill", "(", ")", ";", "err", "!=", "nil", "{", "if", ...
// Kill will force kill the terminal.
[ "Kill", "will", "force", "kill", "the", "terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L208-L218
23,160
gravitational/teleport
lib/srv/term.go
Close
func (t *terminal) Close() error { var err error // note, pty is closed in the copying goroutine, // not here to avoid data races if t.tty != nil { if e := t.tty.Close(); e != nil { err = e } } go t.closePTY() return trace.Wrap(err) }
go
func (t *terminal) Close() error { var err error // note, pty is closed in the copying goroutine, // not here to avoid data races if t.tty != nil { if e := t.tty.Close(); e != nil { err = e } } go t.closePTY() return trace.Wrap(err) }
[ "func", "(", "t", "*", "terminal", ")", "Close", "(", ")", "error", "{", "var", "err", "error", "\n", "// note, pty is closed in the copying goroutine,", "// not here to avoid data races", "if", "t", ".", "tty", "!=", "nil", "{", "if", "e", ":=", "t", ".", "...
// Close will free resources associated with the terminal.
[ "Close", "will", "free", "resources", "associated", "with", "the", "terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L231-L242
23,161
gravitational/teleport
lib/srv/term.go
GetWinSize
func (t *terminal) GetWinSize() (*term.Winsize, error) { t.mu.Lock() defer t.mu.Unlock() if t.pty == nil { return nil, trace.NotFound("no pty") } ws, err := term.GetWinsize(t.pty.Fd()) if err != nil { return nil, trace.Wrap(err) } return ws, nil }
go
func (t *terminal) GetWinSize() (*term.Winsize, error) { t.mu.Lock() defer t.mu.Unlock() if t.pty == nil { return nil, trace.NotFound("no pty") } ws, err := term.GetWinsize(t.pty.Fd()) if err != nil { return nil, trace.Wrap(err) } return ws, nil }
[ "func", "(", "t", "*", "terminal", ")", "GetWinSize", "(", ")", "(", "*", "term", ".", "Winsize", ",", "error", ")", "{", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "t", ".", "...
// GetWinSize returns the window size of the terminal.
[ "GetWinSize", "returns", "the", "window", "size", "of", "the", "terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L264-L275
23,162
gravitational/teleport
lib/srv/term.go
SetWinSize
func (t *terminal) SetWinSize(params rsession.TerminalParams) error { t.mu.Lock() defer t.mu.Unlock() if t.pty == nil { return trace.NotFound("no pty") } if err := term.SetWinsize(t.pty.Fd(), params.Winsize()); err != nil { return trace.Wrap(err) } t.params = params return nil }
go
func (t *terminal) SetWinSize(params rsession.TerminalParams) error { t.mu.Lock() defer t.mu.Unlock() if t.pty == nil { return trace.NotFound("no pty") } if err := term.SetWinsize(t.pty.Fd(), params.Winsize()); err != nil { return trace.Wrap(err) } t.params = params return nil }
[ "func", "(", "t", "*", "terminal", ")", "SetWinSize", "(", "params", "rsession", ".", "TerminalParams", ")", "error", "{", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "t", ".", "pty",...
// SetWinSize sets the window size of the terminal.
[ "SetWinSize", "sets", "the", "window", "size", "of", "the", "terminal", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L278-L289
23,163
gravitational/teleport
lib/srv/term.go
GetTerminalParams
func (t *terminal) GetTerminalParams() rsession.TerminalParams { t.mu.Lock() defer t.mu.Unlock() return t.params }
go
func (t *terminal) GetTerminalParams() rsession.TerminalParams { t.mu.Lock() defer t.mu.Unlock() return t.params }
[ "func", "(", "t", "*", "terminal", ")", "GetTerminalParams", "(", ")", "rsession", ".", "TerminalParams", "{", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "t", ".", "params", "\n", ...
// GetTerminalParams is a fast call to get cached terminal parameters // and avoid extra system call.
[ "GetTerminalParams", "is", "a", "fast", "call", "to", "get", "cached", "terminal", "parameters", "and", "avoid", "extra", "system", "call", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L293-L297
23,164
gravitational/teleport
lib/srv/term.go
SetTermType
func (t *terminal) SetTermType(term string) { if term == "" { term = defaultTerm } t.termType = term }
go
func (t *terminal) SetTermType(term string) { if term == "" { term = defaultTerm } t.termType = term }
[ "func", "(", "t", "*", "terminal", ")", "SetTermType", "(", "term", "string", ")", "{", "if", "term", "==", "\"", "\"", "{", "term", "=", "defaultTerm", "\n", "}", "\n", "t", ".", "termType", "=", "term", "\n", "}" ]
// SetTermType sets the terminal type from "req-pty" request.
[ "SetTermType", "sets", "the", "terminal", "type", "from", "req", "-", "pty", "request", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L305-L310
23,165
gravitational/teleport
lib/srv/term.go
setOwner
func (t *terminal) setOwner() error { uid, gid, mode, err := getOwner(t.ctx.Identity.Login, user.Lookup, user.LookupGroup) if err != nil { return trace.Wrap(err) } err = os.Chown(t.tty.Name(), uid, gid) if err != nil { return trace.Wrap(err) } err = os.Chmod(t.tty.Name(), mode) if err != nil { return tra...
go
func (t *terminal) setOwner() error { uid, gid, mode, err := getOwner(t.ctx.Identity.Login, user.Lookup, user.LookupGroup) if err != nil { return trace.Wrap(err) } err = os.Chown(t.tty.Name(), uid, gid) if err != nil { return trace.Wrap(err) } err = os.Chmod(t.tty.Name(), mode) if err != nil { return tra...
[ "func", "(", "t", "*", "terminal", ")", "setOwner", "(", ")", "error", "{", "uid", ",", "gid", ",", "mode", ",", "err", ":=", "getOwner", "(", "t", ".", "ctx", ".", "Identity", ".", "Login", ",", "user", ".", "Lookup", ",", "user", ".", "LookupGr...
// setOwner changes the owner and mode of the TTY.
[ "setOwner", "changes", "the", "owner", "and", "mode", "of", "the", "TTY", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L355-L373
23,166
gravitational/teleport
lib/srv/term.go
prepareRemoteSession
func (t *remoteTerminal) prepareRemoteSession(session *ssh.Session, ctx *ServerContext) { envs := map[string]string{ teleport.SSHTeleportUser: ctx.Identity.TeleportUser, teleport.SSHSessionWebproxyAddr: ctx.ProxyPublicAddress(), teleport.SSHTeleportHostUUID: ctx.srv.ID(), teleport.SSHTeleportClusterN...
go
func (t *remoteTerminal) prepareRemoteSession(session *ssh.Session, ctx *ServerContext) { envs := map[string]string{ teleport.SSHTeleportUser: ctx.Identity.TeleportUser, teleport.SSHSessionWebproxyAddr: ctx.ProxyPublicAddress(), teleport.SSHTeleportHostUUID: ctx.srv.ID(), teleport.SSHTeleportClusterN...
[ "func", "(", "t", "*", "remoteTerminal", ")", "prepareRemoteSession", "(", "session", "*", "ssh", ".", "Session", ",", "ctx", "*", "ServerContext", ")", "{", "envs", ":=", "map", "[", "string", "]", "string", "{", "teleport", ".", "SSHTeleportUser", ":", ...
// prepareRemoteSession prepares the more session for execution.
[ "prepareRemoteSession", "prepares", "the", "more", "session", "for", "execution", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/term.go#L586-L600
23,167
gravitational/teleport
lib/auth/auth.go
NewAuthServer
func NewAuthServer(cfg *InitConfig, opts ...AuthServerOption) (*AuthServer, error) { if cfg.Trust == nil { cfg.Trust = local.NewCAService(cfg.Backend) } if cfg.Presence == nil { cfg.Presence = local.NewPresenceService(cfg.Backend) } if cfg.Provisioner == nil { cfg.Provisioner = local.NewProvisioningService(c...
go
func NewAuthServer(cfg *InitConfig, opts ...AuthServerOption) (*AuthServer, error) { if cfg.Trust == nil { cfg.Trust = local.NewCAService(cfg.Backend) } if cfg.Presence == nil { cfg.Presence = local.NewPresenceService(cfg.Backend) } if cfg.Provisioner == nil { cfg.Provisioner = local.NewProvisioningService(c...
[ "func", "NewAuthServer", "(", "cfg", "*", "InitConfig", ",", "opts", "...", "AuthServerOption", ")", "(", "*", "AuthServer", ",", "error", ")", "{", "if", "cfg", ".", "Trust", "==", "nil", "{", "cfg", ".", "Trust", "=", "local", ".", "NewCAService", "(...
// NewAuthServer creates and configures a new AuthServer instance
[ "NewAuthServer", "creates", "and", "configures", "a", "new", "AuthServer", "instance" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L62-L125
23,168
gravitational/teleport
lib/auth/auth.go
SetCache
func (a *AuthServer) SetCache(clt AuthCache) { a.lock.Lock() defer a.lock.Unlock() a.cache = clt }
go
func (a *AuthServer) SetCache(clt AuthCache) { a.lock.Lock() defer a.lock.Unlock() a.cache = clt }
[ "func", "(", "a", "*", "AuthServer", ")", "SetCache", "(", "clt", "AuthCache", ")", "{", "a", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "lock", ".", "Unlock", "(", ")", "\n", "a", ".", "cache", "=", "clt", "\n", "}" ]
// SetCache sets cache used by auth server
[ "SetCache", "sets", "cache", "used", "by", "auth", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L212-L216
23,169
gravitational/teleport
lib/auth/auth.go
GetCache
func (a *AuthServer) GetCache() AuthCache { a.lock.RLock() defer a.lock.RUnlock() if a.cache == nil { return &a.AuthServices } return a.cache }
go
func (a *AuthServer) GetCache() AuthCache { a.lock.RLock() defer a.lock.RUnlock() if a.cache == nil { return &a.AuthServices } return a.cache }
[ "func", "(", "a", "*", "AuthServer", ")", "GetCache", "(", ")", "AuthCache", "{", "a", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "a", ".", "lock", ".", "RUnlock", "(", ")", "\n", "if", "a", ".", "cache", "==", "nil", "{", "return", "&...
// GetCache returns cache used by auth server
[ "GetCache", "returns", "cache", "used", "by", "auth", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L219-L226
23,170
gravitational/teleport
lib/auth/auth.go
runPeriodicOperations
func (a *AuthServer) runPeriodicOperations() { // run periodic functions with a semi-random period // to avoid contention on the database in case if there are multiple // auth servers running - so they don't compete trying // to update the same resources. r := rand.New(rand.NewSource(a.GetClock().Now().UnixNano())...
go
func (a *AuthServer) runPeriodicOperations() { // run periodic functions with a semi-random period // to avoid contention on the database in case if there are multiple // auth servers running - so they don't compete trying // to update the same resources. r := rand.New(rand.NewSource(a.GetClock().Now().UnixNano())...
[ "func", "(", "a", "*", "AuthServer", ")", "runPeriodicOperations", "(", ")", "{", "// run periodic functions with a semi-random period", "// to avoid contention on the database in case if there are multiple", "// auth servers running - so they don't compete trying", "// to update the same ...
// runPeriodicOperations runs some periodic bookkeeping operations // performed by auth server
[ "runPeriodicOperations", "runs", "some", "periodic", "bookkeeping", "operations", "performed", "by", "auth", "server" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L230-L255
23,171
gravitational/teleport
lib/auth/auth.go
SetClock
func (a *AuthServer) SetClock(clock clockwork.Clock) { a.lock.Lock() defer a.lock.Unlock() a.clock = clock }
go
func (a *AuthServer) SetClock(clock clockwork.Clock) { a.lock.Lock() defer a.lock.Unlock() a.clock = clock }
[ "func", "(", "a", "*", "AuthServer", ")", "SetClock", "(", "clock", "clockwork", ".", "Clock", ")", "{", "a", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "lock", ".", "Unlock", "(", ")", "\n", "a", ".", "clock", "=", "clock", "...
// SetClock sets clock, used in tests
[ "SetClock", "sets", "clock", "used", "in", "tests" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L272-L276
23,172
gravitational/teleport
lib/auth/auth.go
GetClusterConfig
func (a *AuthServer) GetClusterConfig(opts ...services.MarshalOption) (services.ClusterConfig, error) { return a.GetCache().GetClusterConfig(opts...) }
go
func (a *AuthServer) GetClusterConfig(opts ...services.MarshalOption) (services.ClusterConfig, error) { return a.GetCache().GetClusterConfig(opts...) }
[ "func", "(", "a", "*", "AuthServer", ")", "GetClusterConfig", "(", "opts", "...", "services", ".", "MarshalOption", ")", "(", "services", ".", "ClusterConfig", ",", "error", ")", "{", "return", "a", ".", "GetCache", "(", ")", ".", "GetClusterConfig", "(", ...
// GetClusterConfig gets ClusterConfig from the backend.
[ "GetClusterConfig", "gets", "ClusterConfig", "from", "the", "backend", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L284-L286
23,173
gravitational/teleport
lib/auth/auth.go
GetClusterName
func (a *AuthServer) GetClusterName(opts ...services.MarshalOption) (services.ClusterName, error) { return a.GetCache().GetClusterName(opts...) }
go
func (a *AuthServer) GetClusterName(opts ...services.MarshalOption) (services.ClusterName, error) { return a.GetCache().GetClusterName(opts...) }
[ "func", "(", "a", "*", "AuthServer", ")", "GetClusterName", "(", "opts", "...", "services", ".", "MarshalOption", ")", "(", "services", ".", "ClusterName", ",", "error", ")", "{", "return", "a", ".", "GetCache", "(", ")", ".", "GetClusterName", "(", "opt...
// GetClusterName returns the domain name that identifies this authority server. // Also known as "cluster name"
[ "GetClusterName", "returns", "the", "domain", "name", "that", "identifies", "this", "authority", "server", ".", "Also", "known", "as", "cluster", "name" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L290-L292
23,174
gravitational/teleport
lib/auth/auth.go
GetDomainName
func (a *AuthServer) GetDomainName() (string, error) { clusterName, err := a.GetClusterName() if err != nil { return "", trace.Wrap(err) } return clusterName.GetClusterName(), nil }
go
func (a *AuthServer) GetDomainName() (string, error) { clusterName, err := a.GetClusterName() if err != nil { return "", trace.Wrap(err) } return clusterName.GetClusterName(), nil }
[ "func", "(", "a", "*", "AuthServer", ")", "GetDomainName", "(", ")", "(", "string", ",", "error", ")", "{", "clusterName", ",", "err", ":=", "a", ".", "GetClusterName", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "trac...
// GetDomainName returns the domain name that identifies this authority server. // Also known as "cluster name"
[ "GetDomainName", "returns", "the", "domain", "name", "that", "identifies", "this", "authority", "server", ".", "Also", "known", "as", "cluster", "name" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L296-L302
23,175
gravitational/teleport
lib/auth/auth.go
GenerateUserCerts
func (a *AuthServer) GenerateUserCerts(key []byte, username string, ttl time.Duration, compatibility string) ([]byte, []byte, error) { user, err := a.Identity.GetUser(username) if err != nil { return nil, nil, trace.Wrap(err) } checker, err := services.FetchRoles(user.GetRoles(), a.Access, user.GetTraits()) if e...
go
func (a *AuthServer) GenerateUserCerts(key []byte, username string, ttl time.Duration, compatibility string) ([]byte, []byte, error) { user, err := a.Identity.GetUser(username) if err != nil { return nil, nil, trace.Wrap(err) } checker, err := services.FetchRoles(user.GetRoles(), a.Access, user.GetTraits()) if e...
[ "func", "(", "a", "*", "AuthServer", ")", "GenerateUserCerts", "(", "key", "[", "]", "byte", ",", "username", "string", ",", "ttl", "time", ".", "Duration", ",", "compatibility", "string", ")", "(", "[", "]", "byte", ",", "[", "]", "byte", ",", "erro...
// GenerateUserCerts is used to generate user certificate, used internally for tests
[ "GenerateUserCerts", "is", "used", "to", "generate", "user", "certificate", "used", "internally", "for", "tests" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L407-L427
23,176
gravitational/teleport
lib/auth/auth.go
WithUserLock
func (s *AuthServer) WithUserLock(username string, authenticateFn func() error) error { user, err := s.Identity.GetUser(username) if err != nil { return trace.Wrap(err) } status := user.GetStatus() if status.IsLocked && status.LockExpires.After(s.clock.Now().UTC()) { return trace.AccessDenied("%v exceeds %v fa...
go
func (s *AuthServer) WithUserLock(username string, authenticateFn func() error) error { user, err := s.Identity.GetUser(username) if err != nil { return trace.Wrap(err) } status := user.GetStatus() if status.IsLocked && status.LockExpires.After(s.clock.Now().UTC()) { return trace.AccessDenied("%v exceeds %v fa...
[ "func", "(", "s", "*", "AuthServer", ")", "WithUserLock", "(", "username", "string", ",", "authenticateFn", "func", "(", ")", "error", ")", "error", "{", "user", ",", "err", ":=", "s", ".", "Identity", ".", "GetUser", "(", "username", ")", "\n", "if", ...
// WithUserLock executes function authenticateFn that performs user authentication // if authenticateFn returns non nil error, the login attempt will be logged in as failed. // The only exception to this rule is ConnectionProblemError, in case if it occurs // access will be denied, but login attempt will not be recorde...
[ "WithUserLock", "executes", "function", "authenticateFn", "that", "performs", "user", "authentication", "if", "authenticateFn", "returns", "non", "nil", "error", "the", "login", "attempt", "will", "be", "logged", "in", "as", "failed", ".", "The", "only", "exceptio...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L543-L594
23,177
gravitational/teleport
lib/auth/auth.go
PreAuthenticatedSignIn
func (s *AuthServer) PreAuthenticatedSignIn(user string) (services.WebSession, error) { sess, err := s.NewWebSession(user) if err != nil { return nil, trace.Wrap(err) } if err := s.UpsertWebSession(user, sess); err != nil { return nil, trace.Wrap(err) } return sess.WithoutSecrets(), nil }
go
func (s *AuthServer) PreAuthenticatedSignIn(user string) (services.WebSession, error) { sess, err := s.NewWebSession(user) if err != nil { return nil, trace.Wrap(err) } if err := s.UpsertWebSession(user, sess); err != nil { return nil, trace.Wrap(err) } return sess.WithoutSecrets(), nil }
[ "func", "(", "s", "*", "AuthServer", ")", "PreAuthenticatedSignIn", "(", "user", "string", ")", "(", "services", ".", "WebSession", ",", "error", ")", "{", "sess", ",", "err", ":=", "s", ".", "NewWebSession", "(", "user", ")", "\n", "if", "err", "!=", ...
// PreAuthenticatedSignIn is for 2-way authentication methods like U2F where the password is // already checked before issuing the second factor challenge
[ "PreAuthenticatedSignIn", "is", "for", "2", "-", "way", "authentication", "methods", "like", "U2F", "where", "the", "password", "is", "already", "checked", "before", "issuing", "the", "second", "factor", "challenge" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L598-L607
23,178
gravitational/teleport
lib/auth/auth.go
ExtendWebSession
func (s *AuthServer) ExtendWebSession(user string, prevSessionID string) (services.WebSession, error) { prevSession, err := s.GetWebSession(user, prevSessionID) if err != nil { return nil, trace.Wrap(err) } // consider absolute expiry time that may be set for this session // by some external identity serivce, s...
go
func (s *AuthServer) ExtendWebSession(user string, prevSessionID string) (services.WebSession, error) { prevSession, err := s.GetWebSession(user, prevSessionID) if err != nil { return nil, trace.Wrap(err) } // consider absolute expiry time that may be set for this session // by some external identity serivce, s...
[ "func", "(", "s", "*", "AuthServer", ")", "ExtendWebSession", "(", "user", "string", ",", "prevSessionID", "string", ")", "(", "services", ".", "WebSession", ",", "error", ")", "{", "prevSession", ",", "err", ":=", "s", ".", "GetWebSession", "(", "user", ...
// ExtendWebSession creates a new web session for a user based on a valid previous sessionID, // method is used to renew the web session for a user
[ "ExtendWebSession", "creates", "a", "new", "web", "session", "for", "a", "user", "based", "on", "a", "valid", "previous", "sessionID", "method", "is", "used", "to", "renew", "the", "web", "session", "for", "a", "user" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L686-L715
23,179
gravitational/teleport
lib/auth/auth.go
CreateWebSession
func (s *AuthServer) CreateWebSession(user string) (services.WebSession, error) { sess, err := s.NewWebSession(user) if err != nil { return nil, trace.Wrap(err) } if err := s.UpsertWebSession(user, sess); err != nil { return nil, trace.Wrap(err) } sess, err = services.GetWebSessionMarshaler().GenerateWebSessi...
go
func (s *AuthServer) CreateWebSession(user string) (services.WebSession, error) { sess, err := s.NewWebSession(user) if err != nil { return nil, trace.Wrap(err) } if err := s.UpsertWebSession(user, sess); err != nil { return nil, trace.Wrap(err) } sess, err = services.GetWebSessionMarshaler().GenerateWebSessi...
[ "func", "(", "s", "*", "AuthServer", ")", "CreateWebSession", "(", "user", "string", ")", "(", "services", ".", "WebSession", ",", "error", ")", "{", "sess", ",", "err", ":=", "s", ".", "NewWebSession", "(", "user", ")", "\n", "if", "err", "!=", "nil...
// CreateWebSession creates a new web session for user without any // checks, is used by admins
[ "CreateWebSession", "creates", "a", "new", "web", "session", "for", "user", "without", "any", "checks", "is", "used", "by", "admins" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L719-L732
23,180
gravitational/teleport
lib/auth/auth.go
CheckAndSetDefaults
func (req *GenerateTokenRequest) CheckAndSetDefaults() error { for _, role := range req.Roles { if err := role.Check(); err != nil { return trace.Wrap(err) } } if req.TTL == 0 { req.TTL = defaults.ProvisioningTokenTTL } if req.Token == "" { token, err := utils.CryptoRandomHex(TokenLenBytes) if err != ...
go
func (req *GenerateTokenRequest) CheckAndSetDefaults() error { for _, role := range req.Roles { if err := role.Check(); err != nil { return trace.Wrap(err) } } if req.TTL == 0 { req.TTL = defaults.ProvisioningTokenTTL } if req.Token == "" { token, err := utils.CryptoRandomHex(TokenLenBytes) if err != ...
[ "func", "(", "req", "*", "GenerateTokenRequest", ")", "CheckAndSetDefaults", "(", ")", "error", "{", "for", "_", ",", "role", ":=", "range", "req", ".", "Roles", "{", "if", "err", ":=", "role", ".", "Check", "(", ")", ";", "err", "!=", "nil", "{", ...
// CheckAndSetDefaults checks and sets default values of request
[ "CheckAndSetDefaults", "checks", "and", "sets", "default", "values", "of", "request" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L745-L762
23,181
gravitational/teleport
lib/auth/auth.go
GenerateToken
func (s *AuthServer) GenerateToken(req GenerateTokenRequest) (string, error) { if err := req.CheckAndSetDefaults(); err != nil { return "", trace.Wrap(err) } token, err := services.NewProvisionToken(req.Token, req.Roles, s.clock.Now().UTC().Add(req.TTL)) if err != nil { return "", trace.Wrap(err) } if err := ...
go
func (s *AuthServer) GenerateToken(req GenerateTokenRequest) (string, error) { if err := req.CheckAndSetDefaults(); err != nil { return "", trace.Wrap(err) } token, err := services.NewProvisionToken(req.Token, req.Roles, s.clock.Now().UTC().Add(req.TTL)) if err != nil { return "", trace.Wrap(err) } if err := ...
[ "func", "(", "s", "*", "AuthServer", ")", "GenerateToken", "(", "req", "GenerateTokenRequest", ")", "(", "string", ",", "error", ")", "{", "if", "err", ":=", "req", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"...
// GenerateToken generates multi-purpose authentication token
[ "GenerateToken", "generates", "multi", "-", "purpose", "authentication", "token" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L765-L777
23,182
gravitational/teleport
lib/auth/auth.go
ExtractHostID
func ExtractHostID(hostName string, clusterName string) (string, error) { suffix := "." + clusterName if !strings.HasSuffix(hostName, suffix) { return "", trace.BadParameter("expected suffix %q in %q", suffix, hostName) } return strings.TrimSuffix(hostName, suffix), nil }
go
func ExtractHostID(hostName string, clusterName string) (string, error) { suffix := "." + clusterName if !strings.HasSuffix(hostName, suffix) { return "", trace.BadParameter("expected suffix %q in %q", suffix, hostName) } return strings.TrimSuffix(hostName, suffix), nil }
[ "func", "ExtractHostID", "(", "hostName", "string", ",", "clusterName", "string", ")", "(", "string", ",", "error", ")", "{", "suffix", ":=", "\"", "\"", "+", "clusterName", "\n", "if", "!", "strings", ".", "HasSuffix", "(", "hostName", ",", "suffix", ")...
// ExtractHostID returns host id based on the hostname
[ "ExtractHostID", "returns", "host", "id", "based", "on", "the", "hostname" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L780-L786
23,183
gravitational/teleport
lib/auth/auth.go
ValidateToken
func (s *AuthServer) ValidateToken(token string) (roles teleport.Roles, e error) { tkns, err := s.GetCache().GetStaticTokens() if err != nil { return nil, trace.Wrap(err) } // First check if the token is a static token. If it is, return right away. // Static tokens have no expiration. for _, st := range tkns.G...
go
func (s *AuthServer) ValidateToken(token string) (roles teleport.Roles, e error) { tkns, err := s.GetCache().GetStaticTokens() if err != nil { return nil, trace.Wrap(err) } // First check if the token is a static token. If it is, return right away. // Static tokens have no expiration. for _, st := range tkns.G...
[ "func", "(", "s", "*", "AuthServer", ")", "ValidateToken", "(", "token", "string", ")", "(", "roles", "teleport", ".", "Roles", ",", "e", "error", ")", "{", "tkns", ",", "err", ":=", "s", ".", "GetCache", "(", ")", ".", "GetStaticTokens", "(", ")", ...
// ValidateToken takes a provisioning token value and finds if it's valid. Returns // a list of roles this token allows its owner to assume, or an error if the token // cannot be found.
[ "ValidateToken", "takes", "a", "provisioning", "token", "value", "and", "finds", "if", "it", "s", "valid", ".", "Returns", "a", "list", "of", "roles", "this", "token", "allows", "its", "owner", "to", "assume", "or", "an", "error", "if", "the", "token", "...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L993-L1018
23,184
gravitational/teleport
lib/auth/auth.go
checkTokenTTL
func (s *AuthServer) checkTokenTTL(tok services.ProvisionToken) bool { now := s.clock.Now().UTC() if tok.Expiry().Before(now) { err := s.DeleteToken(tok.GetName()) if err != nil { if !trace.IsNotFound(err) { log.Warnf("Unable to delete token from backend: %v.", err) } } return false } return true ...
go
func (s *AuthServer) checkTokenTTL(tok services.ProvisionToken) bool { now := s.clock.Now().UTC() if tok.Expiry().Before(now) { err := s.DeleteToken(tok.GetName()) if err != nil { if !trace.IsNotFound(err) { log.Warnf("Unable to delete token from backend: %v.", err) } } return false } return true ...
[ "func", "(", "s", "*", "AuthServer", ")", "checkTokenTTL", "(", "tok", "services", ".", "ProvisionToken", ")", "bool", "{", "now", ":=", "s", ".", "clock", ".", "Now", "(", ")", ".", "UTC", "(", ")", "\n", "if", "tok", ".", "Expiry", "(", ")", "....
// checkTokenTTL checks if the token is still valid. If it is not, the token // is removed from the backend and returns false. Otherwise returns true.
[ "checkTokenTTL", "checks", "if", "the", "token", "is", "still", "valid", ".", "If", "it", "is", "not", "the", "token", "is", "removed", "from", "the", "backend", "and", "returns", "false", ".", "Otherwise", "returns", "true", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L1022-L1034
23,185
gravitational/teleport
lib/auth/auth.go
CheckAndSetDefaults
func (r *RegisterUsingTokenRequest) CheckAndSetDefaults() error { if r.HostID == "" { return trace.BadParameter("missing parameter HostID") } if r.Token == "" { return trace.BadParameter("missing parameter Token") } if err := r.Role.Check(); err != nil { return trace.Wrap(err) } return nil }
go
func (r *RegisterUsingTokenRequest) CheckAndSetDefaults() error { if r.HostID == "" { return trace.BadParameter("missing parameter HostID") } if r.Token == "" { return trace.BadParameter("missing parameter Token") } if err := r.Role.Check(); err != nil { return trace.Wrap(err) } return nil }
[ "func", "(", "r", "*", "RegisterUsingTokenRequest", ")", "CheckAndSetDefaults", "(", ")", "error", "{", "if", "r", ".", "HostID", "==", "\"", "\"", "{", "return", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "r", ".", "T...
// CheckAndSetDefaults checks for errors and sets defaults
[ "CheckAndSetDefaults", "checks", "for", "errors", "and", "sets", "defaults" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L1064-L1075
23,186
gravitational/teleport
lib/auth/auth.go
NewWatcher
func (a *AuthServer) NewWatcher(ctx context.Context, watch services.Watch) (services.Watcher, error) { return a.GetCache().NewWatcher(ctx, watch) }
go
func (a *AuthServer) NewWatcher(ctx context.Context, watch services.Watch) (services.Watcher, error) { return a.GetCache().NewWatcher(ctx, watch) }
[ "func", "(", "a", "*", "AuthServer", ")", "NewWatcher", "(", "ctx", "context", ".", "Context", ",", "watch", "services", ".", "Watch", ")", "(", "services", ".", "Watcher", ",", "error", ")", "{", "return", "a", ".", "GetCache", "(", ")", ".", "NewWa...
// NewWatcher returns a new event watcher. In case of an auth server // this watcher will return events as seen by the auth server's // in memory cache, not the backend.
[ "NewWatcher", "returns", "a", "new", "event", "watcher", ".", "In", "case", "of", "an", "auth", "server", "this", "watcher", "will", "return", "events", "as", "seen", "by", "the", "auth", "server", "s", "in", "memory", "cache", "not", "the", "backend", "...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L1274-L1276
23,187
gravitational/teleport
lib/auth/auth.go
Error
func (k *authKeepAliver) Error() error { k.RLock() defer k.RUnlock() return k.err }
go
func (k *authKeepAliver) Error() error { k.RLock() defer k.RUnlock() return k.err }
[ "func", "(", "k", "*", "authKeepAliver", ")", "Error", "(", ")", "error", "{", "k", ".", "RLock", "(", ")", "\n", "defer", "k", ".", "RUnlock", "(", ")", "\n", "return", "k", ".", "err", "\n", "}" ]
// Error returns the error if keep aliver // has been closed
[ "Error", "returns", "the", "error", "if", "keep", "aliver", "has", "been", "closed" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L1443-L1447
23,188
gravitational/teleport
lib/auth/auth.go
oidcConfigsEqual
func oidcConfigsEqual(a, b oidc.ClientConfig) bool { if a.RedirectURL != b.RedirectURL { return false } if a.Credentials.ID != b.Credentials.ID { return false } if a.Credentials.Secret != b.Credentials.Secret { return false } if len(a.Scope) != len(b.Scope) { return false } for i := range a.Scope { i...
go
func oidcConfigsEqual(a, b oidc.ClientConfig) bool { if a.RedirectURL != b.RedirectURL { return false } if a.Credentials.ID != b.Credentials.ID { return false } if a.Credentials.Secret != b.Credentials.Secret { return false } if len(a.Scope) != len(b.Scope) { return false } for i := range a.Scope { i...
[ "func", "oidcConfigsEqual", "(", "a", ",", "b", "oidc", ".", "ClientConfig", ")", "bool", "{", "if", "a", ".", "RedirectURL", "!=", "b", ".", "RedirectURL", "{", "return", "false", "\n", "}", "\n", "if", "a", ".", "Credentials", ".", "ID", "!=", "b",...
// oidcConfigsEqual returns true if the provided OIDC configs are equal
[ "oidcConfigsEqual", "returns", "true", "if", "the", "provided", "OIDC", "configs", "are", "equal" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L1488-L1507
23,189
gravitational/teleport
lib/auth/auth.go
oauth2ConfigsEqual
func oauth2ConfigsEqual(a, b oauth2.Config) bool { if a.Credentials.ID != b.Credentials.ID { return false } if a.Credentials.Secret != b.Credentials.Secret { return false } if a.RedirectURL != b.RedirectURL { return false } if len(a.Scope) != len(b.Scope) { return false } for i := range a.Scope { if ...
go
func oauth2ConfigsEqual(a, b oauth2.Config) bool { if a.Credentials.ID != b.Credentials.ID { return false } if a.Credentials.Secret != b.Credentials.Secret { return false } if a.RedirectURL != b.RedirectURL { return false } if len(a.Scope) != len(b.Scope) { return false } for i := range a.Scope { if ...
[ "func", "oauth2ConfigsEqual", "(", "a", ",", "b", "oauth2", ".", "Config", ")", "bool", "{", "if", "a", ".", "Credentials", ".", "ID", "!=", "b", ".", "Credentials", ".", "ID", "{", "return", "false", "\n", "}", "\n", "if", "a", ".", "Credentials", ...
// oauth2ConfigsEqual returns true if the provided OAuth2 configs are equal
[ "oauth2ConfigsEqual", "returns", "true", "if", "the", "provided", "OAuth2", "configs", "are", "equal" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L1510-L1538
23,190
gravitational/teleport
lib/auth/auth.go
isHTTPS
func isHTTPS(u string) error { earl, err := url.Parse(u) if err != nil { return trace.Wrap(err) } if earl.Scheme != "https" { return trace.BadParameter("expected scheme https, got %q", earl.Scheme) } return nil }
go
func isHTTPS(u string) error { earl, err := url.Parse(u) if err != nil { return trace.Wrap(err) } if earl.Scheme != "https" { return trace.BadParameter("expected scheme https, got %q", earl.Scheme) } return nil }
[ "func", "isHTTPS", "(", "u", "string", ")", "error", "{", "earl", ",", "err", ":=", "url", ".", "Parse", "(", "u", ")", "\n", "if", "err", "!=", "nil", "{", "return", "trace", ".", "Wrap", "(", "err", ")", "\n", "}", "\n", "if", "earl", ".", ...
// isHTTPS checks if the scheme for a URL is https or not.
[ "isHTTPS", "checks", "if", "the", "scheme", "for", "a", "URL", "is", "https", "or", "not", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/auth.go#L1541-L1551
23,191
gravitational/teleport
lib/services/oidc.go
NewOIDCConnector
func NewOIDCConnector(name string, spec OIDCConnectorSpecV2) OIDCConnector { return &OIDCConnectorV2{ Kind: KindOIDCConnector, Version: V2, Metadata: Metadata{ Name: name, Namespace: defaults.Namespace, }, Spec: spec, } }
go
func NewOIDCConnector(name string, spec OIDCConnectorSpecV2) OIDCConnector { return &OIDCConnectorV2{ Kind: KindOIDCConnector, Version: V2, Metadata: Metadata{ Name: name, Namespace: defaults.Namespace, }, Spec: spec, } }
[ "func", "NewOIDCConnector", "(", "name", "string", ",", "spec", "OIDCConnectorSpecV2", ")", "OIDCConnector", "{", "return", "&", "OIDCConnectorV2", "{", "Kind", ":", "KindOIDCConnector", ",", "Version", ":", "V2", ",", "Metadata", ":", "Metadata", "{", "Name", ...
// NewOIDCConnector returns a new OIDCConnector based off a name and OIDCConnectorSpecV2.
[ "NewOIDCConnector", "returns", "a", "new", "OIDCConnector", "based", "off", "a", "name", "and", "OIDCConnectorSpecV2", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/oidc.go#L92-L102
23,192
gravitational/teleport
lib/services/oidc.go
UnmarshalOIDCConnector
func (*TeleportOIDCConnectorMarshaler) UnmarshalOIDCConnector(bytes []byte, opts ...MarshalOption) (OIDCConnector, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } var h ResourceHeader err = utils.FastUnmarshal(bytes, &h) if err != nil { return nil, trace.Wrap(err) } s...
go
func (*TeleportOIDCConnectorMarshaler) UnmarshalOIDCConnector(bytes []byte, opts ...MarshalOption) (OIDCConnector, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } var h ResourceHeader err = utils.FastUnmarshal(bytes, &h) if err != nil { return nil, trace.Wrap(err) } s...
[ "func", "(", "*", "TeleportOIDCConnectorMarshaler", ")", "UnmarshalOIDCConnector", "(", "bytes", "[", "]", "byte", ",", "opts", "...", "MarshalOption", ")", "(", "OIDCConnector", ",", "error", ")", "{", "cfg", ",", "err", ":=", "collectOptions", "(", "opts", ...
// UnmarshalOIDCConnector unmarshals connector from
[ "UnmarshalOIDCConnector", "unmarshals", "connector", "from" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/oidc.go#L137-L180
23,193
gravitational/teleport
lib/services/oidc.go
MarshalOIDCConnector
func (*TeleportOIDCConnectorMarshaler) MarshalOIDCConnector(c OIDCConnector, opts ...MarshalOption) ([]byte, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } type connv1 interface { V1() *OIDCConnectorV1 } type connv2 interface { V2() *OIDCConnectorV2 } version := c...
go
func (*TeleportOIDCConnectorMarshaler) MarshalOIDCConnector(c OIDCConnector, opts ...MarshalOption) ([]byte, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } type connv1 interface { V1() *OIDCConnectorV1 } type connv2 interface { V2() *OIDCConnectorV2 } version := c...
[ "func", "(", "*", "TeleportOIDCConnectorMarshaler", ")", "MarshalOIDCConnector", "(", "c", "OIDCConnector", ",", "opts", "...", "MarshalOption", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "cfg", ",", "err", ":=", "collectOptions", "(", "opts", ")", ...
// MarshalUser marshals OIDC connector into JSON
[ "MarshalUser", "marshals", "OIDC", "connector", "into", "JSON" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/oidc.go#L183-L220
23,194
gravitational/teleport
lib/services/oidc.go
V1
func (o *OIDCConnectorV2) V1() *OIDCConnectorV1 { return &OIDCConnectorV1{ ID: o.Metadata.Name, IssuerURL: o.Spec.IssuerURL, ClientID: o.Spec.ClientID, ClientSecret: o.Spec.ClientSecret, RedirectURL: o.Spec.RedirectURL, Display: o.Spec.Display, Scope: o.Spec.Scope, ...
go
func (o *OIDCConnectorV2) V1() *OIDCConnectorV1 { return &OIDCConnectorV1{ ID: o.Metadata.Name, IssuerURL: o.Spec.IssuerURL, ClientID: o.Spec.ClientID, ClientSecret: o.Spec.ClientSecret, RedirectURL: o.Spec.RedirectURL, Display: o.Spec.Display, Scope: o.Spec.Scope, ...
[ "func", "(", "o", "*", "OIDCConnectorV2", ")", "V1", "(", ")", "*", "OIDCConnectorV1", "{", "return", "&", "OIDCConnectorV1", "{", "ID", ":", "o", ".", "Metadata", ".", "Name", ",", "IssuerURL", ":", "o", ".", "Spec", ".", "IssuerURL", ",", "ClientID",...
// V1 converts OIDCConnectorV2 to OIDCConnectorV1 format
[ "V1", "converts", "OIDCConnectorV2", "to", "OIDCConnectorV1", "format" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/oidc.go#L272-L283
23,195
gravitational/teleport
lib/services/oidc.go
GetClaims
func (o *OIDCConnectorV2) GetClaims() []string { var out []string for _, mapping := range o.Spec.ClaimsToRoles { out = append(out, mapping.Claim) } return utils.Deduplicate(out) }
go
func (o *OIDCConnectorV2) GetClaims() []string { var out []string for _, mapping := range o.Spec.ClaimsToRoles { out = append(out, mapping.Claim) } return utils.Deduplicate(out) }
[ "func", "(", "o", "*", "OIDCConnectorV2", ")", "GetClaims", "(", ")", "[", "]", "string", "{", "var", "out", "[", "]", "string", "\n", "for", "_", ",", "mapping", ":=", "range", "o", ".", "Spec", ".", "ClaimsToRoles", "{", "out", "=", "append", "("...
// GetClaims returns list of claims expected by mappings
[ "GetClaims", "returns", "list", "of", "claims", "expected", "by", "mappings" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/oidc.go#L412-L418
23,196
gravitational/teleport
lib/services/oidc.go
MapClaims
func (o *OIDCConnectorV2) MapClaims(claims jose.Claims) []string { var roles []string for _, mapping := range o.Spec.ClaimsToRoles { for claimName := range claims { if claimName != mapping.Claim { continue } var claimValues []string claimValue, ok, _ := claims.StringClaim(claimName) if ok { c...
go
func (o *OIDCConnectorV2) MapClaims(claims jose.Claims) []string { var roles []string for _, mapping := range o.Spec.ClaimsToRoles { for claimName := range claims { if claimName != mapping.Claim { continue } var claimValues []string claimValue, ok, _ := claims.StringClaim(claimName) if ok { c...
[ "func", "(", "o", "*", "OIDCConnectorV2", ")", "MapClaims", "(", "claims", "jose", ".", "Claims", ")", "[", "]", "string", "{", "var", "roles", "[", "]", "string", "\n", "for", "_", ",", "mapping", ":=", "range", "o", ".", "Spec", ".", "ClaimsToRoles...
// MapClaims maps claims to roles
[ "MapClaims", "maps", "claims", "to", "roles" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/oidc.go#L421-L456
23,197
gravitational/teleport
lib/services/oidc.go
GetClaimNames
func GetClaimNames(claims jose.Claims) []string { var out []string for claim := range claims { out = append(out, claim) } return out }
go
func GetClaimNames(claims jose.Claims) []string { var out []string for claim := range claims { out = append(out, claim) } return out }
[ "func", "GetClaimNames", "(", "claims", "jose", ".", "Claims", ")", "[", "]", "string", "{", "var", "out", "[", "]", "string", "\n", "for", "claim", ":=", "range", "claims", "{", "out", "=", "append", "(", "out", ",", "claim", ")", "\n", "}", "\n",...
// GetClaimNames returns a list of claim names from the claim values
[ "GetClaimNames", "returns", "a", "list", "of", "claim", "names", "from", "the", "claim", "values" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/oidc.go#L613-L619
23,198
gravitational/teleport
lib/services/oidc.go
V2
func (o *OIDCConnectorV1) V2() *OIDCConnectorV2 { return &OIDCConnectorV2{ Kind: KindOIDCConnector, Version: V2, Metadata: Metadata{ Name: o.ID, }, Spec: OIDCConnectorSpecV2{ IssuerURL: o.IssuerURL, ClientID: o.ClientID, ClientSecret: o.ClientSecret, RedirectURL: o.RedirectURL, ...
go
func (o *OIDCConnectorV1) V2() *OIDCConnectorV2 { return &OIDCConnectorV2{ Kind: KindOIDCConnector, Version: V2, Metadata: Metadata{ Name: o.ID, }, Spec: OIDCConnectorSpecV2{ IssuerURL: o.IssuerURL, ClientID: o.ClientID, ClientSecret: o.ClientSecret, RedirectURL: o.RedirectURL, ...
[ "func", "(", "o", "*", "OIDCConnectorV1", ")", "V2", "(", ")", "*", "OIDCConnectorV2", "{", "return", "&", "OIDCConnectorV2", "{", "Kind", ":", "KindOIDCConnector", ",", "Version", ":", "V2", ",", "Metadata", ":", "Metadata", "{", "Name", ":", "o", ".", ...
// V2 returns V2 version of the connector
[ "V2", "returns", "V2", "version", "of", "the", "connector" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/oidc.go#L682-L699
23,199
gravitational/teleport
lib/utils/checker.go
Authenticate
func (c *CertChecker) Authenticate(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) { err := validate(key) if err != nil { return nil, trace.Wrap(err) } perms, err := c.CertChecker.Authenticate(conn, key) if err != nil { return nil, trace.Wrap(err) } return perms, nil }
go
func (c *CertChecker) Authenticate(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) { err := validate(key) if err != nil { return nil, trace.Wrap(err) } perms, err := c.CertChecker.Authenticate(conn, key) if err != nil { return nil, trace.Wrap(err) } return perms, nil }
[ "func", "(", "c", "*", "CertChecker", ")", "Authenticate", "(", "conn", "ssh", ".", "ConnMetadata", ",", "key", "ssh", ".", "PublicKey", ")", "(", "*", "ssh", ".", "Permissions", ",", "error", ")", "{", "err", ":=", "validate", "(", "key", ")", "\n",...
// Authenticate checks the validity of a user certificate. // a value for ServerConfig.PublicKeyCallback.
[ "Authenticate", "checks", "the", "validity", "of", "a", "user", "certificate", ".", "a", "value", "for", "ServerConfig", ".", "PublicKeyCallback", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/checker.go#L43-L55