move to zerolog
This commit is contained in:
8
auth.go
8
auth.go
@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"golang.org/x/crypto/ssh"
|
||||
|
||||
config "novit.tech/direktil/pkg/bootstrapconfig"
|
||||
@ -23,7 +23,7 @@ func localAuth() bool {
|
||||
}
|
||||
|
||||
if config.CheckPassword(auth.Password, sec) {
|
||||
log.Printf("login with auth %q", auth.Name)
|
||||
log.Info().Msgf("login with auth %q", auth.Name)
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -41,12 +41,12 @@ func sshCheckPubkey(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions,
|
||||
|
||||
allowedKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(auth.SSHKey))
|
||||
if err != nil {
|
||||
log.Printf("SSH pubkey for %q invalid: %v", auth.Name, auth.SSHKey)
|
||||
log.Warn().Err(err).Str("user", auth.Name).Str("key", auth.SSHKey).Msg("SSH public key is invalid")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if bytes.Equal(allowedKey.Marshal(), keyBytes) {
|
||||
log.Print("ssh: accepting public key for ", auth.Name)
|
||||
log.Info().Str("user", auth.Name).Msg("ssh: accepting public key")
|
||||
return &ssh.Permissions{
|
||||
Extensions: map[string]string{
|
||||
"pubkey-fp": ssh.FingerprintSHA256(key),
|
||||
|
Reference in New Issue
Block a user