aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-10-05 15:34:47 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-10-05 15:34:47 +0200
commit39f2578e79b6db426ad3dd5db4898bcc7820e44a (patch)
treeee2764126083be71c4814bee7d17cb2218157aed /pkg
parent5fb240326bba79f6963f5d042dea824cdb9e8e45 (diff)
downloadcerrado-39f2578e79b6db426ad3dd5db4898bcc7820e44a.tar.gz
cerrado-39f2578e79b6db426ad3dd5db4898bcc7820e44a.tar.bz2
cerrado-39f2578e79b6db426ad3dd5db4898bcc7820e44a.zip
feat: Add hash and aes key to the config file
This should the base configuration for user. Bcrypt hash will be used to authenticate and aes key will be used to generate the token.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/config/config.go26
-rw-r--r--pkg/config/config_test.go4
2 files changed, 30 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
index fd19808..902ff0d 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -33,6 +33,8 @@ type (
Scan *scan
RootReadme string
ListenAddr string
+ Passphrase string
+ AESKey string
Repositories []*GitRepositoryConfiguration
}
@@ -52,6 +54,8 @@ type (
ConfigurationRepository struct {
rootReadme string
listenAddr string
+ passphrase string
+ aesKey string
repositories []*GitRepositoryConfiguration
}
)
@@ -71,6 +75,8 @@ func LoadConfigurationRepository(configPath string) (*ConfigurationRepository, e
rootReadme: config.RootReadme,
listenAddr: config.ListenAddr,
repositories: config.Repositories,
+ passphrase: config.Passphrase,
+ aesKey: config.AESKey,
}
if config.Scan.Path != "" {
@@ -170,6 +176,16 @@ func parse(r io.Reader) (*configuration, error) {
return nil, err
}
+ err = setPassphrase(block, &config.Passphrase)
+ if err != nil {
+ return nil, err
+ }
+
+ err = setAESKey(block, &config.AESKey)
+ if err != nil {
+ return nil, err
+ }
+
err = setRepositories(block, &config.Repositories)
if err != nil {
return nil, err
@@ -263,6 +279,16 @@ func setRootReadme(block scfg.Block, readme *string) error {
return setString(scanDir, readme)
}
+func setPassphrase(block scfg.Block, listenAddr *string) error {
+ scanDir := block.Get("passphrase")
+ return setString(scanDir, listenAddr)
+}
+
+func setAESKey(block scfg.Block, listenAddr *string) error {
+ scanDir := block.Get("aes-key")
+ return setString(scanDir, listenAddr)
+}
+
func setListenAddr(block scfg.Block, listenAddr *string) error {
scanDir := block.Get("listen-addr")
return setString(scanDir, listenAddr)
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index 8c1d27e..0970cfa 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -103,6 +103,8 @@ repository /srv/git/cerrado.git {
name: "complete",
config: `
listen-addr unix://var/run/cerrado/cerrado.sock
+passphrase $2a$14$VnB/ZcB1DUDkMnosRA6Y7.dj8h5eroslDxTeXlLwfQX/x86mh6WAq
+aes-key 8XHptZxSWCGs1m7QzztX5zNQ7D9NiQevVX0DaUTNMbDpRwFzoJiB0U7K6O/kqIt01jJVgzBUfiR8ES46ZLLb4w==
scan "/srv/git" {
public true
@@ -122,6 +124,8 @@ repository /srv/git/cerrado.git {
Path: "/srv/git",
},
ListenAddr: "unix://var/run/cerrado/cerrado.sock",
+ Passphrase: "$2a$14$VnB/ZcB1DUDkMnosRA6Y7.dj8h5eroslDxTeXlLwfQX/x86mh6WAq",
+ AESKey: "8XHptZxSWCGs1m7QzztX5zNQ7D9NiQevVX0DaUTNMbDpRwFzoJiB0U7K6O/kqIt01jJVgzBUfiR8ES46ZLLb4w==",
Repositories: []*GitRepositoryConfiguration{
{
Name: "linux.git",