We're Hiring!

allowing read access to all images via urls without credenti

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

allowing read access to all images via urls without credenti

Postby jwarren » Tue Jul 22, 2014 3:48 pm

Hi

For our project and omero instance all our images are publically available and I want to make them available via our web app and possibly some of the omero clients probably omero web and insight.

at the moment i can access images via our web app if I'm logged into the omero web client and then serve those images through my webapp like this as described in the docs
so in my jsp:

<img id="752" src="http://172.22.68.222:4080/webgateway/render_thumbnail/752/200" alt="image" title="30910.bmp" style="width: 200px;">

In the first instance I wouldn't mind being able to get my images using credentials with the url - but I can't find how to do this in the docs? Do I put user pass in the request header or directly on the url (obviously not very secure). But ideally I'd like to be able to have a user that can read access all my images on our omero instance without logging in via url? Can I do that? or set up a user/group that can do that for their files -so I just use the same user in my application?

Obviously I don't want anyone to be able to delete our images from the server though.

Any pointers on the best/easiest way to do this appreciated.

Thanks

Jonathan.
jwarren
 
Posts: 102
Joined: Wed Jul 09, 2014 1:35 pm

Re: allowing read access to all images via urls without cred

Postby wmoore » Wed Jul 23, 2014 9:35 am

Hi Johnathan,

Have a look at "Enabling a public user" under https://www.openmicroscopy.org/site/sup ... stallation

I think the public user functionality should do everything you want, although it is for web only (not Insight).

Let us know if you have any more questions, or suggestions on how to improve our docs to make this stuff easier to find.

Will.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: allowing read access to all images via urls without cred

Postby jwarren » Wed Jul 23, 2014 3:00 pm

Thanks Will. The link you have sent has given me the info that I want and I followed in the instructions.

I am stuck on the details of what to do at the end however. i.e. I have a public user and it belongs to the same group as the user I've uploaded images with. I can also log in to the web client as the public user and then request an image via my webapp which then appears.

If I log out of the omero client the image now fails to appear in my web-app. How do I get it to work when I'm not logged in? or how do I send the credentials for public user in the webgateway url via my jsp?

I ran the command at the end to get the public url accessible:

bin/omero config set omero.web.public.url_filter '/webgateway'

but when I look in the logs I get the message that the url is not a valid public url?
Code: Select all
2014-07-23 16:22:32,340 DEBUG [                     omeroweb.decorators] (proc.16193) wrapped:361 Connection not provided, attempting to get one.
2014-07-23 16:22:32,341 DEBUG [                     omeroweb.decorators] (proc.16193) get_authenticated_connection:260 Is SSL? False
2014-07-23 16:22:32,341 DEBUG [                     omeroweb.decorators] (proc.16193) get_authenticated_connection:262 Connector: None
2014-07-23 16:22:32,342 DEBUG [                     omeroweb.decorators] (proc.16193) get_authenticated_connection:274 No Server ID available.
2014-07-23 16:22:32,342 DEBUG [                     omeroweb.decorators] (proc.16193) get_connection:208 Is valid public URL? False
2014-07-23 16:22:32,342 DEBUG [                     omeroweb.decorators] (proc.16193) on_not_logged_in:122 Request is not Ajax, redirecting to /webclient/login/


Thanks in advance

Jonathan.
Last edited by jwarren on Wed Jul 23, 2014 3:29 pm, edited 1 time in total.
jwarren
 
Posts: 102
Joined: Wed Jul 09, 2014 1:35 pm

Re: allowing read access to all images via urls without cred

Postby wmoore » Wed Jul 23, 2014 3:23 pm

I should probably have referred you here for more info:
https://www.openmicroscopy.org/site/sup ... cData.html

Did you set any url_filter?
Assuming that you allow all 'webgateway' urls (as suggested in the above link), you should be OK for the webgateway/render_image that you wanted.

What do you see if you go to the image src in your browser? Do you get a 404?
E.g. a public image from our server is https://nightshade.openmicroscopy.org/w ... 5543/27/0/

All I can suggest is that you check each of the settings and make sure you haven't missed one of them.

Will.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: allowing read access to all images via urls without cred

Postby jwarren » Wed Jul 23, 2014 3:38 pm

I was editing my post above with the logs from the server while you were responding :)

The response is a 200 according to Chrome.

How do I know which server id I need - I'm assuming we just have one in our list but I'm not sure?
Also is there a config file where I can check if the commands I ran took effect? they didn't give a response to say whether they worked or not?
jwarren
 
Posts: 102
Joined: Wed Jul 09, 2014 1:35 pm

Re: allowing read access to all images via urls without cred

Postby jwarren » Wed Jul 23, 2014 3:54 pm

These were the commands I ran:
bin/omero config set omero.web.public.enabled True
bin/omero config set omero.web.public.user 'public_user'
bin/omero config set omero.web.public.password 'secret'

set a url pattern which I want them to be able to access via the url so:
bin/omero config set omero.web.public.url_filter '/webgateway'
jwarren
 
Posts: 102
Joined: Wed Jul 09, 2014 1:35 pm

Re: allowing read access to all images via urls without cred

Postby jwarren » Wed Jul 23, 2014 4:01 pm

although the 200 code is because it forwards me to the omero login page...
jwarren
 
Posts: 102
Joined: Wed Jul 09, 2014 1:35 pm

Re: allowing read access to all images via urls without cred

Postby wmoore » Wed Jul 23, 2014 9:17 pm

If you're getting redirected to the login page, it suggests that the url is not being matched by your url_filter.

E.g. if you edit the public webgateway/render_image url above, replacing webgateway with webclient then you are redirected to the login page, since we only allow webgateway urls with our filter. Whereas if you use a bogus image ID, E.g. https://nightshade.openmicroscopy.org/w ... e/123/0/0/ then you get a 404.

You can check regex matching with a script that we created (although this was for much more complex use cases where you need) https://gist.github.com/will-moore/8315580
E.g. if you simply have:

Code: Select all
test = '/webgateway'


and add an example like ``` /webgateway/render_image/123/1/2 ``` to the list of urls then this should be permitted by that filter.

You can check all your settings with:

Code: Select all
$ bin/omero config get


Hope that helps.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: allowing read access to all images via urls without cred

Postby jwarren » Thu Jul 24, 2014 10:49 am

Thanks for the reply Will.

The configuration looks correct to me but I still get redirected to login.
The version is 5.0.1

I'm not missing something simple like I have to restart the server for the config to take effect or anything like that?

even a '/' as the filter pattern doesn't work....

to be thorough I also tried the pattern matching script which give the following output:

bin/omero config set omero.web.public.url_filter '/webgateway'

True http://172.22.68.222:4080/webgateway/re ... e/1278/200
jwarren
 
Posts: 102
Joined: Wed Jul 09, 2014 1:35 pm

Re: allowing read access to all images via urls without cred

Postby wmoore » Thu Jul 24, 2014 11:05 am

Ah - you don't have to restart the OMERO server, but you do have to restart the web:

Code: Select all
$ bin/omero web stop
$ bin/omero web start


Hopefully that'll be all you need?
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Next

Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest