diff --git a/server/server.go b/server/server.go index 5cfa6192a..e3f66d3c5 100644 --- a/server/server.go +++ b/server/server.go @@ -41,6 +41,16 @@ func NewServer(cfg *config.Config) (*Server, error) { // Add the initial admin keys to the list of admins. fb.AdditionalAdmins = cfg.InitialAdminKeys cfg = cfg.WithBackend(fb) + + // Create internal key. + _, err = keygen.NewWithWrite( + filepath.Join(cfg.DataPath, cfg.SSH.InternalKeyPath), + nil, + keygen.Ed25519, + ) + if err != nil { + return nil, err + } } srv := &Server{ diff --git a/ui/pages/selection/selection.go b/ui/pages/selection/selection.go index bfd1f31f6..944251ebf 100644 --- a/ui/pages/selection/selection.go +++ b/ui/pages/selection/selection.go @@ -9,6 +9,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/log" + "github.com/charmbracelet/soft-serve/server/backend" "github.com/charmbracelet/soft-serve/ui/common" "github.com/charmbracelet/soft-serve/ui/components/code" "github.com/charmbracelet/soft-serve/ui/components/selector" @@ -182,23 +183,30 @@ func (s *Selection) FullHelp() [][]key.Binding { func (s *Selection) Init() tea.Cmd { var readmeCmd tea.Cmd cfg := s.common.Config() + if cfg == nil { + return nil + } + pk := s.common.PublicKey() - if cfg == nil || pk == nil { + if pk == nil && !cfg.Backend.AllowKeyless() { return nil } + repos, err := cfg.Backend.Repositories() if err != nil { return common.ErrorCmd(err) } sortedItems := make(Items, 0) - // Put configured repos first for _, r := range repos { - item, err := NewItem(r, cfg) - if err != nil { - logger.Debugf("ui: failed to create item for %s: %v", r.Name(), err) - continue + al := cfg.Backend.AccessLevel(r.Name(), pk) + if al >= backend.ReadOnlyAccess { + item, err := NewItem(r, cfg) + if err != nil { + logger.Debugf("ui: failed to create item for %s: %v", r.Name(), err) + continue + } + sortedItems = append(sortedItems, item) } - sortedItems = append(sortedItems, item) } sort.Sort(sortedItems) items := make([]selector.IdentifiableItem, len(sortedItems))