A characterisation of quadratic extensions contained in cyclic extensions of degree 4

Let $D$ be a squarefree integer. I am trying to prove that $\mathbb Q[\sqrt D]$ is contained in a Galois extension of $\mathbb Q$ with Galois group $\mathbb Z/4$ if and only if $D$ is the sum of two squares, $D = a^2 + b^2$ with $a,b\in \mathbb Q$.

The hint in the exercise in Dummit and Foote suggests considering the extension $\mathbb Q[\sqrt{s + s\sqrt D}]$ for the forward direction. However, I am unsure how to show that this extension is Galois, much less that its Galois group is cyclic of order 4.

For the reverse direction, I expressed the given Galois extension as $\mathbb Q[\sqrt{a+b\sqrt D}]$ for some $a,b\in \mathbb Q$. I showed that this extension has $\mathbb Q[\sqrt{c^2 – d^2 D}]$ as a subfield for some $c,d \in \mathbb Q$. From this, I deduced that the $\sqrt D$ and $\sqrt{c^2 – d^2 D}$ generate the same extension, so $\sqrt D = x \sqrt{c^2 – d^2 D}$ for some $x$, and hence that $D = \frac{x^2 c^2}{1 + x^2 d^2} $. It seems that there should be a way to decompose this as a sum of two squares, but I did not see how.

I did not tag this as homework as I am studying it independently.

Solutions Collecting From Web of "A characterisation of quadratic extensions contained in cyclic extensions of degree 4"

If $\Bbb Q \subset L$ has its Galois group $G$ cyclic of order $4$, then it has to be a quadratic extension of a quadratic extension of $\Bbb Q$, so there are $a,b,D \in \Bbb Q$ such that $\Bbb Q \subset \Bbb Q(\sqrt D) \subset \Bbb Q(\sqrt D, \sqrt{a + b \sqrt D}) = L$.

Given generic elements $a,b,D$ of $\Bbb Q$, this is not a Galois extension, its Galois closure is $\Bbb Q(\sqrt D, \sqrt{a + b\sqrt D}, \sqrt{a – b\sqrt D})$, and its Galois group $G’$ is a bit more complicated ($G’$ is the diedral group of order 8).
Now we can view $G$ as the only cyclic subgroup of $G’$ or order $4$.
The subfield of the generic extension fixed by $G$ is $\Bbb Q(\sqrt{D(a^2-b^2D)})$, and so for particular $a,b,D \in \Bbb Q$, $\Bbb Q(\sqrt{a+b\sqrt D})$ has Galois group $G$ if and only if $\Bbb Q = \Bbb Q(\sqrt{D(a^2-b^2D)}) \varsubsetneq \Bbb Q(\sqrt D, \sqrt{a^2-b^2D})$, which is equivalent to $D(a^2-b^2D)$ is a square, and $D$ is not a square.

Suppose $D(a^2-b^2D) = c^2$. Then, $Da^2 = c^2 + b^2D^2$, and $D = (c/a)^2 + (bD/a)^2$.
Suppose $D = x^2+y^2$ and is not a square. Then we can simply solve for $x = c/a$ and $y=bD/a$. For example, we can pick $a=D, c=xD$ and $b = y$ : then $D(a^2-b^2D) = D(D^2-y^2D) = D^2(D-y^2) = D^2x^2 = (Dx)^2$ which is a square as needed.