This issue has been migrated from #16275.
This was added in matrix-org/synapse#16117 and matrix-org/synapse#16125 (note this needed the fix in matrix-org/synapse#16216).
Reverted in matrix-org/synapse#16258 due it being broken.
We should reintroduce these PRs (with fixes) once we have some CI for OIDC.
cc @hughns @sandhose