You could try one of those automation apps. I remember seeing some triggers for entering and leaving a location, and the advanced ones should be able to use wifi connections/disconnections
Whether it can change security settings though I’m not as sure about.