Archived

This forum has been archived. Please start a new discussion on GitHub.

glacier2: retrieve the session user id of who invokes a call

Hi,

We've got some servants running behind icegrid / glacier2

  • some servants run as root (1 instance each)
  • some are allocatable, they run as the authenticated user, in the icegrid xml it's set to activation="session" user="${session.id}"

A client user logs on via username/password (permission verifier) and creates the session. The default session manager is being used.

So now, at the server side, how do we get the user identity of who is invoking a remote call?
Can it be retrieved via the Current object?

Thanks in advance!

Comments

  • benoit
    benoit Rennes, France

    Hi,

    No, you can't retrieve this information through the Ice.Current object. I suggest that you setup a property in the server configuration with the session ID, for example:

    <property name="SessionId" value="${session.id}"/>
    

    You can then read this property in the servant implementation.

    Cheers,
    Benoit.

  • Oh perfect, thank you very much for this amazingly quick reply!

  • I guess this solves the problem for allocatable servants, but how would you know the user id when it makes a remote call on a 'root' service?

  • benoit
    benoit Rennes, France

    Hi,

    Can't you just rely on the property not being set for these servers? In other words, if the value of the {{SessionId}} property is empty, the servant assumes it's ran as root.

    Cheers,
    Benoit.

  • Hi,

    I do know which servant runs as root and which is allocated by whom, but what I'd like to know is: 'who is the user which makes a remote call to this root servant'?

    For example, servant S runs as root, then user X logs on via glacier2/permissionVerifier, the user X makes a remote method call to S... so now within S's method I'd like to know who the user was that made the call. (The answer should be user X.)

    Is this possible in any way? I've searched around, but I may have missed it.

    Thanks,
    Wout

  • benoit
    benoit Rennes, France

    Hi,

    Ice doesn't provide this information. This is something the client will need to provide to the server. You could use request contexts to pass this information.

    Cheers,
    Benoit.

  • Cool, using request contexts seems to be a nice and easy solution, thanks!