Skip to content

Commit

Permalink
fix local re-register (#46182)
Browse files Browse the repository at this point in the history
  • Loading branch information
fspmarshall authored Sep 3, 2024
1 parent bc8bcdd commit c0e948f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/auth/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func LocalRegister(id state.IdentityID, authServer *Server, additionalPrincipals
}

// If local registration is happening and no remote address was passed in
// (which means no advertise IP was set), use localhost.
// (which means no advertise IP was set), use localhost. This behavior must
// be kept consistent with the equivalen behavior in cert rotation/re-register
// logic in lib/service.
if remoteAddr == "" {
remoteAddr = defaults.Localhost
}
Expand Down
7 changes: 6 additions & 1 deletion lib/service/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package service

import (
"cmp"
"context"
"crypto/tls"
"errors"
Expand Down Expand Up @@ -404,7 +405,11 @@ func (process *TeleportProcess) reRegister(conn *Connector, additionalPrincipals

if srv := process.getLocalAuth(); srv != nil {
clt = srv
remoteAddr = process.Config.AdvertiseIP
// auth server typically extracts remote addr from conn. since we're using the local auth
// directly we must supply a reasonable remote addr value. preferably the advertise IP, but
// otherwise localhost. this behavior must be kept consistent with the equivalent behavior
// in LocalRegister.
remoteAddr = cmp.Or(process.Config.AdvertiseIP, defaults.Localhost)
}

identity, err := auth.ReRegister(ctx, auth.ReRegisterParams{
Expand Down

0 comments on commit c0e948f

Please sign in to comment.