ScuttleBot

fix: bcrypt hash oper password for Ergo compatibility

lmata 2026-04-05 21:51 trunk
Commit 4e1758ef682c597d3181340bede19aff2313e5ecc05df1c95675ba944f2c3d05
1 file changed +5 -1
--- internal/ergo/ircdconfig.go
+++ internal/ergo/ircdconfig.go
@@ -3,10 +3,11 @@
33
import (
44
"bytes"
55
"text/template"
66
77
"github.com/conflicthq/scuttlebot/internal/config"
8
+ "golang.org/x/crypto/bcrypt"
89
)
910
1011
var ircdTemplate = template.Must(template.New("ircd").Parse(`# Generated by scuttlebot — do not edit manually.
1112
network:
1213
name: {{.NetworkName}}
@@ -87,11 +88,11 @@
8788
8889
opers:
8990
scuttlebot:
9091
class: server-admin
9192
whois-line: is a scuttlebot system operator
92
- password: "{{.APIToken}}"
93
+ password: "{{.OperPassHash}}"
9394
9495
oper-classes:
9596
server-admin:
9697
title: Server Admin
9798
capabilities:
@@ -125,10 +126,11 @@
125126
TLSDomain string
126127
TLSAddr string
127128
DataDir string
128129
APIAddr string
129130
APIToken string
131
+ OperPassHash string // bcrypt hash of APIToken for oper password
130132
HistoryEnabled bool
131133
PostgresDSN string
132134
MySQLEnabled bool
133135
MySQL config.MySQLConfig
134136
RequireSASL bool
@@ -135,19 +137,21 @@
135137
DefaultChannelModes string
136138
}
137139
138140
// GenerateConfig renders an ircd.yaml from the given ErgoConfig.
139141
func GenerateConfig(cfg config.ErgoConfig) ([]byte, error) {
142
+ operHash, _ := bcrypt.GenerateFromPassword([]byte(cfg.APIToken), bcrypt.MinCost)
140143
data := ircdTemplateData{
141144
NetworkName: cfg.NetworkName,
142145
ServerName: cfg.ServerName,
143146
IRCAddr: cfg.IRCAddr,
144147
TLSDomain: cfg.TLSDomain,
145148
TLSAddr: cfg.TLSAddr,
146149
DataDir: cfg.DataDir,
147150
APIAddr: cfg.APIAddr,
148151
APIToken: cfg.APIToken,
152
+ OperPassHash: string(operHash),
149153
HistoryEnabled: cfg.History.Enabled,
150154
PostgresDSN: cfg.History.PostgresDSN,
151155
MySQLEnabled: cfg.History.MySQL.Host != "" && cfg.History.PostgresDSN == "",
152156
MySQL: cfg.History.MySQL,
153157
RequireSASL: cfg.RequireSASL,
154158
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button