ScuttleBot
fix: bcrypt hash oper password for Ergo compatibility
Commit
4e1758ef682c597d3181340bede19aff2313e5ecc05df1c95675ba944f2c3d05
Parent
a408eeee93d1fae…
1 file changed
+5
-1
+5
-1
| --- internal/ergo/ircdconfig.go | ||
| +++ internal/ergo/ircdconfig.go | ||
| @@ -3,10 +3,11 @@ | ||
| 3 | 3 | import ( |
| 4 | 4 | "bytes" |
| 5 | 5 | "text/template" |
| 6 | 6 | |
| 7 | 7 | "github.com/conflicthq/scuttlebot/internal/config" |
| 8 | + "golang.org/x/crypto/bcrypt" | |
| 8 | 9 | ) |
| 9 | 10 | |
| 10 | 11 | var ircdTemplate = template.Must(template.New("ircd").Parse(`# Generated by scuttlebot — do not edit manually. |
| 11 | 12 | network: |
| 12 | 13 | name: {{.NetworkName}} |
| @@ -87,11 +88,11 @@ | ||
| 87 | 88 | |
| 88 | 89 | opers: |
| 89 | 90 | scuttlebot: |
| 90 | 91 | class: server-admin |
| 91 | 92 | whois-line: is a scuttlebot system operator |
| 92 | - password: "{{.APIToken}}" | |
| 93 | + password: "{{.OperPassHash}}" | |
| 93 | 94 | |
| 94 | 95 | oper-classes: |
| 95 | 96 | server-admin: |
| 96 | 97 | title: Server Admin |
| 97 | 98 | capabilities: |
| @@ -125,10 +126,11 @@ | ||
| 125 | 126 | TLSDomain string |
| 126 | 127 | TLSAddr string |
| 127 | 128 | DataDir string |
| 128 | 129 | APIAddr string |
| 129 | 130 | APIToken string |
| 131 | + OperPassHash string // bcrypt hash of APIToken for oper password | |
| 130 | 132 | HistoryEnabled bool |
| 131 | 133 | PostgresDSN string |
| 132 | 134 | MySQLEnabled bool |
| 133 | 135 | MySQL config.MySQLConfig |
| 134 | 136 | RequireSASL bool |
| @@ -135,19 +137,21 @@ | ||
| 135 | 137 | DefaultChannelModes string |
| 136 | 138 | } |
| 137 | 139 | |
| 138 | 140 | // GenerateConfig renders an ircd.yaml from the given ErgoConfig. |
| 139 | 141 | func GenerateConfig(cfg config.ErgoConfig) ([]byte, error) { |
| 142 | + operHash, _ := bcrypt.GenerateFromPassword([]byte(cfg.APIToken), bcrypt.MinCost) | |
| 140 | 143 | data := ircdTemplateData{ |
| 141 | 144 | NetworkName: cfg.NetworkName, |
| 142 | 145 | ServerName: cfg.ServerName, |
| 143 | 146 | IRCAddr: cfg.IRCAddr, |
| 144 | 147 | TLSDomain: cfg.TLSDomain, |
| 145 | 148 | TLSAddr: cfg.TLSAddr, |
| 146 | 149 | DataDir: cfg.DataDir, |
| 147 | 150 | APIAddr: cfg.APIAddr, |
| 148 | 151 | APIToken: cfg.APIToken, |
| 152 | + OperPassHash: string(operHash), | |
| 149 | 153 | HistoryEnabled: cfg.History.Enabled, |
| 150 | 154 | PostgresDSN: cfg.History.PostgresDSN, |
| 151 | 155 | MySQLEnabled: cfg.History.MySQL.Host != "" && cfg.History.PostgresDSN == "", |
| 152 | 156 | MySQL: cfg.History.MySQL, |
| 153 | 157 | RequireSASL: cfg.RequireSASL, |
| 154 | 158 |
| --- internal/ergo/ircdconfig.go | |
| +++ internal/ergo/ircdconfig.go | |
| @@ -3,10 +3,11 @@ | |
| 3 | import ( |
| 4 | "bytes" |
| 5 | "text/template" |
| 6 | |
| 7 | "github.com/conflicthq/scuttlebot/internal/config" |
| 8 | ) |
| 9 | |
| 10 | var ircdTemplate = template.Must(template.New("ircd").Parse(`# Generated by scuttlebot — do not edit manually. |
| 11 | network: |
| 12 | name: {{.NetworkName}} |
| @@ -87,11 +88,11 @@ | |
| 87 | |
| 88 | opers: |
| 89 | scuttlebot: |
| 90 | class: server-admin |
| 91 | whois-line: is a scuttlebot system operator |
| 92 | password: "{{.APIToken}}" |
| 93 | |
| 94 | oper-classes: |
| 95 | server-admin: |
| 96 | title: Server Admin |
| 97 | capabilities: |
| @@ -125,10 +126,11 @@ | |
| 125 | TLSDomain string |
| 126 | TLSAddr string |
| 127 | DataDir string |
| 128 | APIAddr string |
| 129 | APIToken string |
| 130 | HistoryEnabled bool |
| 131 | PostgresDSN string |
| 132 | MySQLEnabled bool |
| 133 | MySQL config.MySQLConfig |
| 134 | RequireSASL bool |
| @@ -135,19 +137,21 @@ | |
| 135 | DefaultChannelModes string |
| 136 | } |
| 137 | |
| 138 | // GenerateConfig renders an ircd.yaml from the given ErgoConfig. |
| 139 | func GenerateConfig(cfg config.ErgoConfig) ([]byte, error) { |
| 140 | data := ircdTemplateData{ |
| 141 | NetworkName: cfg.NetworkName, |
| 142 | ServerName: cfg.ServerName, |
| 143 | IRCAddr: cfg.IRCAddr, |
| 144 | TLSDomain: cfg.TLSDomain, |
| 145 | TLSAddr: cfg.TLSAddr, |
| 146 | DataDir: cfg.DataDir, |
| 147 | APIAddr: cfg.APIAddr, |
| 148 | APIToken: cfg.APIToken, |
| 149 | HistoryEnabled: cfg.History.Enabled, |
| 150 | PostgresDSN: cfg.History.PostgresDSN, |
| 151 | MySQLEnabled: cfg.History.MySQL.Host != "" && cfg.History.PostgresDSN == "", |
| 152 | MySQL: cfg.History.MySQL, |
| 153 | RequireSASL: cfg.RequireSASL, |
| 154 |
| --- internal/ergo/ircdconfig.go | |
| +++ internal/ergo/ircdconfig.go | |
| @@ -3,10 +3,11 @@ | |
| 3 | import ( |
| 4 | "bytes" |
| 5 | "text/template" |
| 6 | |
| 7 | "github.com/conflicthq/scuttlebot/internal/config" |
| 8 | "golang.org/x/crypto/bcrypt" |
| 9 | ) |
| 10 | |
| 11 | var ircdTemplate = template.Must(template.New("ircd").Parse(`# Generated by scuttlebot — do not edit manually. |
| 12 | network: |
| 13 | name: {{.NetworkName}} |
| @@ -87,11 +88,11 @@ | |
| 88 | |
| 89 | opers: |
| 90 | scuttlebot: |
| 91 | class: server-admin |
| 92 | whois-line: is a scuttlebot system operator |
| 93 | password: "{{.OperPassHash}}" |
| 94 | |
| 95 | oper-classes: |
| 96 | server-admin: |
| 97 | title: Server Admin |
| 98 | capabilities: |
| @@ -125,10 +126,11 @@ | |
| 126 | TLSDomain string |
| 127 | TLSAddr string |
| 128 | DataDir string |
| 129 | APIAddr string |
| 130 | APIToken string |
| 131 | OperPassHash string // bcrypt hash of APIToken for oper password |
| 132 | HistoryEnabled bool |
| 133 | PostgresDSN string |
| 134 | MySQLEnabled bool |
| 135 | MySQL config.MySQLConfig |
| 136 | RequireSASL bool |
| @@ -135,19 +137,21 @@ | |
| 137 | DefaultChannelModes string |
| 138 | } |
| 139 | |
| 140 | // GenerateConfig renders an ircd.yaml from the given ErgoConfig. |
| 141 | func GenerateConfig(cfg config.ErgoConfig) ([]byte, error) { |
| 142 | operHash, _ := bcrypt.GenerateFromPassword([]byte(cfg.APIToken), bcrypt.MinCost) |
| 143 | data := ircdTemplateData{ |
| 144 | NetworkName: cfg.NetworkName, |
| 145 | ServerName: cfg.ServerName, |
| 146 | IRCAddr: cfg.IRCAddr, |
| 147 | TLSDomain: cfg.TLSDomain, |
| 148 | TLSAddr: cfg.TLSAddr, |
| 149 | DataDir: cfg.DataDir, |
| 150 | APIAddr: cfg.APIAddr, |
| 151 | APIToken: cfg.APIToken, |
| 152 | OperPassHash: string(operHash), |
| 153 | HistoryEnabled: cfg.History.Enabled, |
| 154 | PostgresDSN: cfg.History.PostgresDSN, |
| 155 | MySQLEnabled: cfg.History.MySQL.Host != "" && cfg.History.PostgresDSN == "", |
| 156 | MySQL: cfg.History.MySQL, |
| 157 | RequireSASL: cfg.RequireSASL, |
| 158 |