Add key setting.
Add require_login.
Use moodle_url to redirect.