Skip to content

Commit

Permalink
fix(server): InitialAdminKeys config name
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed May 2, 2023
1 parent 4727a5d commit 5d177f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions server/backend/sqlite/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ func (d *SqliteBackend) AccessLevel(repo string, username string) backend.Access
//
// It implements backend.Backend.
func (d *SqliteBackend) AccessLevelByPublicKey(repo string, pk ssh.PublicKey) backend.AccessLevel {
ak := backend.MarshalAuthorizedKey(pk)
if strings.HasPrefix(d.cfg.InternalPublicKey, ak) {
if ik, _, err := backend.ParseAuthorizedKey(d.cfg.InternalPublicKey); err == nil && backend.KeysEqual(ik, pk) {
return backend.AdminAccess
}
for _, k := range d.cfg.InitialAdminKeys {
if k == ak {
ik, _, err := backend.ParseAuthorizedKey(k)
if err == nil && backend.KeysEqual(pk, ik) {
return backend.AdminAccess
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type Config struct {
Stats StatsConfig `envPrefix:"STATS_" yaml:"stats"`

// InitialAdminKeys is a list of public keys that will be added to the list of admins.
InitialAdminKeys []string `env:"INITIAL_ADMIN_KEY" envSeparator:"\n" yaml:"initial_admin_keys"`
InitialAdminKeys []string `env:"INITIAL_ADMIN_KEYS" envSeparator:"\n" yaml:"initial_admin_keys"`

// DataPath is the path to the directory where Soft Serve will store its data.
DataPath string `env:"DATA_PATH" yaml:"-"`
Expand Down
3 changes: 3 additions & 0 deletions server/config/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ stats:
# The address on which the stats server will listen.
listen_addr: "{{ .Stats.ListenAddr }}"
# Additional admin keys.
#initial_admin_keys:
# - "ssh-rsa AAAAB3NzaC1yc2..."
`))
)

Expand Down

0 comments on commit 5d177f5

Please sign in to comment.