3
votes

Using PHP framework in Google App Engine, Cron job failed when I using the index.php url with login:required. I used login:admin for cron.

Refer my app.yaml file

app.yaml

application: my-app
version: 1
runtime: php55
api_version: 1


- url: /.*
  script: index.php
  login: required

- url: /backup_cron/remindermail
  static_dir: backup_cron/remindermail
  login: admin

I don't want use no login and login: admin to my index.php load.

My app can see all those who has Gmail login only. With no login cron job worked fine.

Is it possible with login:required used in first loading page?

With login:required

log details:

HTTP/1.1" 302

Request failed because URL requires user login. For requests invoked within App Engine (offline requests like Task Queue, or webhooks like XMPP and Incoming Mail), the URL must require admin login (or no login).

With no loginnd login:admin

Log details:

HTTP/1.1" 200

Success

1
Did you test cron on index.php without login at all? Or with login: admin? Also, what do the logs say? - MeLight
Thank for you reply MeLight. I updated log details in the post.Plz review - Sattanathan
It fails to run the cron job when login is set to 'login:admin'? - MeLight
sry, Login success when login is set to 'login:admin' - Sattanathan

1 Answers

2
votes

Crons can not access url's protected by login: required because they are not ran as users. From docs:

Note: While cron jobs can use URL paths restricted with login: admin, they cannot use URL paths restricted with login: required because cron scheduled tasks are not run as any user. The admin restriction is satisfied by the inclusion of the X-Appengine-Cron header described below.

Link here: https://cloud.google.com/appengine/docs/python/config/cron?hl=en#Python_app_yaml_Securing_URLs_for_cron

That being said, I suggest you use a specific handler for all your protected jobs. Or you could redirect non-logged in users.