5d177f53752b4abef76e37655425e9b855efd19b

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix(server): InitialAdminKeys config name

Diff

 1diff --git a/server/backend/sqlite/user.go b/server/backend/sqlite/user.go
 2index 86d36ac1e84d443910e7a5dfe0714f57f416777d..1afa8085fcac43779cba4dbdc3e2657aa185bde6 100644
 3--- a/server/backend/sqlite/user.go
 4+++ b/server/backend/sqlite/user.go
 5@@ -118,12 +118,12 @@ func (d *SqliteBackend) AccessLevel(repo string, username string) backend.Access
 6 //
 7 // It implements backend.Backend.
 8 func (d *SqliteBackend) AccessLevelByPublicKey(repo string, pk ssh.PublicKey) backend.AccessLevel {
 9-	ak := backend.MarshalAuthorizedKey(pk)
10-	if strings.HasPrefix(d.cfg.InternalPublicKey, ak) {
11+	if ik, _, err := backend.ParseAuthorizedKey(d.cfg.InternalPublicKey); err == nil && backend.KeysEqual(ik, pk) {
12 		return backend.AdminAccess
13 	}
14 	for _, k := range d.cfg.InitialAdminKeys {
15-		if k == ak {
16+		ik, _, err := backend.ParseAuthorizedKey(k)
17+		if err == nil && backend.KeysEqual(pk, ik) {
18 			return backend.AdminAccess
19 		}
20 	}
21diff --git a/server/config/config.go b/server/config/config.go
22index 1418e4b8b938d976d22caa7a33d81647d110a758..b72dae3c31e91ac3dcef59ee84fd97db2cab789e 100644
23--- a/server/config/config.go
24+++ b/server/config/config.go
25@@ -89,7 +89,7 @@ type Config struct {
26 	Stats StatsConfig `envPrefix:"STATS_" yaml:"stats"`
27 
28 	// InitialAdminKeys is a list of public keys that will be added to the list of admins.
29-	InitialAdminKeys []string `env:"INITIAL_ADMIN_KEY" envSeparator:"\n" yaml:"initial_admin_keys"`
30+	InitialAdminKeys []string `env:"INITIAL_ADMIN_KEYS" envSeparator:"\n" yaml:"initial_admin_keys"`
31 
32 	// DataPath is the path to the directory where Soft Serve will store its data.
33 	DataPath string `env:"DATA_PATH" yaml:"-"`
34diff --git a/server/config/file.go b/server/config/file.go
35index 7ee81d5293d91ef32c9acdb989c5c3f31047d10d..d436e14b1022bcfa339aab8194f6b32e6f2957a4 100644
36--- a/server/config/file.go
37+++ b/server/config/file.go
38@@ -75,6 +75,9 @@ stats:
39   # The address on which the stats server will listen.
40   listen_addr: "{{ .Stats.ListenAddr }}"
41 
42+# Additional admin keys.
43+#initial_admin_keys:
44+#  - "ssh-rsa AAAAB3NzaC1yc2..."
45 `))
46 )
47