refactor(middleware): extract auth-context middleware registration into testable submodule (#6008)