mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-25 21:39:25 +01:00
config: Fix accounts registration/authentication
This commit is contained in:
parent
d1cb4b9b37
commit
3058161f62
@ -8,7 +8,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). For the purpo
|
|||||||
New release of Oragono!
|
New release of Oragono!
|
||||||
|
|
||||||
### Config Changes
|
### Config Changes
|
||||||
|
* `registration` and `authentication-enabled` keys moved under `accounts` section.
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -78,7 +78,7 @@ func loadAccount(server *Server, tx *buntdb.Tx, accountKey string) *ClientAccoun
|
|||||||
// authenticateHandler parses the AUTHENTICATE command (for SASL authentication).
|
// authenticateHandler parses the AUTHENTICATE command (for SASL authentication).
|
||||||
func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||||
// sasl abort
|
// sasl abort
|
||||||
if !server.authenticationEnabled || len(msg.Params) == 1 && msg.Params[0] == "*" {
|
if !server.accountAuthenticationEnabled || len(msg.Params) == 1 && msg.Params[0] == "*" {
|
||||||
if client.saslInProgress {
|
if client.saslInProgress {
|
||||||
client.Send(nil, server.name, ERR_SASLABORTED, client.nick, "SASL authentication aborted")
|
client.Send(nil, server.name, ERR_SASLABORTED, client.nick, "SASL authentication aborted")
|
||||||
} else {
|
} else {
|
||||||
|
@ -145,10 +145,9 @@ type Config struct {
|
|||||||
Path string
|
Path string
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthenticationEnabled bool `yaml:"authentication-enabled"`
|
Accounts struct {
|
||||||
|
Registration AccountRegistrationConfig
|
||||||
Registration struct {
|
AuthenticationEnabled bool `yaml:"authentication-enabled"`
|
||||||
Accounts AccountRegistrationConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OperClasses map[string]*OperClassConfig `yaml:"oper-classes"`
|
OperClasses map[string]*OperClassConfig `yaml:"oper-classes"`
|
||||||
|
110
irc/server.go
110
irc/server.go
@ -80,44 +80,44 @@ type ListenerEvent struct {
|
|||||||
|
|
||||||
// Server is the main Oragono server.
|
// Server is the main Oragono server.
|
||||||
type Server struct {
|
type Server struct {
|
||||||
accountRegistration *AccountRegistration
|
accountRegistration *AccountRegistration
|
||||||
accounts map[string]*ClientAccount
|
accounts map[string]*ClientAccount
|
||||||
authenticationEnabled bool
|
accountAuthenticationEnabled bool
|
||||||
channels ChannelNameMap
|
channels ChannelNameMap
|
||||||
checkIdent bool
|
checkIdent bool
|
||||||
clients *ClientLookupSet
|
clients *ClientLookupSet
|
||||||
commands chan Command
|
commands chan Command
|
||||||
configFilename string
|
configFilename string
|
||||||
connectionThrottle *ConnectionThrottle
|
connectionThrottle *ConnectionThrottle
|
||||||
connectionThrottleMutex sync.Mutex // used when affecting the connection limiter, to make sure rehashing doesn't make things go out-of-whack
|
connectionThrottleMutex sync.Mutex // used when affecting the connection limiter, to make sure rehashing doesn't make things go out-of-whack
|
||||||
connectionLimits *ConnectionLimits
|
connectionLimits *ConnectionLimits
|
||||||
connectionLimitsMutex sync.Mutex // used when affecting the connection limiter, to make sure rehashing doesn't make things go out-of-whack
|
connectionLimitsMutex sync.Mutex // used when affecting the connection limiter, to make sure rehashing doesn't make things go out-of-whack
|
||||||
ctime time.Time
|
ctime time.Time
|
||||||
currentOpers map[*Client]bool
|
currentOpers map[*Client]bool
|
||||||
dlines *DLineManager
|
dlines *DLineManager
|
||||||
idle chan *Client
|
idle chan *Client
|
||||||
isupport *ISupportList
|
isupport *ISupportList
|
||||||
klines *KLineManager
|
klines *KLineManager
|
||||||
limits Limits
|
limits Limits
|
||||||
listenerEventActMutex sync.Mutex
|
listenerEventActMutex sync.Mutex
|
||||||
listeners map[string]ListenerInterface
|
listeners map[string]ListenerInterface
|
||||||
listenerUpdateMutex sync.Mutex
|
listenerUpdateMutex sync.Mutex
|
||||||
monitoring map[string][]Client
|
monitoring map[string][]Client
|
||||||
motdLines []string
|
motdLines []string
|
||||||
name string
|
name string
|
||||||
nameCasefolded string
|
nameCasefolded string
|
||||||
networkName string
|
networkName string
|
||||||
newConns chan clientConn
|
newConns chan clientConn
|
||||||
operators map[string]Oper
|
operators map[string]Oper
|
||||||
operclasses map[string]OperClass
|
operclasses map[string]OperClass
|
||||||
password []byte
|
password []byte
|
||||||
passwords *PasswordManager
|
passwords *PasswordManager
|
||||||
rehashMutex sync.Mutex
|
rehashMutex sync.Mutex
|
||||||
rehashSignal chan os.Signal
|
rehashSignal chan os.Signal
|
||||||
restAPI *RestAPIConfig
|
restAPI *RestAPIConfig
|
||||||
signals chan os.Signal
|
signals chan os.Signal
|
||||||
store *buntdb.DB
|
store *buntdb.DB
|
||||||
whoWas *WhoWasList
|
whoWas *WhoWasList
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -150,7 +150,7 @@ func NewServer(configFilename string, config *Config) *Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.AuthenticationEnabled {
|
if config.Accounts.AuthenticationEnabled {
|
||||||
SupportedCapabilities[SASL] = true
|
SupportedCapabilities[SASL] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,17 +178,17 @@ func NewServer(configFilename string, config *Config) *Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
server := &Server{
|
server := &Server{
|
||||||
accounts: make(map[string]*ClientAccount),
|
accounts: make(map[string]*ClientAccount),
|
||||||
authenticationEnabled: config.AuthenticationEnabled,
|
accountAuthenticationEnabled: config.Accounts.AuthenticationEnabled,
|
||||||
channels: make(ChannelNameMap),
|
channels: make(ChannelNameMap),
|
||||||
clients: NewClientLookupSet(),
|
clients: NewClientLookupSet(),
|
||||||
commands: make(chan Command),
|
commands: make(chan Command),
|
||||||
configFilename: configFilename,
|
configFilename: configFilename,
|
||||||
connectionLimits: connectionLimits,
|
connectionLimits: connectionLimits,
|
||||||
connectionThrottle: connectionThrottle,
|
connectionThrottle: connectionThrottle,
|
||||||
ctime: time.Now(),
|
ctime: time.Now(),
|
||||||
currentOpers: make(map[*Client]bool),
|
currentOpers: make(map[*Client]bool),
|
||||||
idle: make(chan *Client),
|
idle: make(chan *Client),
|
||||||
limits: Limits{
|
limits: Limits{
|
||||||
AwayLen: int(config.Limits.AwayLen),
|
AwayLen: int(config.Limits.AwayLen),
|
||||||
ChannelLen: int(config.Limits.ChannelLen),
|
ChannelLen: int(config.Limits.ChannelLen),
|
||||||
@ -297,7 +297,7 @@ func NewServer(configFilename string, config *Config) *Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// registration
|
// registration
|
||||||
accountReg := NewAccountRegistration(config.Registration.Accounts)
|
accountReg := NewAccountRegistration(config.Accounts.Registration)
|
||||||
server.accountRegistration = &accountReg
|
server.accountRegistration = &accountReg
|
||||||
|
|
||||||
// Attempt to clean up when receiving these signals.
|
// Attempt to clean up when receiving these signals.
|
||||||
@ -1286,17 +1286,17 @@ func (server *Server) rehash() error {
|
|||||||
removedCaps := make(CapabilitySet)
|
removedCaps := make(CapabilitySet)
|
||||||
|
|
||||||
// SASL
|
// SASL
|
||||||
if config.AuthenticationEnabled && !server.authenticationEnabled {
|
if config.Accounts.AuthenticationEnabled && !server.accountAuthenticationEnabled {
|
||||||
// enabling SASL
|
// enabling SASL
|
||||||
SupportedCapabilities[SASL] = true
|
SupportedCapabilities[SASL] = true
|
||||||
addedCaps[SASL] = true
|
addedCaps[SASL] = true
|
||||||
}
|
}
|
||||||
if !config.AuthenticationEnabled && server.authenticationEnabled {
|
if !config.Accounts.AuthenticationEnabled && server.accountAuthenticationEnabled {
|
||||||
// disabling SASL
|
// disabling SASL
|
||||||
SupportedCapabilities[SASL] = false
|
SupportedCapabilities[SASL] = false
|
||||||
removedCaps[SASL] = true
|
removedCaps[SASL] = true
|
||||||
}
|
}
|
||||||
server.authenticationEnabled = config.AuthenticationEnabled
|
server.accountAuthenticationEnabled = config.Accounts.AuthenticationEnabled
|
||||||
|
|
||||||
// burst new and removed caps
|
// burst new and removed caps
|
||||||
var capBurstClients ClientSet
|
var capBurstClients ClientSet
|
||||||
@ -1336,7 +1336,7 @@ func (server *Server) rehash() error {
|
|||||||
server.checkIdent = config.Server.CheckIdent
|
server.checkIdent = config.Server.CheckIdent
|
||||||
|
|
||||||
// registration
|
// registration
|
||||||
accountReg := NewAccountRegistration(config.Registration.Accounts)
|
accountReg := NewAccountRegistration(config.Accounts.Registration)
|
||||||
server.accountRegistration = &accountReg
|
server.accountRegistration = &accountReg
|
||||||
|
|
||||||
// set RPL_ISUPPORT
|
// set RPL_ISUPPORT
|
||||||
|
10
oragono.yaml
10
oragono.yaml
@ -97,10 +97,10 @@ server:
|
|||||||
- "127.0.0.1/8"
|
- "127.0.0.1/8"
|
||||||
- "::1/128"
|
- "::1/128"
|
||||||
|
|
||||||
# account/channel registration
|
# account options
|
||||||
registration:
|
accounts:
|
||||||
# account registration
|
# account registration
|
||||||
accounts:
|
registration:
|
||||||
# can users register new accounts?
|
# can users register new accounts?
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
@ -112,8 +112,8 @@ registration:
|
|||||||
enabled-callbacks:
|
enabled-callbacks:
|
||||||
- none # no verification needed, will instantly register successfully
|
- none # no verification needed, will instantly register successfully
|
||||||
|
|
||||||
# whether account authentication is enabled
|
# is account authentication enabled?
|
||||||
authentication-enabled: true
|
authentication-enabled: true
|
||||||
|
|
||||||
# operator classes
|
# operator classes
|
||||||
oper-classes:
|
oper-classes:
|
||||||
|
Loading…
Reference in New Issue
Block a user