-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Use ssh_service.public_addrs in IsMFARequired check
#24070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,8 +49,10 @@ type Server interface { | |
| GetCmdLabels() map[string]CommandLabel | ||
| // SetCmdLabels sets command labels. | ||
| SetCmdLabels(cmdLabels map[string]CommandLabel) | ||
| // GetPublicAddr is an optional field that returns the public address this cluster can be reached at. | ||
| // GetPublicAddr returns a public address where this server can be reached. | ||
| GetPublicAddr() string | ||
| // GetPublicAddrs returns a list of public addresses where this server can be reached. | ||
| GetPublicAddrs() []string | ||
| // GetRotation gets the state of certificate authority rotation. | ||
| GetRotation() Rotation | ||
| // SetRotation sets the state of certificate authority rotation. | ||
|
|
@@ -63,8 +65,8 @@ type Server interface { | |
| String() string | ||
| // SetAddr sets server address | ||
| SetAddr(addr string) | ||
| // SetPublicAddr sets the public address this cluster can be reached at. | ||
| SetPublicAddr(string) | ||
| // SetPublicAddrs sets the public addresses where this server can be reached. | ||
| SetPublicAddrs([]string) | ||
| // SetNamespace sets server namespace | ||
| SetNamespace(namespace string) | ||
| // GetApps gets the list of applications this server is proxying. | ||
|
|
@@ -178,9 +180,13 @@ func (s *ServerV2) Expiry() time.Time { | |
| return s.Metadata.Expiry() | ||
| } | ||
|
|
||
| // SetPublicAddr sets the public address this cluster can be reached at. | ||
| func (s *ServerV2) SetPublicAddr(addr string) { | ||
| s.Spec.PublicAddr = addr | ||
| // SetPublicAddrs sets the public proxy addresses where this server can be reached. | ||
| func (s *ServerV2) SetPublicAddrs(addrs []string) { | ||
| s.Spec.PublicAddrs = addrs | ||
| // DELETE IN 15.0. (Joerger) PublicAddr deprecated in favor of PublicAddrs | ||
| if len(addrs) != 0 { | ||
| s.Spec.PublicAddr = addrs[0] | ||
| } | ||
| } | ||
|
|
||
| // GetName returns server name | ||
|
|
@@ -198,9 +204,22 @@ func (s *ServerV2) GetAddr() string { | |
| return s.Spec.Addr | ||
| } | ||
|
|
||
| // GetPublicAddr is an optional field that returns the public address this cluster can be reached at. | ||
| // GetPublicAddr returns a public address where this server can be reached. | ||
| func (s *ServerV2) GetPublicAddr() string { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this still needed? Should all callers be using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now this is just a helper function to return the first addr or empty string so we don't need to do the following for every caller: var addr string
if addrs := s.GetPublicAddrs(); len(addrs) != 0 {
adrr = s.Spec.PublicAddrs[0]
} |
||
| return s.Spec.PublicAddr | ||
| addrs := s.GetPublicAddrs() | ||
| if len(addrs) != 0 { | ||
| return addrs[0] | ||
| } | ||
| return "" | ||
| } | ||
|
|
||
| // GetPublicAddrs returns a list of public addresses where this server can be reached. | ||
| func (s *ServerV2) GetPublicAddrs() []string { | ||
| // DELETE IN 15.0. (Joerger) PublicAddr deprecated in favor of PublicAddrs | ||
| if len(s.Spec.PublicAddrs) == 0 && s.Spec.PublicAddr != "" { | ||
| return []string{s.Spec.PublicAddr} | ||
| } | ||
| return s.Spec.PublicAddrs | ||
| } | ||
|
|
||
| // GetRotation gets the state of certificate authority rotation. | ||
|
|
@@ -404,8 +423,8 @@ func (s *ServerV2) CheckAndSetDefaults() error { | |
| if s.Spec.Addr == "" { | ||
| return trace.BadParameter(`Addr must be set when server SubKind is "openssh"`) | ||
| } | ||
| if s.Spec.PublicAddr != "" { | ||
| return trace.BadParameter(`PublicAddr must not be set when server SubKind is "openssh"`) | ||
| if len(s.GetPublicAddrs()) != 0 { | ||
| return trace.BadParameter(`PublicAddrs must not be set when server SubKind is "openssh"`) | ||
| } | ||
| if s.Spec.Hostname == "" { | ||
| return trace.BadParameter(`Hostname must be set when server SubKind is "openssh"`) | ||
|
|
@@ -436,6 +455,7 @@ func (s *ServerV2) MatchSearch(values []string) bool { | |
|
|
||
| if s.GetKind() == KindNode { | ||
| fieldVals = append(utils.MapToStrings(s.GetAllLabels()), s.GetName(), s.GetHostname(), s.GetAddr()) | ||
| fieldVals = append(fieldVals, s.GetPublicAddrs()...) | ||
|
|
||
| if s.GetUseTunnel() { | ||
| custom = func(val string) bool { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.