Merge pull request #1 from thijskh/wip_master_mdl-31938_fix_cas_auth

Thanks to Thijs Kinkhorst for the fixes!