protected function loadModules()
    {
        foreach ($this->config["authModules"] as $name) {
            try {
                $instance = $this->container->get($name);
            } catch (\League\Container\Exception\NotFoundException $e) {
                if (!class_exists($name)) {
                    throw new \RuntimeException("PicoAuth module not found: " . $name);
                }
                $instance = new $name;
            }

            if (!is_subclass_of($instance, Module\AbstractAuthModule::class, false)) {
                throw new \RuntimeException("PicoAuth module class must inherit from AbstractAuthModule.");
            }

            $name = $instance->getName();
            $this->modules[$name] = $instance;
        }
    }