Fred while this is most certainly possible, I don't think there's any publicly available example for how to achieve this.
For passing a custom redirect URL to the login modal, it's a bit complicated since Flarum uses a modal and has no native concept of redirect. One option would be to store the information in local storage or a cookie when the modal opens, and then apply that value after the page refreshes.
Another option would be to place the login form on a standalone page as it would provide more flexibility for redirects. I have a work in progress for such an extension, but currently it only modifies the SignUp part and not login https://github.com/flamarkt/signup-page
Most single sign on examples I can think of use an external website as the master and Flarum as a slave. The opposite seems to be less common at this time.