cms

A content management system wish ssh app. The goal of this library is to provide a wish middleware that lets users ssh into this app to manage their account as well as their posts.

setup

You are responsible for creating your own sql tables. A copy of the schema is in this repo.

import (
  "github.com/charmbracelet/wish"
	bm "github.com/charmbracelet/wish/bubbletea"
	"github.com/gliderlabs/ssh"
  "github.com/picosh/cms"
  "github.com/picosh/cms/config"
)

type SSHServer struct{}
func (me *SSHServer) authHandler(ctx ssh.Context, key ssh.PublicKey) bool {
	return true
}

func main() {
  cfg := config.NewConfigCms()
  handler := cms.Middleware(cfg)

  sshServer := &SSHServer{}
  s, err := wish.NewServer(
    wish.WithAddress(fmt.Sprintf("%s:%s", "localhost", "2222")),
    wish.WithHostKeyPath("ssh_data/term_info_ed25519"),
    wish.WithPublicKeyAuth(sshServer.authHandler),
    wish.WithMiddleware(bm.Middleware(handler)),
  )

  // ... the rest of the wish initialization
}

attribution

This code originated in part from https://github.com/charmbracelet/charm

GitHub

View Github