diff options
author | Himbeer <himbeer@disroot.org> | 2024-11-16 23:17:27 +0100 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-11-17 16:32:50 +0100 |
commit | d0d39d2f9f3abb68eec146376b3233c8bc7c1cfa (patch) | |
tree | 70be515811406cdc3ba1ab8b56d3c6eccb2f0d59 /run.go | |
parent | e7d92562fcf05e4f9b7f6ba29b7cda529aab49bc (diff) |
Allow plugins to implement authentication backends
Design decisions:
* Config option specifies which of the registered backends is used
* Name conflicts (including with builtins) make the backend registration
fail
* Builtin backends are not moved to plugins to avoid breaking existing
setups confusion in general
* Builtin backends are exposed to plugins (and have been for some time);
Important information and internal methods are hidden to prevent
interference from malicious plugins
See doc/auth_backends.md and the related interface and function
documentation for details.
Closes #127.
Diffstat (limited to 'run.go')
-rw-r--r-- | run.go | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -20,11 +20,11 @@ func Run() { func runFunc() { if !Conf().NoPlugins { - loadPlugins() + LoadPlugins() } - var err error - switch Conf().AuthBackend { + authBackendName := Conf().AuthBackend + switch authBackendName { case "files": setAuthBackend(AuthFiles{}) case "mtsqlite3": @@ -41,8 +41,14 @@ func runFunc() { } setAuthBackend(ab) - default: + case "": log.Fatal("invalid auth backend") + default: + if ab, ok := authBackends[authBackendName]; ok { + setAuthBackend(ab) + } else { + log.Fatal("invalid auth backend") + } } addr, err := net.ResolveUDPAddr("udp", Conf().BindAddr) @@ -124,7 +130,7 @@ func runFunc() { } srvName, srv := conf.DefaultServerInfo() - lastSrv, err := authIface.LastSrv(cc.Name()) + lastSrv, err := DefaultAuth().LastSrv(cc.Name()) if err == nil && !conf.ForceDefaultSrv && lastSrv != srvName { choice, ok := conf.RandomGroupServer(lastSrv) if !ok { |