repo stringlengths 5 67 | sha stringlengths 40 40 | path stringlengths 4 234 | url stringlengths 85 339 | language stringclasses 6
values | split stringclasses 3
values | doc stringlengths 3 51.2k | sign stringlengths 5 8.01k | problem stringlengths 13 51.2k | output stringlengths 0 3.87M |
|---|---|---|---|---|---|---|---|---|---|
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/methods.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/methods.go#L274-L320 | go | train | // AuthenticateSSHUser authenticates web user, creates and returns web session
// in case if authentication is successful | func (s *AuthServer) AuthenticateSSHUser(req AuthenticateSSHRequest) (*SSHLoginResponse, error) | // AuthenticateSSHUser authenticates web user, creates and returns web session
// in case if authentication is successful
func (s *AuthServer) AuthenticateSSHUser(req AuthenticateSSHRequest) (*SSHLoginResponse, error) | {
clusterName, err := s.GetClusterName()
if err != nil {
return nil, trace.Wrap(err)
}
if err := s.AuthenticateUser(req.AuthenticateUserRequest); err != nil {
return nil, trace.Wrap(err)
}
user, err := s.GetUser(req.Username)
if err != nil {
return nil, trace.Wrap(err)
}
roles, err := services.FetchRol... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/pam/pam.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L75-L88 | go | train | //export writeCallback | func writeCallback(index C.int, stream C.int, s *C.char) | //export writeCallback
func writeCallback(index C.int, stream C.int, s *C.char) | {
handle, err := lookupHandler(int(index))
if err != nil {
log.Errorf("Unable to write to output stream: %v", err)
return
}
// To prevent poorly written PAM modules from sending more data than they
// should, cap strings to the maximum message size that PAM allows.
str := C.GoStringN(s, C.int(C.strnlen(s, C... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/pam/pam.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L91-L121 | go | train | //export readCallback | func readCallback(index C.int, e C.int) *C.char | //export readCallback
func readCallback(index C.int, e C.int) *C.char | {
handle, err := lookupHandler(int(index))
if err != nil {
log.Errorf("Unable to read from input stream: %v", err)
return nil
}
var echo bool
if e == 1 {
echo = true
}
// Read from the stream (typically stdin or equivalent).
s, err := handle.readStream(echo)
if err != nil {
log.Errorf("Unable to rea... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/pam/pam.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L125-L136 | go | train | // registerHandler will register a instance of *PAM with the package level
// handlers to support callbacks from C. | func registerHandler(p *PAM) int | // registerHandler will register a instance of *PAM with the package level
// handlers to support callbacks from C.
func registerHandler(p *PAM) int | {
handlerMu.Lock()
defer handlerMu.Unlock()
// The make_pam_conv function allocates struct pam_conv on the heap. It will
// be released by Close function.
handlerCount = handlerCount + 1
p.conv = C.make_pam_conv(C.int(handlerCount))
handlers[handlerCount] = p
return handlerCount
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/pam/pam.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L140-L145 | go | train | // unregisterHandler will remove the PAM handle from the package level map
// once no more C callbacks can come back. | func unregisterHandler(handlerIndex int) | // unregisterHandler will remove the PAM handle from the package level map
// once no more C callbacks can come back.
func unregisterHandler(handlerIndex int) | {
handlerMu.Lock()
defer handlerMu.Unlock()
delete(handlers, handlerIndex)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/pam/pam.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L148-L158 | go | train | // lookupHandler returns a particular handler from the package level map. | func lookupHandler(handlerIndex int) (handler, error) | // lookupHandler returns a particular handler from the package level map.
func lookupHandler(handlerIndex int) (handler, error) | {
handlerMu.Lock()
defer handlerMu.Unlock()
handle, ok := handlers[handlerIndex]
if !ok {
return nil, trace.BadParameter("handler with index %v not registered", handlerIndex)
}
return handle, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/pam/pam.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L215-L271 | go | train | // Open creates a PAM context and initiates a PAM transaction to check the
// account and then opens a session. | func Open(config *Config) (*PAM, error) | // Open creates a PAM context and initiates a PAM transaction to check the
// account and then opens a session.
func Open(config *Config) (*PAM, error) | {
if config == nil {
return nil, trace.BadParameter("PAM configuration is required.")
}
err := config.CheckDefaults()
if err != nil {
return nil, trace.Wrap(err)
}
p := &PAM{
pamh: nil,
stdin: config.Stdin,
stdout: config.Stdout,
stderr: config.Stderr,
}
// Both config.ServiceName and config.U... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/pam/pam.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L275-L300 | go | train | // Close will close the session, the PAM context, and release any allocated
// memory. | func (p *PAM) Close() error | // Close will close the session, the PAM context, and release any allocated
// memory.
func (p *PAM) Close() error | {
// Close the PAM session. Closing a session can entail anything from
// unmounting a home directory and updating auth.log.
p.retval = C._pam_close_session(pamHandle, p.pamh, 0)
if p.retval != C.PAM_SUCCESS {
return p.codeToError(p.retval)
}
// Terminate the PAM transaction.
retval := C._pam_end(pamHandle, ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/pam/pam.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L304-L318 | go | train | // writeStream will write to the output stream (stdout or stderr or
// equivalent). | func (p *PAM) writeStream(stream int, s string) (int, error) | // writeStream will write to the output stream (stdout or stderr or
// equivalent).
func (p *PAM) writeStream(stream int, s string) (int, error) | {
writer := p.stdout
if stream == syscall.Stderr {
writer = p.stderr
}
// Replace \n with \r\n so the message correctly aligned.
r := strings.NewReplacer("\r\n", "\r\n", "\n", "\r\n")
n, err := writer.Write([]byte(r.Replace(s)))
if err != nil {
return n, err
}
return n, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/pam/pam.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L323-L331 | go | train | // readStream will read from the input stream (stdin or equivalent).
// TODO(russjones): At some point in the future if this becomes an issue, we
// should consider supporting echo = false. | func (p *PAM) readStream(echo bool) (string, error) | // readStream will read from the input stream (stdin or equivalent).
// TODO(russjones): At some point in the future if this becomes an issue, we
// should consider supporting echo = false.
func (p *PAM) readStream(echo bool) (string, error) | {
reader := bufio.NewReader(p.stdin)
text, err := reader.ReadString('\n')
if err != nil {
return "", trace.Wrap(err)
}
return text, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/pam/pam.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/pam/pam.go#L334-L343 | go | train | // codeToError returns a human readable string from the PAM error. | func (p *PAM) codeToError(returnValue C.int) error | // codeToError returns a human readable string from the PAM error.
func (p *PAM) codeToError(returnValue C.int) error | {
// Error strings are not allocated on the heap, so memory does not need
// released.
err := C._pam_strerror(pamHandle, p.pamh, returnValue)
if err != nil {
return trace.BadParameter(C.GoString(err))
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/utils/fakeconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/fakeconn.go#L89-L96 | go | train | // DualPipeAddrConn creates a net.Pipe to connect a client and a server. The
// two net.Conn instances are wrapped in an addrConn which holds the source and
// destination addresses. | func DualPipeNetConn(srcAddr net.Addr, dstAddr net.Addr) (*PipeNetConn, *PipeNetConn) | // DualPipeAddrConn creates a net.Pipe to connect a client and a server. The
// two net.Conn instances are wrapped in an addrConn which holds the source and
// destination addresses.
func DualPipeNetConn(srcAddr net.Addr, dstAddr net.Addr) (*PipeNetConn, *PipeNetConn) | {
server, client := net.Pipe()
serverConn := NewPipeNetConn(server, server, server, dstAddr, srcAddr)
clientConn := NewPipeNetConn(client, client, client, srcAddr, dstAddr)
return serverConn, clientConn
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/clustername.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/clustername.go#L46-L61 | go | train | // NewClusterName is a convenience wrapper to create a ClusterName resource. | func NewClusterName(spec ClusterNameSpecV2) (ClusterName, error) | // NewClusterName is a convenience wrapper to create a ClusterName resource.
func NewClusterName(spec ClusterNameSpecV2) (ClusterName, error) | {
cn := ClusterNameV2{
Kind: KindClusterName,
Version: V2,
Metadata: Metadata{
Name: MetaNameClusterName,
Namespace: defaults.Namespace,
},
Spec: spec,
}
if err := cn.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
return &cn, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/clustername.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/clustername.go#L109-L111 | go | train | // SetExpiry sets expiry time for the object | func (c *ClusterNameV2) SetExpiry(expires time.Time) | // SetExpiry sets expiry time for the object
func (c *ClusterNameV2) SetExpiry(expires time.Time) | {
c.Metadata.SetExpiry(expires)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/clustername.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/clustername.go#L134-L146 | go | train | // CheckAndSetDefaults checks validity of all parameters and sets defaults. | func (c *ClusterNameV2) CheckAndSetDefaults() error | // CheckAndSetDefaults checks validity of all parameters and sets defaults.
func (c *ClusterNameV2) CheckAndSetDefaults() error | {
// make sure we have defaults for all metadata fields
err := c.Metadata.CheckAndSetDefaults()
if err != nil {
return trace.Wrap(err)
}
if c.Spec.ClusterName == "" {
return trace.BadParameter("cluster name is required")
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/clustername.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/clustername.go#L166-L174 | go | train | // GetClusterNameSchema returns the schema with optionally injected
// schema for extensions. | func GetClusterNameSchema(extensionSchema string) string | // GetClusterNameSchema returns the schema with optionally injected
// schema for extensions.
func GetClusterNameSchema(extensionSchema string) string | {
var clusterNameSchema string
if clusterNameSchema == "" {
clusterNameSchema = fmt.Sprintf(ClusterNameSpecSchemaTemplate, "")
} else {
clusterNameSchema = fmt.Sprintf(ClusterNameSpecSchemaTemplate, ","+extensionSchema)
}
return fmt.Sprintf(V2SchemaTemplate, MetadataSchema, clusterNameSchema, DefaultDefinitio... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/clustername.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/clustername.go#L203-L239 | go | train | // Unmarshal unmarshals ClusterName from JSON. | func (t *TeleportClusterNameMarshaler) Unmarshal(bytes []byte, opts ...MarshalOption) (ClusterName, error) | // Unmarshal unmarshals ClusterName from JSON.
func (t *TeleportClusterNameMarshaler) Unmarshal(bytes []byte, opts ...MarshalOption) (ClusterName, error) | {
var clusterName ClusterNameV2
if len(bytes) == 0 {
return nil, trace.BadParameter("missing resource data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
if cfg.SkipValidation {
if err := utils.FastUnmarshal(bytes, &clusterName); err != nil {
return nil, trace.Bad... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/clustername.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/clustername.go#L242-L260 | go | train | // Marshal marshals ClusterName to JSON. | func (t *TeleportClusterNameMarshaler) Marshal(c ClusterName, opts ...MarshalOption) ([]byte, error) | // Marshal marshals ClusterName to JSON.
func (t *TeleportClusterNameMarshaler) Marshal(c ClusterName, opts ...MarshalOption) ([]byte, error) | {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch resource := c.(type) {
case *ClusterNameV2:
if !cfg.PreserveResourceID {
// avoid modifying the original object
// to prevent unexpected data races
copy := *resource
copy.SetResourceID(0)
resource = ©
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trust.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trust.go#L81-L86 | go | train | // Check checks if certificate authority type value is correct | func (c CertAuthType) Check() error | // Check checks if certificate authority type value is correct
func (c CertAuthType) Check() error | {
if c != HostCA && c != UserCA {
return trace.BadParameter("'%v' authority type is not supported", c)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trust.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trust.go#L99-L107 | go | train | // Check returns error if any of the id parameters are bad, nil otherwise | func (c *CertAuthID) Check() error | // Check returns error if any of the id parameters are bad, nil otherwise
func (c *CertAuthID) Check() error | {
if err := c.Type.Check(); err != nil {
return trace.Wrap(err)
}
if strings.TrimSpace(c.DomainName) == "" {
return trace.BadParameter("identity validation error: empty domain name")
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnel.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L55-L68 | go | train | // NewReverseTunnel returns new version of reverse tunnel | func NewReverseTunnel(clusterName string, dialAddrs []string) ReverseTunnel | // NewReverseTunnel returns new version of reverse tunnel
func NewReverseTunnel(clusterName string, dialAddrs []string) ReverseTunnel | {
return &ReverseTunnelV2{
Kind: KindReverseTunnel,
Version: V2,
Metadata: Metadata{
Name: clusterName,
Namespace: defaults.Namespace,
},
Spec: ReverseTunnelSpecV2{
ClusterName: clusterName,
DialAddrs: dialAddrs,
},
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnel.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L106-L108 | go | train | // SetExpiry sets expiry time for the object | func (r *ReverseTunnelV2) SetExpiry(expires time.Time) | // SetExpiry sets expiry time for the object
func (r *ReverseTunnelV2) SetExpiry(expires time.Time) | {
r.Metadata.SetExpiry(expires)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnel.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L136-L141 | go | train | // V1 returns V1 version of the resource | func (r *ReverseTunnelV2) V1() *ReverseTunnelV1 | // V1 returns V1 version of the resource
func (r *ReverseTunnelV2) V1() *ReverseTunnelV1 | {
return &ReverseTunnelV1{
DomainName: r.Spec.ClusterName,
DialAddrs: r.Spec.DialAddrs,
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnel.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L168-L173 | go | train | // GetType gets the type of ReverseTunnel. | func (r *ReverseTunnelV2) GetType() TunnelType | // GetType gets the type of ReverseTunnel.
func (r *ReverseTunnelV2) GetType() TunnelType | {
if string(r.Spec.Type) == "" {
return ProxyTunnel
}
return r.Spec.Type
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnel.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L186-L206 | go | train | // Check returns nil if all parameters are good, error otherwise | func (r *ReverseTunnelV2) Check() error | // Check returns nil if all parameters are good, error otherwise
func (r *ReverseTunnelV2) Check() error | {
if r.Version == "" {
return trace.BadParameter("missing reverse tunnel version")
}
if strings.TrimSpace(r.Spec.ClusterName) == "" {
return trace.BadParameter("Reverse tunnel validation error: empty cluster name")
}
if len(r.Spec.DialAddrs) == 0 {
return trace.BadParameter("Invalid dial address for revers... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnel.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L240-L254 | go | train | // V2 returns V2 version of reverse tunnel | func (r *ReverseTunnelV1) V2() *ReverseTunnelV2 | // V2 returns V2 version of reverse tunnel
func (r *ReverseTunnelV1) V2() *ReverseTunnelV2 | {
return &ReverseTunnelV2{
Kind: KindReverseTunnel,
Version: V2,
Metadata: Metadata{
Name: r.DomainName,
Namespace: defaults.Namespace,
},
Spec: ReverseTunnelSpecV2{
ClusterName: r.DomainName,
Type: ProxyTunnel,
DialAddrs: r.DialAddrs,
},
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnel.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L264-L313 | go | train | // UnmarshalReverseTunnel unmarshals reverse tunnel from JSON or YAML,
// sets defaults and checks the schema | func UnmarshalReverseTunnel(data []byte, opts ...MarshalOption) (ReverseTunnel, error) | // UnmarshalReverseTunnel unmarshals reverse tunnel from JSON or YAML,
// sets defaults and checks the schema
func UnmarshalReverseTunnel(data []byte, opts ...MarshalOption) (ReverseTunnel, error) | {
if len(data) == 0 {
return nil, trace.BadParameter("missing tunnel data")
}
var h ResourceHeader
err := json.Unmarshal(data, &h)
if err != nil {
return nil, trace.Wrap(err)
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch h.Version {
case "":
var r ReverseTu... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnel.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L340-L342 | go | train | // UnmarshalReverseTunnel unmarshals reverse tunnel from JSON or YAML | func (*TeleportTunnelMarshaler) UnmarshalReverseTunnel(bytes []byte, opts ...MarshalOption) (ReverseTunnel, error) | // UnmarshalReverseTunnel unmarshals reverse tunnel from JSON or YAML
func (*TeleportTunnelMarshaler) UnmarshalReverseTunnel(bytes []byte, opts ...MarshalOption) (ReverseTunnel, error) | {
return UnmarshalReverseTunnel(bytes, opts...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnel.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnel.go#L345-L381 | go | train | // MarshalRole marshalls role into JSON | func (*TeleportTunnelMarshaler) MarshalReverseTunnel(rt ReverseTunnel, opts ...MarshalOption) ([]byte, error) | // MarshalRole marshalls role into JSON
func (*TeleportTunnelMarshaler) MarshalReverseTunnel(rt ReverseTunnel, opts ...MarshalOption) ([]byte, error) | {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
type tunv1 interface {
V1() *ReverseTunnelV1
}
type tunv2 interface {
V2() *ReverseTunnelV2
}
version := cfg.GetVersion()
switch version {
case V1:
v, ok := rt.(tunv1)
if !ok {
return nil, trace.BadParameter("don't ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/utils/syslog.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/syslog.go#L33-L45 | go | train | // SwitchLoggingtoSyslog tells the logger to send the output to syslog. This
// code is behind a build flag because Windows does not support syslog. | func SwitchLoggingtoSyslog() error | // SwitchLoggingtoSyslog tells the logger to send the output to syslog. This
// code is behind a build flag because Windows does not support syslog.
func SwitchLoggingtoSyslog() error | {
log.StandardLogger().SetHooks(make(log.LevelHooks))
hook, err := logrusSyslog.NewSyslogHook("", "", syslog.LOG_WARNING, "")
if err != nil {
// syslog is not available
log.SetOutput(os.Stderr)
return trace.Wrap(err)
}
log.AddHook(hook)
// ... and disable stderr:
log.SetOutput(ioutil.Discard)
return nil
... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/rotate.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L61-L71 | go | train | // Types returns cert authority types requested to be rotated. | func (r *RotateRequest) Types() []services.CertAuthType | // Types returns cert authority types requested to be rotated.
func (r *RotateRequest) Types() []services.CertAuthType | {
switch r.Type {
case "":
return []services.CertAuthType{services.HostCA, services.UserCA}
case services.HostCA:
return []services.CertAuthType{services.HostCA}
case services.UserCA:
return []services.CertAuthType{services.UserCA}
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/rotate.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L74-L105 | go | train | // CheckAndSetDefaults checks and sets default values. | func (r *RotateRequest) CheckAndSetDefaults(clock clockwork.Clock) error | // CheckAndSetDefaults checks and sets default values.
func (r *RotateRequest) CheckAndSetDefaults(clock clockwork.Clock) error | {
if r.TargetPhase == "" {
// if phase if not set, imply that the first meaningful phase
// is set as a target phase
r.TargetPhase = services.RotationPhaseInit
}
// if mode is not set, default to manual (as it's safer)
if r.Mode == "" {
r.Mode = services.RotationModeManual
}
switch r.Type {
case "", ser... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/rotate.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L198-L240 | go | train | // RotateCertAuthority starts or restarts certificate authority rotation process.
//
// Rotation procedure is based on the state machine approach.
//
// Here are the supported rotation states:
//
// * Standby - the cluster is in standby mode and ready to take action.
// * In-progress - cluster CA rotation is in progr... | func (a *AuthServer) RotateCertAuthority(req RotateRequest) error | // RotateCertAuthority starts or restarts certificate authority rotation process.
//
// Rotation procedure is based on the state machine approach.
//
// Here are the supported rotation states:
//
// * Standby - the cluster is in standby mode and ready to take action.
// * In-progress - cluster CA rotation is in progr... | {
if err := req.CheckAndSetDefaults(a.clock); err != nil {
return trace.Wrap(err)
}
clusterName, err := a.GetClusterName()
if err != nil {
return trace.Wrap(err)
}
caTypes := req.Types()
for _, caType := range caTypes {
existing, err := a.Trust.GetCertAuthority(services.CertAuthID{
Type: caType,... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/rotate.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L245-L280 | go | train | // RotateExternalCertAuthority rotates external certificate authority,
// this method is called by remote trusted cluster and is used to update
// only public keys and certificates of the certificate authority. | func (a *AuthServer) RotateExternalCertAuthority(ca services.CertAuthority) error | // RotateExternalCertAuthority rotates external certificate authority,
// this method is called by remote trusted cluster and is used to update
// only public keys and certificates of the certificate authority.
func (a *AuthServer) RotateExternalCertAuthority(ca services.CertAuthority) error | {
if ca == nil {
return trace.BadParameter("missing certificate authority")
}
clusterName, err := a.GetClusterName()
if err != nil {
return trace.Wrap(err)
}
// this is just an extra precaution against local admins,
// because this is additionally enforced by RBAC as well
if ca.GetClusterName() == cluster... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/rotate.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L285-L303 | go | train | // autoRotateCertAuthorities automatically rotates cert authorities,
// does nothing if no rotation parameters were set up
// or it is too early to rotate per schedule | func (a *AuthServer) autoRotateCertAuthorities() error | // autoRotateCertAuthorities automatically rotates cert authorities,
// does nothing if no rotation parameters were set up
// or it is too early to rotate per schedule
func (a *AuthServer) autoRotateCertAuthorities() error | {
clusterName, err := a.GetClusterName()
if err != nil {
return trace.Wrap(err)
}
for _, caType := range []services.CertAuthType{services.HostCA, services.UserCA} {
ca, err := a.Trust.GetCertAuthority(services.CertAuthID{
Type: caType,
DomainName: clusterName.GetClusterName(),
}, true)
if err !... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/rotate.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L371-L450 | go | train | // processRotationRequest processes rotation request based on the target and
// current phase and state. | func processRotationRequest(req rotationReq) (services.CertAuthority, error) | // processRotationRequest processes rotation request based on the target and
// current phase and state.
func processRotationRequest(req rotationReq) (services.CertAuthority, error) | {
rotation := req.ca.GetRotation()
ca := req.ca.Clone()
switch req.targetPhase {
case services.RotationPhaseInit:
// This is the first stage of the rotation - new certificate authorities
// are being generated, but no components are using them yet
switch rotation.State {
case services.RotationStateStandby... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/rotate.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L454-L544 | go | train | // startNewRotation starts new rotation and updates the certificate
// authority with new CA keys. | func startNewRotation(req rotationReq, ca services.CertAuthority) error | // startNewRotation starts new rotation and updates the certificate
// authority with new CA keys.
func startNewRotation(req rotationReq, ca services.CertAuthority) error | {
clock := req.clock
gracePeriod := req.gracePeriod
rotation := ca.GetRotation()
id := uuid.New()
rotation.Mode = req.mode
rotation.Schedule = req.schedule
var sshPrivPEM, sshPubPEM []byte
var keyPEM, certPEM []byte
// generate keys and certificates:
if len(req.privateKey) != 0 {
log.Infof("Generating ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/rotate.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L552-L572 | go | train | // updateClients swaps old and new cert authorities:
//
// * old CAs exist and are trusted, but are not used for signing
// * the new CAs are now used for signing
// * remote components will reload with new certificates used for client connections
// | func updateClients(ca services.CertAuthority, mode string) error | // updateClients swaps old and new cert authorities:
//
// * old CAs exist and are trusted, but are not used for signing
// * the new CAs are now used for signing
// * remote components will reload with new certificates used for client connections
//
func updateClients(ca services.CertAuthority, mode string) error | {
rotation := ca.GetRotation()
signingKeys := ca.GetSigningKeys()
checkingKeys := ca.GetCheckingKeys()
keyPairs := ca.GetTLSKeyPairs()
signingKeys = [][]byte{signingKeys[1], signingKeys[0]}
checkingKeys = [][]byte{checkingKeys[1], checkingKeys[0]}
keyPairs = []services.TLSKeyPair{keyPairs[1], keyPairs[0]}
r... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/rotate.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L575-L601 | go | train | // startRollingBackRotation starts roll back to the original state. | func startRollingBackRotation(ca services.CertAuthority) error | // startRollingBackRotation starts roll back to the original state.
func startRollingBackRotation(ca services.CertAuthority) error | {
rotation := ca.GetRotation()
// Rollback always sets rotation to manual mode.
rotation.Mode = services.RotationModeManual
signingKeys := ca.GetSigningKeys()
checkingKeys := ca.GetCheckingKeys()
keyPairs := ca.GetTLSKeyPairs()
// Rotation sets the first key to be the new key
// and keep only public keys/ce... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/rotate.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L604-L622 | go | train | // completeRollingBackRotation completes rollback of the rotation and sets it to the standby state | func completeRollingBackRotation(clock clockwork.Clock, ca services.CertAuthority) error | // completeRollingBackRotation completes rollback of the rotation and sets it to the standby state
func completeRollingBackRotation(clock clockwork.Clock, ca services.CertAuthority) error | {
rotation := ca.GetRotation()
// clean up the state
rotation.Started = time.Time{}
rotation.State = services.RotationStateStandby
rotation.Phase = services.RotationPhaseStandby
rotation.Mode = ""
rotation.Schedule = services.RotationSchedule{}
keyPairs := ca.GetTLSKeyPairs()
// only keep the original certi... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/rotate.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/rotate.go#L625-L647 | go | train | // completeRotation completes the certificate authority rotation. | func completeRotation(clock clockwork.Clock, ca services.CertAuthority) error | // completeRotation completes the certificate authority rotation.
func completeRotation(clock clockwork.Clock, ca services.CertAuthority) error | {
rotation := ca.GetRotation()
signingKeys := ca.GetSigningKeys()
checkingKeys := ca.GetCheckingKeys()
keyPairs := ca.GetTLSKeyPairs()
signingKeys = signingKeys[:1]
checkingKeys = checkingKeys[:1]
keyPairs = keyPairs[:1]
rotation.Started = time.Time{}
rotation.State = services.RotationStateStandby
rotation... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/utils/unpack.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/unpack.go#L33-L49 | go | train | // Extract extracts the contents of the specified tarball under dir.
// The resulting files and directories are created using the current user context. | func Extract(r io.Reader, dir string) error | // Extract extracts the contents of the specified tarball under dir.
// The resulting files and directories are created using the current user context.
func Extract(r io.Reader, dir string) error | {
tarball := tar.NewReader(r)
for {
header, err := tarball.Next()
if err == io.EOF {
break
} else if err != nil {
return trace.Wrap(err)
}
if err := extractFile(tarball, header, dir); err != nil {
return trace.Wrap(err)
}
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/utils/unpack.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/unpack.go#L54-L68 | go | train | // extractFile extracts a single file or directory from tarball into dir.
// Uses header to determine the type of item to create
// Based on https://github.com/mholt/archiver | func extractFile(tarball *tar.Reader, header *tar.Header, dir string) error | // extractFile extracts a single file or directory from tarball into dir.
// Uses header to determine the type of item to create
// Based on https://github.com/mholt/archiver
func extractFile(tarball *tar.Reader, header *tar.Header, dir string) error | {
switch header.Typeflag {
case tar.TypeDir:
return withDir(filepath.Join(dir, header.Name), nil)
case tar.TypeBlock, tar.TypeChar, tar.TypeReg, tar.TypeRegA, tar.TypeFifo:
return writeFile(filepath.Join(dir, header.Name), tarball, header.FileInfo().Mode())
case tar.TypeLink:
return writeHardLink(filepath.Jo... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/utils/rand.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/rand.go#L30-L36 | go | train | // CryptoRandomHex returns hex encoded random string generated with crypto-strong
// pseudo random generator of the given bytes | func CryptoRandomHex(len int) (string, error) | // CryptoRandomHex returns hex encoded random string generated with crypto-strong
// pseudo random generator of the given bytes
func CryptoRandomHex(len int) (string, error) | {
randomBytes := make([]byte, len)
if _, err := rand.Reader.Read(randomBytes); err != nil {
return "", trace.Wrap(err)
}
return hex.EncodeToString(randomBytes), nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/utils/rand.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/rand.go#L39-L45 | go | train | // RandomDuration returns a duration in a range [0, max) | func RandomDuration(max time.Duration) time.Duration | // RandomDuration returns a duration in a range [0, max)
func RandomDuration(max time.Duration) time.Duration | {
randomVal, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
return max / 2
}
return time.Duration(randomVal.Int64())
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/suite/suite.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/suite/suite.go#L302-L315 | go | train | // NewServer creates a new server resource | func NewServer(kind, name, addr, namespace string) *services.ServerV2 | // NewServer creates a new server resource
func NewServer(kind, name, addr, namespace string) *services.ServerV2 | {
return &services.ServerV2{
Kind: kind,
Version: services.V2,
Metadata: services.Metadata{
Name: name,
Namespace: namespace,
},
Spec: services.ServerSpecV2{
Addr: addr,
PublicAddr: addr,
},
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/suite/suite.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/suite/suite.go#L890-L905 | go | train | // AuthPreference tests authentication preference service | func (s *ServicesTestSuite) AuthPreference(c *check.C) | // AuthPreference tests authentication preference service
func (s *ServicesTestSuite) AuthPreference(c *check.C) | {
ap, err := services.NewAuthPreference(services.AuthPreferenceSpecV2{
Type: "local",
SecondFactor: "otp",
})
c.Assert(err, check.IsNil)
err = s.ConfigS.SetAuthPreference(ap)
c.Assert(err, check.IsNil)
gotAP, err := s.ConfigS.GetAuthPreference()
c.Assert(err, check.IsNil)
c.Assert(gotAP.GetType(... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/suite/suite.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/suite/suite.go#L953-L959 | go | train | // CollectOptions collects suite options | func CollectOptions(opts ...SuiteOption) SuiteOptions | // CollectOptions collects suite options
func CollectOptions(opts ...SuiteOption) SuiteOptions | {
var suiteOpts SuiteOptions
for _, o := range opts {
o(&suiteOpts)
}
return suiteOpts
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/suite/suite.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/suite/suite.go#L962-L1023 | go | train | // ClusterConfig tests cluster configuration | func (s *ServicesTestSuite) ClusterConfig(c *check.C, opts ...SuiteOption) | // ClusterConfig tests cluster configuration
func (s *ServicesTestSuite) ClusterConfig(c *check.C, opts ...SuiteOption) | {
config, err := services.NewClusterConfig(services.ClusterConfigSpecV3{
ClientIdleTimeout: services.NewDuration(17 * time.Second),
DisconnectExpiredCert: services.NewBool(true),
ClusterID: "27",
SessionRecording: services.RecordAtProxy,
Audit: services.AuditConfig{
Region: ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/suite/suite.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/suite/suite.go#L1026-L1307 | go | train | // Events tests various events variations | func (s *ServicesTestSuite) Events(c *check.C) | // Events tests various events variations
func (s *ServicesTestSuite) Events(c *check.C) | {
testCases := []eventTest{
{
name: "Cert authority with secrets",
kind: services.WatchKind{
Kind: services.KindCertAuthority,
LoadSecrets: true,
},
crud: func() services.Resource {
ca := NewTestCA(services.UserCA, "example.com")
c.Assert(s.CAS.UpsertCertAuthority(ca), check.IsNil... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/suite/suite.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/suite/suite.go#L1310-L1357 | go | train | // EventsClusterConfig tests cluster config resource events | func (s *ServicesTestSuite) EventsClusterConfig(c *check.C) | // EventsClusterConfig tests cluster config resource events
func (s *ServicesTestSuite) EventsClusterConfig(c *check.C) | {
testCases := []eventTest{
{
name: "Cluster config",
kind: services.WatchKind{
Kind: services.KindClusterConfig,
},
crud: func() services.Resource {
config, err := services.NewClusterConfig(services.ClusterConfigSpecV3{})
c.Assert(err, check.IsNil)
err = s.ConfigS.SetClusterConfig(conf... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnelconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L78-L84 | go | train | // IsTunnelConnectionStatus returns tunnel connection status based on the last
// heartbeat time recorded for a connection | func TunnelConnectionStatus(clock clockwork.Clock, conn TunnelConnection) string | // IsTunnelConnectionStatus returns tunnel connection status based on the last
// heartbeat time recorded for a connection
func TunnelConnectionStatus(clock clockwork.Clock, conn TunnelConnection) string | {
diff := clock.Now().Sub(conn.GetLastHeartbeat())
if diff < defaults.ReverseTunnelOfflineThreshold {
return teleport.RemoteClusterStatusOnline
}
return teleport.RemoteClusterStatusOffline
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnelconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L88-L94 | go | train | // MustCreateTunnelConnection returns new connection from V2 spec or panics if
// parameters are incorrect | func MustCreateTunnelConnection(name string, spec TunnelConnectionSpecV2) TunnelConnection | // MustCreateTunnelConnection returns new connection from V2 spec or panics if
// parameters are incorrect
func MustCreateTunnelConnection(name string, spec TunnelConnectionSpecV2) TunnelConnection | {
conn, err := NewTunnelConnection(name, spec)
if err != nil {
panic(err)
}
return conn
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnelconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L97-L112 | go | train | // NewTunnelConnection returns new connection from V2 spec | func NewTunnelConnection(name string, spec TunnelConnectionSpecV2) (TunnelConnection, error) | // NewTunnelConnection returns new connection from V2 spec
func NewTunnelConnection(name string, spec TunnelConnectionSpecV2) (TunnelConnection, error) | {
conn := &TunnelConnectionV2{
Kind: KindTunnelConnection,
SubKind: spec.ClusterName,
Version: V2,
Metadata: Metadata{
Name: name,
Namespace: defaults.Namespace,
},
Spec: spec,
}
if err := conn.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
return conn, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnelconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L151-L154 | go | train | // String returns user-friendly description of this connection | func (r *TunnelConnectionV2) String() string | // String returns user-friendly description of this connection
func (r *TunnelConnectionV2) String() string | {
return fmt.Sprintf("TunnelConnection(name=%v, type=%v, cluster=%v, proxy=%v)",
r.Metadata.Name, r.Spec.Type, r.Spec.ClusterName, r.Spec.ProxyName)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnelconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L162-L164 | go | train | // SetExpiry sets expiry time for the object | func (r *TunnelConnectionV2) SetExpiry(expires time.Time) | // SetExpiry sets expiry time for the object
func (r *TunnelConnectionV2) SetExpiry(expires time.Time) | {
r.Metadata.SetExpiry(expires)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnelconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L172-L174 | go | train | // SetTTL sets Expires header using realtime clock | func (r *TunnelConnectionV2) SetTTL(clock clockwork.Clock, ttl time.Duration) | // SetTTL sets Expires header using realtime clock
func (r *TunnelConnectionV2) SetTTL(clock clockwork.Clock, ttl time.Duration) | {
r.Metadata.SetTTL(clock, ttl)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnelconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L221-L223 | go | train | // SetLastHeartbeat sets last heartbeat time | func (r *TunnelConnectionV2) SetLastHeartbeat(tm time.Time) | // SetLastHeartbeat sets last heartbeat time
func (r *TunnelConnectionV2) SetLastHeartbeat(tm time.Time) | {
r.Spec.LastHeartbeat = tm
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnelconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L226-L231 | go | train | // GetType gets the type of ReverseTunnel. | func (r *TunnelConnectionV2) GetType() TunnelType | // GetType gets the type of ReverseTunnel.
func (r *TunnelConnectionV2) GetType() TunnelType | {
if string(r.Spec.Type) == "" {
return ProxyTunnel
}
return r.Spec.Type
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnelconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L239-L252 | go | train | // Check returns nil if all parameters are good, error otherwise | func (r *TunnelConnectionV2) Check() error | // Check returns nil if all parameters are good, error otherwise
func (r *TunnelConnectionV2) Check() error | {
if r.Version == "" {
return trace.BadParameter("missing version")
}
if strings.TrimSpace(r.Spec.ClusterName) == "" {
return trace.BadParameter("empty cluster name")
}
if len(r.Spec.ProxyName) == 0 {
return trace.BadParameter("missing parameter proxy name")
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnelconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L275-L314 | go | train | // UnmarshalTunnelConnection unmarshals reverse tunnel from JSON or YAML,
// sets defaults and checks the schema | func UnmarshalTunnelConnection(data []byte, opts ...MarshalOption) (TunnelConnection, error) | // UnmarshalTunnelConnection unmarshals reverse tunnel from JSON or YAML,
// sets defaults and checks the schema
func UnmarshalTunnelConnection(data []byte, opts ...MarshalOption) (TunnelConnection, error) | {
if len(data) == 0 {
return nil, trace.BadParameter("missing tunnel connection data")
}
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
var h ResourceHeader
err = utils.FastUnmarshal(data, &h)
if err != nil {
return nil, trace.Wrap(err)
}
switch h.Version {
case V2:
v... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/tunnelconn.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/tunnelconn.go#L317-L335 | go | train | // MarshalTunnelConnection marshals tunnel connection | func MarshalTunnelConnection(rt TunnelConnection, opts ...MarshalOption) ([]byte, error) | // MarshalTunnelConnection marshals tunnel connection
func MarshalTunnelConnection(rt TunnelConnection, opts ...MarshalOption) ([]byte, error) | {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch resource := rt.(type) {
case *TunnelConnectionV2:
if !cfg.PreserveResourceID {
// avoid modifying the original object
// to prevent unexpected data races
copy := *resource
copy.SetResourceID(0)
resource = &c... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | tool/tctl/common/status_command.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/status_command.go#L41-L44 | go | train | // Initialize allows StatusCommand to plug itself into the CLI parser. | func (c *StatusCommand) Initialize(app *kingpin.Application, config *service.Config) | // Initialize allows StatusCommand to plug itself into the CLI parser.
func (c *StatusCommand) Initialize(app *kingpin.Application, config *service.Config) | {
c.config = config
c.status = app.Command("status", "Report cluster status")
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | tool/tctl/common/status_command.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/status_command.go#L47-L55 | go | train | // TryRun takes the CLI command as an argument (like "nodes ls") and executes it. | func (c *StatusCommand) TryRun(cmd string, client auth.ClientI) (match bool, err error) | // TryRun takes the CLI command as an argument (like "nodes ls") and executes it.
func (c *StatusCommand) TryRun(cmd string, client auth.ClientI) (match bool, err error) | {
switch cmd {
case c.status.FullCommand():
err = c.Status(client)
default:
return false, nil
}
return true, trace.Wrap(err)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | tool/tctl/common/status_command.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/tool/tctl/common/status_command.go#L58-L126 | go | train | // Status is called to execute "status" CLI command. | func (c *StatusCommand) Status(client auth.ClientI) error | // Status is called to execute "status" CLI command.
func (c *StatusCommand) Status(client auth.ClientI) error | {
clusterNameResource, err := client.GetClusterName()
if err != nil {
return trace.Wrap(err)
}
clusterName := clusterNameResource.GetClusterName()
hostCAs, err := client.GetCertAuthorities(services.HostCA, false)
if err != nil {
return trace.Wrap(err)
}
userCAs, err := client.GetCertAuthorities(services.... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L38-L147 | go | train | // UpsertTrustedCluster creates or toggles a Trusted Cluster relationship. | func (a *AuthServer) UpsertTrustedCluster(trustedCluster services.TrustedCluster) (services.TrustedCluster, error) | // UpsertTrustedCluster creates or toggles a Trusted Cluster relationship.
func (a *AuthServer) UpsertTrustedCluster(trustedCluster services.TrustedCluster) (services.TrustedCluster, error) | {
var exists bool
// it is recommended to omit trusted cluster name, because
// it will be always set to the cluster name as set by the cluster
var existingCluster services.TrustedCluster
var err error
if trustedCluster.GetName() != "" {
existingCluster, err = a.Presence.GetTrustedCluster(trustedCluster.GetNa... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L171-L199 | go | train | // DeleteTrustedCluster removes services.CertAuthority, services.ReverseTunnel,
// and services.TrustedCluster resources. | func (a *AuthServer) DeleteTrustedCluster(name string) error | // DeleteTrustedCluster removes services.CertAuthority, services.ReverseTunnel,
// and services.TrustedCluster resources.
func (a *AuthServer) DeleteTrustedCluster(name string) error | {
err := a.DeleteCertAuthority(services.CertAuthID{Type: services.HostCA, DomainName: name})
if err != nil {
if !trace.IsNotFound(err) {
return trace.Wrap(err)
}
}
err = a.DeleteCertAuthority(services.CertAuthID{Type: services.UserCA, DomainName: name})
if err != nil {
if !trace.IsNotFound(err) {
ret... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L293-L325 | go | train | // DeleteRemoteCluster deletes remote cluster resource, all certificate authorities
// associated with it | func (a *AuthServer) DeleteRemoteCluster(clusterName string) error | // DeleteRemoteCluster deletes remote cluster resource, all certificate authorities
// associated with it
func (a *AuthServer) DeleteRemoteCluster(clusterName string) error | {
// To make sure remote cluster exists - to protect against random
// clusterName requests (e.g. when clusterName is set to local cluster name)
_, err := a.Presence.GetRemoteCluster(clusterName)
if err != nil {
return trace.Wrap(err)
}
// delete cert authorities associated with the cluster
err = a.DeleteCert... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L328-L339 | go | train | // GetRemoteCluster returns remote cluster by name | func (a *AuthServer) GetRemoteCluster(clusterName string) (services.RemoteCluster, error) | // GetRemoteCluster returns remote cluster by name
func (a *AuthServer) GetRemoteCluster(clusterName string) (services.RemoteCluster, error) | {
// To make sure remote cluster exists - to protect against random
// clusterName requests (e.g. when clusterName is set to local cluster name)
remoteCluster, err := a.Presence.GetRemoteCluster(clusterName)
if err != nil {
return nil, trace.Wrap(err)
}
if err := a.updateRemoteClusterStatus(remoteCluster); err... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L357-L370 | go | train | // GetRemoteClusters returns remote clusters with updated statuses | func (a *AuthServer) GetRemoteClusters(opts ...services.MarshalOption) ([]services.RemoteCluster, error) | // GetRemoteClusters returns remote clusters with updated statuses
func (a *AuthServer) GetRemoteClusters(opts ...services.MarshalOption) ([]services.RemoteCluster, error) | {
// To make sure remote cluster exists - to protect against random
// clusterName requests (e.g. when clusterName is set to local cluster name)
remoteClusters, err := a.Presence.GetRemoteClusters(opts...)
if err != nil {
return nil, trace.Wrap(err)
}
for i := range remoteClusters {
if err := a.updateRemoteC... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L599-L606 | go | train | // activateCertAuthority will activate both the user and host certificate
// authority given in the services.TrustedCluster resource. | func (a *AuthServer) activateCertAuthority(t services.TrustedCluster) error | // activateCertAuthority will activate both the user and host certificate
// authority given in the services.TrustedCluster resource.
func (a *AuthServer) activateCertAuthority(t services.TrustedCluster) error | {
err := a.ActivateCertAuthority(services.CertAuthID{Type: services.UserCA, DomainName: t.GetName()})
if err != nil {
return trace.Wrap(err)
}
return trace.Wrap(a.ActivateCertAuthority(services.CertAuthID{Type: services.HostCA, DomainName: t.GetName()}))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/trustedcluster.go#L621-L627 | go | train | // createReverseTunnel will create a services.ReverseTunnel givenin the
// services.TrustedCluster resource. | func (a *AuthServer) createReverseTunnel(t services.TrustedCluster) error | // createReverseTunnel will create a services.ReverseTunnel givenin the
// services.TrustedCluster resource.
func (a *AuthServer) createReverseTunnel(t services.TrustedCluster) error | {
reverseTunnel := services.NewReverseTunnel(
t.GetName(),
[]string{t.GetReverseTunnelAddress()},
)
return trace.Wrap(a.UpsertReverseTunnel(reverseTunnel))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/configuration.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L41-L51 | go | train | // GetClusterName gets the name of the cluster from the backend. | func (s *ClusterConfigurationService) GetClusterName(opts ...services.MarshalOption) (services.ClusterName, error) | // GetClusterName gets the name of the cluster from the backend.
func (s *ClusterConfigurationService) GetClusterName(opts ...services.MarshalOption) (services.ClusterName, error) | {
item, err := s.Get(context.TODO(), backend.Key(clusterConfigPrefix, namePrefix))
if err != nil {
if trace.IsNotFound(err) {
return nil, trace.NotFound("cluster name not found")
}
return nil, trace.Wrap(err)
}
return services.GetClusterNameMarshaler().Unmarshal(item.Value,
services.AddOptions(opts, ser... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/configuration.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L54-L63 | go | train | // DeleteClusterName deletes services.ClusterName from the backend. | func (s *ClusterConfigurationService) DeleteClusterName() error | // DeleteClusterName deletes services.ClusterName from the backend.
func (s *ClusterConfigurationService) DeleteClusterName() error | {
err := s.Delete(context.TODO(), backend.Key(clusterConfigPrefix, namePrefix))
if err != nil {
if trace.IsNotFound(err) {
return trace.NotFound("cluster configuration not found")
}
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/configuration.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L67-L83 | go | train | // SetClusterName sets the name of the cluster in the backend. SetClusterName
// can only be called once on a cluster after which it will return trace.AlreadyExists. | func (s *ClusterConfigurationService) SetClusterName(c services.ClusterName) error | // SetClusterName sets the name of the cluster in the backend. SetClusterName
// can only be called once on a cluster after which it will return trace.AlreadyExists.
func (s *ClusterConfigurationService) SetClusterName(c services.ClusterName) error | {
value, err := services.GetClusterNameMarshaler().Marshal(c)
if err != nil {
return trace.Wrap(err)
}
_, err = s.Create(context.TODO(), backend.Item{
Key: backend.Key(clusterConfigPrefix, namePrefix),
Value: value,
Expires: c.Expiry(),
})
if err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/configuration.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L106-L116 | go | train | // GetStaticTokens gets the list of static tokens used to provision nodes. | func (s *ClusterConfigurationService) GetStaticTokens() (services.StaticTokens, error) | // GetStaticTokens gets the list of static tokens used to provision nodes.
func (s *ClusterConfigurationService) GetStaticTokens() (services.StaticTokens, error) | {
item, err := s.Get(context.TODO(), backend.Key(clusterConfigPrefix, staticTokensPrefix))
if err != nil {
if trace.IsNotFound(err) {
return nil, trace.NotFound("static tokens not found")
}
return nil, trace.Wrap(err)
}
return services.GetStaticTokensMarshaler().Unmarshal(item.Value,
services.WithResour... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/configuration.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L119-L135 | go | train | // SetStaticTokens sets the list of static tokens used to provision nodes. | func (s *ClusterConfigurationService) SetStaticTokens(c services.StaticTokens) error | // SetStaticTokens sets the list of static tokens used to provision nodes.
func (s *ClusterConfigurationService) SetStaticTokens(c services.StaticTokens) error | {
value, err := services.GetStaticTokensMarshaler().Marshal(c)
if err != nil {
return trace.Wrap(err)
}
_, err = s.Put(context.TODO(), backend.Item{
Key: backend.Key(clusterConfigPrefix, staticTokensPrefix),
Value: value,
Expires: c.Expiry(),
ID: c.GetResourceID(),
})
if err != nil {
retur... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/configuration.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L138-L147 | go | train | // DeleteStaticTokens deletes static tokens | func (s *ClusterConfigurationService) DeleteStaticTokens() error | // DeleteStaticTokens deletes static tokens
func (s *ClusterConfigurationService) DeleteStaticTokens() error | {
err := s.Delete(context.TODO(), backend.Key(clusterConfigPrefix, staticTokensPrefix))
if err != nil {
if trace.IsNotFound(err) {
return trace.NotFound("static tokens are not found")
}
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/configuration.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L151-L161 | go | train | // GetAuthPreference fetches the cluster authentication preferences
// from the backend and return them. | func (s *ClusterConfigurationService) GetAuthPreference() (services.AuthPreference, error) | // GetAuthPreference fetches the cluster authentication preferences
// from the backend and return them.
func (s *ClusterConfigurationService) GetAuthPreference() (services.AuthPreference, error) | {
item, err := s.Get(context.TODO(), backend.Key(authPrefix, preferencePrefix, generalPrefix))
if err != nil {
if trace.IsNotFound(err) {
return nil, trace.NotFound("authentication preference not found")
}
return nil, trace.Wrap(err)
}
return services.GetAuthPreferenceMarshaler().Unmarshal(item.Value,
s... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/configuration.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L165-L183 | go | train | // SetAuthPreference sets the cluster authentication preferences
// on the backend. | func (s *ClusterConfigurationService) SetAuthPreference(preferences services.AuthPreference) error | // SetAuthPreference sets the cluster authentication preferences
// on the backend.
func (s *ClusterConfigurationService) SetAuthPreference(preferences services.AuthPreference) error | {
value, err := services.GetAuthPreferenceMarshaler().Marshal(preferences)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(authPrefix, preferencePrefix, generalPrefix),
Value: value,
ID: preferences.GetResourceID(),
}
_, err = s.Put(context.TODO(), item)
if err != ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/configuration.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L186-L197 | go | train | // GetClusterConfig gets services.ClusterConfig from the backend. | func (s *ClusterConfigurationService) GetClusterConfig(opts ...services.MarshalOption) (services.ClusterConfig, error) | // GetClusterConfig gets services.ClusterConfig from the backend.
func (s *ClusterConfigurationService) GetClusterConfig(opts ...services.MarshalOption) (services.ClusterConfig, error) | {
item, err := s.Get(context.TODO(), backend.Key(clusterConfigPrefix, generalPrefix))
if err != nil {
if trace.IsNotFound(err) {
return nil, trace.NotFound("cluster configuration not found")
}
return nil, trace.Wrap(err)
}
return services.GetClusterConfigMarshaler().Unmarshal(item.Value,
services.AddOpt... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/configuration.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L200-L209 | go | train | // DeleteClusterConfig deletes services.ClusterConfig from the backend. | func (s *ClusterConfigurationService) DeleteClusterConfig() error | // DeleteClusterConfig deletes services.ClusterConfig from the backend.
func (s *ClusterConfigurationService) DeleteClusterConfig() error | {
err := s.Delete(context.TODO(), backend.Key(clusterConfigPrefix, generalPrefix))
if err != nil {
if trace.IsNotFound(err) {
return trace.NotFound("cluster configuration not found")
}
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/local/configuration.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/local/configuration.go#L212-L230 | go | train | // SetClusterConfig sets services.ClusterConfig on the backend. | func (s *ClusterConfigurationService) SetClusterConfig(c services.ClusterConfig) error | // SetClusterConfig sets services.ClusterConfig on the backend.
func (s *ClusterConfigurationService) SetClusterConfig(c services.ClusterConfig) error | {
value, err := services.GetClusterConfigMarshaler().Marshal(c)
if err != nil {
return trace.Wrap(err)
}
item := backend.Item{
Key: backend.Key(clusterConfigPrefix, generalPrefix),
Value: value,
ID: c.GetResourceID(),
}
_, err = s.Put(context.TODO(), item)
if err != nil {
return trace.Wrap(err)... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/httplib/httpheaders.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httpheaders.go#L27-L31 | go | train | // SetNoCacheHeaders tells proxies and browsers do not cache the content | func SetNoCacheHeaders(h http.Header) | // SetNoCacheHeaders tells proxies and browsers do not cache the content
func SetNoCacheHeaders(h http.Header) | {
h.Set("Cache-Control", "no-cache, no-store, must-revalidate")
h.Set("Pragma", "no-cache")
h.Set("Expires", "0")
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/httplib/httpheaders.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/httplib/httpheaders.go#L40-L70 | go | train | // SetIndexHTMLHeaders sets security header flags for main index.html page | func SetIndexHTMLHeaders(h http.Header) | // SetIndexHTMLHeaders sets security header flags for main index.html page
func SetIndexHTMLHeaders(h http.Header) | {
SetNoCacheHeaders(h)
SetSameOriginIFrame(h)
SetNoSniff(h)
// X-Frame-Options indicates that the page can only be displayed in iframe on the same origin as the page itself
h.Set("X-Frame-Options", "SAMEORIGIN")
// X-XSS-Protection is a feature of Internet Explorer, Chrome and Safari that stops pages
// from ... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/kube/proxy/roundtrip.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/roundtrip.go#L99-L101 | go | train | // NewSpdyRoundTripperWithDialer creates a new SpdyRoundTripper that will use
// the specified tlsConfig. This function is mostly meant for unit tests. | func NewSpdyRoundTripperWithDialer(cfg roundTripperConfig) *SpdyRoundTripper | // NewSpdyRoundTripperWithDialer creates a new SpdyRoundTripper that will use
// the specified tlsConfig. This function is mostly meant for unit tests.
func NewSpdyRoundTripperWithDialer(cfg roundTripperConfig) *SpdyRoundTripper | {
return &SpdyRoundTripper{tlsConfig: cfg.tlsConfig, followRedirects: cfg.followRedirects, dialWithContext: cfg.dial, ctx: cfg.ctx, authCtx: cfg.authCtx, bearerToken: cfg.bearerToken}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/kube/proxy/roundtrip.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/roundtrip.go#L125-L127 | go | train | // dial dials the host specified by req | func (s *SpdyRoundTripper) dial(req *http.Request) (net.Conn, error) | // dial dials the host specified by req
func (s *SpdyRoundTripper) dial(req *http.Request) (net.Conn, error) | {
return s.dialWithoutProxy(req.URL)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/kube/proxy/roundtrip.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/roundtrip.go#L130-L172 | go | train | // dialWithoutProxy dials the host specified by url, using TLS if appropriate. | func (s *SpdyRoundTripper) dialWithoutProxy(url *url.URL) (net.Conn, error) | // dialWithoutProxy dials the host specified by url, using TLS if appropriate.
func (s *SpdyRoundTripper) dialWithoutProxy(url *url.URL) (net.Conn, error) | {
dialAddr := netutil.CanonicalAddr(url)
if url.Scheme == "http" {
switch {
case s.dialWithContext != nil:
return s.dialWithContext(s.ctx, "tcp", dialAddr)
default:
return net.Dial("tcp", dialAddr)
}
}
// TODO validate the TLSClientConfig is set up?
var conn *tls.Conn
var err error
if s.dialWith... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/kube/proxy/roundtrip.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/kube/proxy/roundtrip.go#L187-L241 | go | train | // RoundTrip executes the Request and upgrades it. After a successful upgrade,
// clients may call SpdyRoundTripper.Connection() to retrieve the upgraded
// connection. | func (s *SpdyRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) | // RoundTrip executes the Request and upgrades it. After a successful upgrade,
// clients may call SpdyRoundTripper.Connection() to retrieve the upgraded
// connection.
func (s *SpdyRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) | {
header := utilnet.CloneHeader(req.Header)
header.Add(httpstream.HeaderConnection, httpstream.HeaderUpgrade)
header.Add(httpstream.HeaderUpgrade, streamspdy.HeaderSpdy31)
// impersonation for remote clusters is handled by remote proxies
if !s.authCtx.cluster.isRemote {
header.Add("Impersonate-User", s.authCtx... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/srv/authhandlers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L59-L92 | go | train | // BuildIdentityContext returns an IdentityContext populated with information
// about the logged in user on the connection. | func (h *AuthHandlers) CreateIdentityContext(sconn *ssh.ServerConn) (IdentityContext, error) | // BuildIdentityContext returns an IdentityContext populated with information
// about the logged in user on the connection.
func (h *AuthHandlers) CreateIdentityContext(sconn *ssh.ServerConn) (IdentityContext, error) | {
identity := IdentityContext{
TeleportUser: sconn.Permissions.Extensions[utils.CertTeleportUser],
Certificate: []byte(sconn.Permissions.Extensions[utils.CertTeleportUserCertificate]),
Login: sconn.User(),
}
clusterName, err := h.AccessPoint.GetClusterName()
if err != nil {
return IdentityContext{... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/srv/authhandlers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L95-L101 | go | train | // CheckAgentForward checks if agent forwarding is allowed for the users RoleSet. | func (h *AuthHandlers) CheckAgentForward(ctx *ServerContext) error | // CheckAgentForward checks if agent forwarding is allowed for the users RoleSet.
func (h *AuthHandlers) CheckAgentForward(ctx *ServerContext) error | {
if err := ctx.Identity.RoleSet.CheckAgentForward(ctx.Identity.Login); err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/srv/authhandlers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L104-L125 | go | train | // CheckPortForward checks if port forwarding is allowed for the users RoleSet. | func (h *AuthHandlers) CheckPortForward(addr string, ctx *ServerContext) error | // CheckPortForward checks if port forwarding is allowed for the users RoleSet.
func (h *AuthHandlers) CheckPortForward(addr string, ctx *ServerContext) error | {
if ok := ctx.Identity.RoleSet.CanPortForward(); !ok {
systemErrorMessage := fmt.Sprintf("port forwarding not allowed by role set: %v", ctx.Identity.RoleSet)
userErrorMessage := "port forwarding not allowed"
// emit port forward failure event
h.AuditLog.EmitAuditEvent(events.PortForwardFailure, events.Event... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/srv/authhandlers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L129-L229 | go | train | // UserKeyAuth implements SSH client authentication using public keys and is
// called by the server every time the client connects. | func (h *AuthHandlers) UserKeyAuth(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) | // UserKeyAuth implements SSH client authentication using public keys and is
// called by the server every time the client connects.
func (h *AuthHandlers) UserKeyAuth(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) | {
fingerprint := fmt.Sprintf("%v %v", key.Type(), sshutils.Fingerprint(key))
// as soon as key auth starts, we know something about the connection, so
// update *log.Entry.
h.Entry = log.WithFields(log.Fields{
trace.Component: h.Component,
trace.ComponentFields: log.Fields{
"local": conn.LocalAddr(),... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/srv/authhandlers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L237-L263 | go | train | // HostKeyAuth implements host key verification and is called by the client
// to validate the certificate presented by the target server. If the target
// server presents a SSH certificate, we validate that it was Teleport that
// generated the certificate. If the target server presents a public key, if
// we are stri... | func (h *AuthHandlers) HostKeyAuth(addr string, remote net.Addr, key ssh.PublicKey) error | // HostKeyAuth implements host key verification and is called by the client
// to validate the certificate presented by the target server. If the target
// server presents a SSH certificate, we validate that it was Teleport that
// generated the certificate. If the target server presents a public key, if
// we are stri... | {
fingerprint := fmt.Sprintf("%v %v", key.Type(), sshutils.Fingerprint(key))
// update entry to include a fingerprint of the key so admins can track down
// the key causing problems
h.Entry = log.WithFields(log.Fields{
trace.Component: h.Component,
trace.ComponentFields: log.Fields{
"remote": remote.S... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/srv/authhandlers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L267-L281 | go | train | // hostKeyCallback allows connections to hosts that present keys only if
// strict host key checking is disabled. | func (h *AuthHandlers) hostKeyCallback(hostname string, remote net.Addr, key ssh.PublicKey) error | // hostKeyCallback allows connections to hosts that present keys only if
// strict host key checking is disabled.
func (h *AuthHandlers) hostKeyCallback(hostname string, remote net.Addr, key ssh.PublicKey) error | {
// If strict host key checking is enabled, reject host key fallback.
clusterConfig, err := h.AccessPoint.GetClusterConfig()
if err != nil {
return trace.Wrap(err)
}
if clusterConfig.GetProxyChecksHostKeys() == services.HostKeyCheckYes {
return trace.AccessDenied("remote host presented a public key, expected... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/srv/authhandlers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L285-L291 | go | train | // IsUserAuthority is called during checking the client key, to see if the
// key used to sign the certificate was a Teleport CA. | func (h *AuthHandlers) IsUserAuthority(cert ssh.PublicKey) bool | // IsUserAuthority is called during checking the client key, to see if the
// key used to sign the certificate was a Teleport CA.
func (h *AuthHandlers) IsUserAuthority(cert ssh.PublicKey) bool | {
if _, err := h.authorityForCert(services.UserCA, cert); err != nil {
return false
}
return true
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/srv/authhandlers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L296-L302 | go | train | // IsHostAuthority is called when checking the host certificate a server
// presents. It make sure that the key used to sign the host certificate was a
// Teleport CA. | func (h *AuthHandlers) IsHostAuthority(cert ssh.PublicKey, address string) bool | // IsHostAuthority is called when checking the host certificate a server
// presents. It make sure that the key used to sign the host certificate was a
// Teleport CA.
func (h *AuthHandlers) IsHostAuthority(cert ssh.PublicKey, address string) bool | {
if _, err := h.authorityForCert(services.HostCA, cert); err != nil {
h.Entry.Debugf("Unable to find SSH host CA: %v.", err)
return false
}
return true
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/srv/authhandlers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L307-L317 | go | train | // canLoginWithoutRBAC checks the given certificate (supplied by a connected
// client) to see if this certificate can be allowed to login as user:login
// pair to requested server. | func (h *AuthHandlers) canLoginWithoutRBAC(cert *ssh.Certificate, clusterName string, teleportUser, osUser string) error | // canLoginWithoutRBAC checks the given certificate (supplied by a connected
// client) to see if this certificate can be allowed to login as user:login
// pair to requested server.
func (h *AuthHandlers) canLoginWithoutRBAC(cert *ssh.Certificate, clusterName string, teleportUser, osUser string) error | {
h.Debugf("Checking permissions for (%v,%v) to login to node without RBAC checks.", teleportUser, osUser)
// check if the ca that signed the certificate is known to the cluster
_, err := h.authorityForCert(services.UserCA, cert.SignatureKey)
if err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/srv/authhandlers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L322-L344 | go | train | // canLoginWithRBAC checks the given certificate (supplied by a connected
// client) to see if this certificate can be allowed to login as user:login
// pair to requested server and if RBAC rules allow login. | func (h *AuthHandlers) canLoginWithRBAC(cert *ssh.Certificate, clusterName string, teleportUser, osUser string) error | // canLoginWithRBAC checks the given certificate (supplied by a connected
// client) to see if this certificate can be allowed to login as user:login
// pair to requested server and if RBAC rules allow login.
func (h *AuthHandlers) canLoginWithRBAC(cert *ssh.Certificate, clusterName string, teleportUser, osUser string)... | {
h.Debugf("Checking permissions for (%v,%v) to login to node with RBAC checks.", teleportUser, osUser)
// get the ca that signd the users certificate
ca, err := h.authorityForCert(services.UserCA, cert.SignatureKey)
if err != nil {
return trace.Wrap(err)
}
// get roles assigned to this user
roles, err := h... |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/srv/authhandlers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/authhandlers.go#L347-L381 | go | train | // fetchRoleSet fetches the services.RoleSet assigned to a Teleport user. | func (h *AuthHandlers) fetchRoleSet(cert *ssh.Certificate, ca services.CertAuthority, teleportUser string, clusterName string) (services.RoleSet, error) | // fetchRoleSet fetches the services.RoleSet assigned to a Teleport user.
func (h *AuthHandlers) fetchRoleSet(cert *ssh.Certificate, ca services.CertAuthority, teleportUser string, clusterName string) (services.RoleSet, error) | {
// for local users, go and check their individual permissions
var roles services.RoleSet
if clusterName == ca.GetClusterName() {
u, err := h.AccessPoint.GetUser(teleportUser)
if err != nil {
return nil, trace.Wrap(err)
}
// Pass along the traits so we get the substituted roles for this user.
roles, e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.