In umbraco settings we have scheduled tasks node where you can set url of task you want to run. I am going to setup one up it points to ashx. What i wanted to know is in the ashx is there a way of determining that the url has been requested from umbraco scheduler is there someting in the request object to tell me that scheduler is making the call? Does scheduler run as a particular cms user eg admin and i can test for that?
It will probably just run as an anonymous user since ASP.Net itself is making a WebRequest behind the scenes. I'm not sure what kind of request headers get sent up by the ASP.Net sub system, but you can have a look. This still wouldn't be the most secure way to check if it is the scheduled task system since people can change request headers with things like Charles or Fiddler.
Thanks for replies. Sean nice suggestion but someone can easily fake that as well. Shannon i'm thinking i can check if request is being made from same host then i can assume scheduler is doing it?
Ismail, you could check if it comes from the same host but beware if you move to / are already running on multiple web nodes in which case the host of the referrer could change.
Alternatively, is there any chance you could just setup a ghost reference to the .ashx (e.g. using UrlRewriting or just a duplicate entry in your web.config file) which is only used by (and known to) the scheduling config? That way you know that ashx call is a scheduled call, anything else is manual
Is it still the case that the scheduled task runs as an anonymous user in 4.8.1? I want to call a /Base method and it would be great if I could set the allowGroup or allowType properties on the RestExtensionMethod attribute.
Scheduled task current user
Guys,
umbraco v:4.0.3 .net 35
In umbraco settings we have scheduled tasks node where you can set url of task you want to run. I am going to setup one up it points to ashx. What i wanted to know is in the ashx is there a way of determining that the url has been requested from umbraco scheduler is there someting in the request object to tell me that scheduler is making the call? Does scheduler run as a particular cms user eg admin and i can test for that?
Many thanks
Ismail
It will probably just run as an anonymous user since ASP.Net itself is making a WebRequest behind the scenes. I'm not sure what kind of request headers get sent up by the ASP.Net sub system, but you can have a look. This still wouldn't be the most secure way to check if it is the scheduled task system since people can change request headers with things like Charles or Fiddler.
You could always set a url parameter in the scheduled task settings:
Guys,
Thanks for replies. Sean nice suggestion but someone can easily fake that as well. Shannon i'm thinking i can check if request is being made from same host then i can assume scheduler is doing it?
Regards
Ismail
Ismail, you could check if it comes from the same host but beware if you move to / are already running on multiple web nodes in which case the host of the referrer could change.
Alternatively, is there any chance you could just setup a ghost reference to the .ashx (e.g. using UrlRewriting or just a duplicate entry in your web.config file) which is only used by (and known to) the scheduling config? That way you know that ashx call is a scheduled call, anything else is manual
Alex,
I did the same host thing but will keep your warning in mind. Really like the ghost suggestion.
Regards
Ismail
Hi guys,
Is it still the case that the scheduled task runs as an anonymous user in 4.8.1? I want to call a /Base method and it would be great if I could set the allowGroup or allowType properties on the RestExtensionMethod attribute.
Cheers,
Greg.
is working on a reply...