Lightweight and easily self-hostable Git forge. git.poy.ooo
git-forge selfhosting homebrew
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031package ssh
import ( "github.com/google/uuid" "golang.org/x/crypto/ssh")
const userIDKey = "user_id"const userHandleKey = "user_handle"const isAnonymousKey = "is_anonymous"
func AuthenticatePublicKey(store Store, conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) { fingerprint := ssh.FingerprintSHA256(key) user, err := store.UserByFingerprint(fingerprint)
if err != nil || user.ID == uuid.Nil { return &ssh.Permissions{ Extensions: map[string]string{ isAnonymousKey: "true", }, }, nil // no error = goes through }
return &ssh.Permissions{ Extensions: map[string]string{ userIDKey: user.ID.String(), userHandleKey: user.Handle, }, }, nil // no error = goes through}