  We develop the Dirac-Schwinger-Zwanziger (DSZ) quantization of classical
abelian gauge theories with general duality structure on oriented Lorentzian
four-manifolds $(M,g)$ of arbitrary topology, obtaining, as a result, the
duality-covariant geometric formulation of such theories through connections on
principal bundles. We implement the DSZ condition by restricting the field
strengths of the theory to those which define classes originating in the
degree-two cohomology of a local system valued in the groupoid of integral
symplectic spaces. We prove that such field strengths are curvatures of
connections $\mathcal{A}$ defined on principal bundles $P$ whose structure
group $G$ is the disconnected group of automorphisms of an integral affine
symplectic torus. The connected component of the identity of $G$ is a torus
group, while its group of connected components is a modified Siegel modular
group. This formulation includes electromagnetic and magnetoelectric gauge
potentials on an equal footing and describes the equations of motion through a
first-order polarized self-duality condition for the curvature of
$\mathcal{A}$. The condition involves a combination of the Hodge operator of
$(M,g)$ with a taming of the duality structure determined by $P$, whose choice
encodes the self-couplings of the theory. This description is reminiscent of
the theory of four-dimensional euclidean instantons, even though we consider a
two-derivative theory in Lorentzian signature. We use this formulation to
characterize the hierarchy of duality groups of abelian gauge theory, providing
a gauge-theoretic description of the electromagnetic duality group as the
discrete remnant of the gauge group of $P$. We also perform the time-like
reduction of the polarized self-duality condition to a Riemannian
three-manifold, obtaining a new type of Bogomolny equation which we solve
explicitly in a particular case.
