On 29 August 2012 21:11, Nate Coraor <nate@bx.psu.edu> wrote:
On Aug 24, 2012, at 9:48 AM, Mutlu Dogruel wrote:

> Hi folk,
>
> Do you know any method for reading (the extended) WSGI HTTP headers
> from a custom tool?
>
> If I put some debugging lines in
> $galaxy/lib/galaxy/web/framework/middleware/xforwardedhost.py, I can
> read the HTTP headers I want. But I need to access them under
> tools/my_script.py. Is there a way to reach the "webapp"s http headers
> from there?

Hi Mutlu,

Do you mean the headers at the time of tool execution?  Running tools (jobs) is intentionally decoupled from the state of the front end.  However, you could modify the tool submission to store the header as a tool parameter and pass it in the command template.

--nate

>
> Thanks.
> Mutlu
> ___________________________________________________________
> Please keep all replies on the list by using "reply all"
> in your mail client.  To manage your subscriptions to this
> and other Galaxy lists, please use the interface at:
>
>  http://lists.bx.psu.edu/



Thanks for the reply. Yes, this is what I am trying to achieve. But in my case, I need to read the headers before the tool is run, and to be more precise, just before dynamic_options creates a selection list. Because it's the dynamic_options script that needs the http header values.

Essentially, I need to get some AWS keys from the http headers. We inject AWS keys and secrets into http headers on a proxy server that Galaxy is sitting behind. I have a customised upload.xml and upload.py for managing downloads from S3 buckets (I kept the original upload scripts as well). In this scenario, a list of available, permitted S3 files are generated by dynamics_options, according to the AWS keys. The user-selected file is later downloaded from Amazon using its URL. This is handled by Galaxy's native URL downloader. It works fine if I read the AWS keys from a local file, but of course, the keys do not have to be static.

I just started to look into lib/galaxy/tools/parameters/dynamic_options.py, can this be a good starting point?

Thanks,
Best regards,
--
Mutlu