Skip to content

Commit

Permalink
feat: improve handling of SOFT_SERVE_INITIAL_ADMIN_KEY (#65)
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos A Becker <[email protected]>
  • Loading branch information
caarlos0 authored Jan 21, 2022
1 parent 5b1f545 commit c32ad0b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"path/filepath"
"strings"

"golang.org/x/crypto/ssh"
"gopkg.in/yaml.v2"

"fmt"
Expand Down Expand Up @@ -53,6 +54,16 @@ func NewConfig(cfg *config.Config) (*Config, error) {
host := cfg.Host
port := cfg.Port
pk := cfg.InitialAdminKey

if bts, err := os.ReadFile(pk); err == nil {
// pk is a file, set its contents as pk
pk = string(bts)
}
// it is a valid ssh key, nothing to do
if _, _, _, _, err := ssh.ParseAuthorizedKey([]byte(pk)); err != nil {
return nil, fmt.Errorf("invalid initial admin key: %w", err)
}

rs := git.NewRepoSource(cfg.RepoPath)
c := &Config{
Cfg: cfg,
Expand Down

0 comments on commit c32ad0b

Please sign in to comment.