Add a sasl set-plain
command
This allows to manually set the SASL credentials for a network.
This commit is contained in:
parent
cd3eacdbfc
commit
2a3ae55f52
@ -173,6 +173,9 @@ abbreviated form, for instance *network* can be abbreviated as *net* or just
|
||||
*certfp reset* <network name>
|
||||
Disable SASL EXTERNAL authentication and remove stored certificate.
|
||||
|
||||
*sasl set-plain* <network name> <username> <password>
|
||||
Set SASL PLAIN credentials.
|
||||
|
||||
*user create* -username <username> -password <password> [-admin]
|
||||
Create a new soju user. Only admin users can create new accounts.
|
||||
|
||||
|
31
service.go
31
service.go
@ -187,6 +187,15 @@ func init() {
|
||||
},
|
||||
},
|
||||
},
|
||||
"sasl": {
|
||||
children: serviceCommandSet{
|
||||
"set-plain": {
|
||||
usage: "<network name> <username> <password>",
|
||||
desc: "set SASL PLAIN credentials",
|
||||
handle: handleServiceSASLSetPlain,
|
||||
},
|
||||
},
|
||||
},
|
||||
"user": {
|
||||
children: serviceCommandSet{
|
||||
"create": {
|
||||
@ -588,6 +597,28 @@ func handleServiceCertfpReset(dc *downstreamConn, params []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleServiceSASLSetPlain(dc *downstreamConn, params []string) error {
|
||||
if len(params) != 3 {
|
||||
return fmt.Errorf("expected exactly 3 arguments")
|
||||
}
|
||||
|
||||
net := dc.user.getNetwork(params[0])
|
||||
if net == nil {
|
||||
return fmt.Errorf("unknown network %q", params[0])
|
||||
}
|
||||
|
||||
net.SASL.Plain.Username = params[1]
|
||||
net.SASL.Plain.Password = params[2]
|
||||
net.SASL.Mechanism = "PLAIN"
|
||||
|
||||
if err := dc.srv.db.StoreNetwork(net.Username, &net.Network); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sendServicePRIVMSG(dc, "credentials saved")
|
||||
return nil
|
||||
}
|
||||
|
||||
func handlePasswordChange(dc *downstreamConn, params []string) error {
|
||||
if len(params) != 1 {
|
||||
return fmt.Errorf("expected exactly one argument")
|
||||
|
Loading…
Reference in New Issue
Block a user