How to know the userid of a client doing a REST call to a Pr

Posted by kevin hermans on 08-Jun-2017 01:22

Dear,

At this moment we use the classic AppServer.
When some user connect to the AppServer we set the UserId of the database through the Connect combined with the Activate procedure of the AppServer
Connect procedure:

define input parameter ipcUserId    as character no-undo.
define input parameter ipcPassword  as character no-undo.
define input parameter ipcInfo      as character no-undo.

assign session:server-connection-context = set-value(session:server-connection-context,"USERID", ipcUserId).


Activate procedure:

/*This function does a setuserid*/
PUBLISH "Pro.SETUSERID" (get-value(session:server-connection-context, "USERID")).

But now we want to move for one project to the Progress application server(PAS) but can't find directly how to do this.

Somebody has an idea?

Kind regards
Kevin Hermans

Posted by Peter Judge on 08-Jun-2017 09:55

Oops, misread that it was from HTTP (REST). For ABL code you needn't change anything.

This should be tied into your authentication system. You should configure PASOE to create a client-principal (C-P) object and pass it into the agent. In the activate procedure you will be able to extract the user name (USER-ID or QUALIFIED-USER-ID attributes). Get the C-P from the SESSION:CURRENT-REQUEST-INFO's OERequestInfo instance via the GetClientPrincipal() method*.

Once you have that, you can do the PUBLISH.

* you MUST delete this handle since it is not autmoaticall garbage collected and every time you call the method a new instance of the CP is created in memory. It's not very big but it does add up over time.

I would look at the SESSION:CURRENT-REQUEST-INFO attribute's ClientContextId property,


and use that as a key for a context table. So don't publish the user ID externally.

You should replace the connect procedure and also do the initial setting in an activate proc (since we don't call the connect with user parameter). In PASOE you should do your authorisation with

You can do it in exactly the same way.

Or should be able to. There are few code changes that are _required_ - things relating to the fact that the PASOE server can server stateful and stateless requests simultaneously initially,.

All Replies

Posted by Peter Judge on 08-Jun-2017 09:55

Oops, misread that it was from HTTP (REST). For ABL code you needn't change anything.

This should be tied into your authentication system. You should configure PASOE to create a client-principal (C-P) object and pass it into the agent. In the activate procedure you will be able to extract the user name (USER-ID or QUALIFIED-USER-ID attributes). Get the C-P from the SESSION:CURRENT-REQUEST-INFO's OERequestInfo instance via the GetClientPrincipal() method*.

Once you have that, you can do the PUBLISH.

* you MUST delete this handle since it is not autmoaticall garbage collected and every time you call the method a new instance of the CP is created in memory. It's not very big but it does add up over time.

I would look at the SESSION:CURRENT-REQUEST-INFO attribute's ClientContextId property,


and use that as a key for a context table. So don't publish the user ID externally.

You should replace the connect procedure and also do the initial setting in an activate proc (since we don't call the connect with user parameter). In PASOE you should do your authorisation with

You can do it in exactly the same way.

Or should be able to. There are few code changes that are _required_ - things relating to the fact that the PASOE server can server stateful and stateless requests simultaneously initially,.

Posted by kevin hermans on 13-Jun-2017 06:56

Thank you Peter it works! :)  Nice and easy I like the way it's stays in the same line like the previous AppServer.

This thread is closed