(ctx ssh.Context, incomingKey ssh.PublicKey)
| 142 | } |
| 143 | |
| 144 | func (serv *Server) handlePublicKey(ctx ssh.Context, incomingKey ssh.PublicKey) bool { |
| 145 | slog := CtxLogger(ctx).With(). |
| 146 | Str("remote_user", ctx.User()). |
| 147 | Str("remote_addr", ctx.RemoteAddr().String()).Logger() |
| 148 | |
| 149 | remoteUser := ctx.User() |
| 150 | |
| 151 | config := serv.GetAdminConfig() |
| 152 | |
| 153 | pk := models.PublicKey{PublicKey: incomingKey} |
| 154 | |
| 155 | /* |
| 156 | if strings.HasPrefix(remoteUser, settings.Options.InvitePrefix) { |
| 157 | invite := remoteUser[len(settings.Options.InvitePrefix):] |
| 158 | |
| 159 | // Try to accept the invite. If this fails, bail out. Otherwise, |
| 160 | // continue looking up the user as normal. |
| 161 | if ok := serv.AcceptInvite(invite, models.PublicKey{incomingKey, ""}); !ok { |
| 162 | return false |
| 163 | } |
| 164 | |
| 165 | // If it succeeded, we actually need to pull the refreshed admin config |
| 166 | // so the new user shows up. |
| 167 | settings = serv.GetAdminConfig() |
| 168 | } |
| 169 | */ |
| 170 | |
| 171 | user, err := config.LookupUserFromKey(pk, remoteUser) |
| 172 | if err != nil { |
| 173 | slog.Warn().Err(err).Msg("User not found") |
| 174 | return false |
| 175 | } |
| 176 | |
| 177 | // Update the context with what we discovered |
| 178 | CtxSetUser(ctx, user) |
| 179 | CtxSetConfig(ctx, config) |
| 180 | CtxSetLogger(ctx, &slog) |
| 181 | CtxSetPublicKey(ctx, &pk) |
| 182 | |
| 183 | return true |
| 184 | } |
| 185 | |
| 186 | func (serv *Server) handleSession(s ssh.Session) { |
| 187 | var ctx context.Context = s.Context() |
nothing calls this directly
no test coverage detected