(Cross-posted from https://math.stackexchange.com/questions/2029407/ray-class-groups-through-binary-quadratic-forms)

If $d$ is the discriminant of a quadratic number field, then the primitive classes of binary quadratic forms of discriminant $d$ form a group isomorphic to the narrow ideal class group of $\mathbb{Q}(\sqrt{d})$. The classes of forms are equivalence classes under an action by $\mathrm{SL}_2(\mathbb{Z})$. My question is, is there a collection of subgroups of $\mathrm{SL_2}(\mathbb{Z})$ for which the sets of classes of forms of discriminant $d$ under action by these groups are in bijection with the narrow ray class groups of $\mathbb{Q}(\sqrt{d})$?

(I would hope that Gauss's composition operation, which is already well-defined at the level of classes under the action of $\begin{bmatrix} 1 & \mathbb{Z} \\ 0 & 1 \end{bmatrix}$, would provide a group operation that makes these bijections into isomorphisms of ray class groups.)