Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #9028 (closed)

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

Bug: omero.share in conn.CONFIG

Reported by: wmoore Owned by: wmoore
Priority: critical Milestone: OMERO-4.4
Component: Insight Version: n.a.
Keywords: n.a. Cc: web-team@…
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: 0.0d
Sprint: 2012-06-05 (16)

Description

If I browse to a share, open an Image in it etc. Then go back to "Data" and browse P/D/I tree, I get Security exception:

Request Method: GET
Request URL: http://localhost:8000/webclient/load_data/?view=tree

Traceback:
File "/Users/will/Desktop/OMERO/dist/lib/python/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/decorators.py" in wrapped
  320.             retval = f(request, *args, **kwargs)
File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/decorators.py" in wrapper
  354.             context = f(request, *args, **kwargs)
File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/webclient/views.py" in load_data
  445.         manager.listContainerHierarchy(filter_user_id)
File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/../omeroweb/webclient/controller/container.py" in listContainerHierarchy
  299.         pr_list = list(self.conn.listProjects(eid))
File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py" in getObjects
  2518.         result = self.getQueryService().findAllByQuery(query, params, self.CONFIG['SERVICE_OPTS'])
File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py" in __call__
  3267.             return self.handle_exception(e, *args, **kwargs)
File "/Users/will/Desktop/OMERO/components/tools/OmeroWeb/omeroweb/webclient/webclient_gateway.py" in handle_exception
  1825.                     e, *args, **kwargs)
File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py" in __call__
  3264.             return self.f(*args, **kwargs)
File "/Users/will/Desktop/OMERO/dist/lib/python/omero_api_IQuery_ice.py" in findAllByQuery
  213.             return _M_omero.api.IQuery._op_findAllByQuery.invoke(self, ((query, params), _ctx))

Exception Type: SecurityViolation at /webclient/load_data/
Exception Value: 

The _ctx in the last line appears as

_ctx 	{'omero.group': '3', 'omero.share': '1142'}

If I restart my development server then I can view the data tree again. If I try this on gretzky, it's kinda random whether I get this exception - guess it depends on which 'conn' my workers are picking up.

So, we need to be sure that we clear all 'omero.share' values from conn.CONFIGSERVICE_OPTS? in the omeroweb login_required, probably under

    def on_logged_in(self, request, conn):
        """
        Called whenever the users is successfully logged in.
        Sets the 'omero.group' option if specified in the constructor
        """
        if conn.CONFIG['SERVICE_OPTS'] is None:
            conn.CONFIG['SERVICE_OPTS'] = {}
        if self.omero_group is not None:
            conn.CONFIG['SERVICE_OPTS']['omero.group'] = str(self.omero_group)

Change History (4)

comment:1 Changed 7 years ago by atarkowska

as we no longer can relay on getEventContext you might want to fix it in:

def prepare_share_connection(self, request, conn, share_id):
    """Prepares the share connection if we have a valid share ID."""
    if share_id is None:
        if conn.getEventContext().shareId > 0:
            try:
                del conn.CONFIG['SERVICE_OPTS']['omero.share']
            except:
                pass

by removing if conn.getEventContext().shareId > 0:

comment:2 Changed 7 years ago by wmoore

That's almost exactly what I was going to do:

    def prepare_share_connection(self, request, conn, share_id):
        """Prepares the share connection if we have a valid share ID."""
        try:
            # we always need to clear any dirty 'omero.share' values from previous calls
            del conn.CONFIG['SERVICE_OPTS']['omero.share']
        except:
            pass
        if share_id is None:
            return None
        share = conn.getShare(share_id)
    ...

Even if we have a share_id, we still need to clean any 'omero.share' value from previous connections, since we don't want them confusing things E.g. if we fail to set a new share.

comment:3 Changed 7 years ago by wmoore

  • Resolution set to fixed
  • Status changed from new to closed

comment:4 Changed 7 years ago by Will Moore <will@…>

  • Remaining Time set to 0

(In [553ae2270115fc415f0d117d889dfd422c941d51/ome.git] on branch develop) Cleanup any dirty 'omero.share' from CONFIG. Closes #9028

Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.83231 sec.)

We're Hiring!