5.2 REST - system.variables.$USER.value

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

5.2 REST - system.variables.$USER.value

#1

Postby Steve James » Thu Sep 01, 2016 1:33 pm

Hi, I've done a clean install on a DEV server of 5.2 this morning. I've set it up to run under IIS so system.variables.$USER.value is populated from within a form.

I need to publish a RESTful web service but system.variables.$USER.value isn't being populated.

I've checked the header and Authorisation is being passed.

The user id is available to the API if I call it from a session that has already called a form (if that makes sense).

Please advise.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Thu Sep 01, 2016 3:06 pm

Do you mean system.variables.$USER is not available from a published REST service? That's correct - there is no userid associated with a REST service. The caller's userid isn't passed across as part of the call. I might have misunderstood the question.
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#3

Postby Steve James » Thu Sep 01, 2016 3:25 pm

Yes I mean that system.variables.$USER isn't available from a published REST service.

Can you explain why it isn't as this is a big issue.

thanks
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#4

Postby Jon » Thu Sep 01, 2016 3:42 pm

The idea is that a REST service is completely independent of the caller, and the caller could be anything - it doesn't have to be an Ebase application and the concept of a user may not apply. Similarly there is no built-in security for a REST service, we thought that customers who want to implement security would just pass authentication information as header variables, then they are free to encrypt/decrypt these in any way.

How were you planning on using $USER from the REST service? Maybe we can find another way.
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#5

Postby Steve James » Thu Sep 01, 2016 4:03 pm

Hi Jon, we are developing a dataPortal to bring datasets together in an api.

External users will not require any authorisation (there is the potential for partner data to require security and at this stage we were thinking oAuth or some other security mechanism).

I was intending (hoping) to validate an internal user so we can return data based on the user's name - eg access to a specific dataset or even return different content based on the userid (row based security).

Internally we want to get user's into Business Intelligence and they can consume rest services either through Excel Power Query or the likes of Power BI (Tableau etc).

I want the internal access to be seamless so 1 user can develop a model and then just distribute it out and other users just get the right data.

We've had a couple of thoughts about extracting the info from IIS and then pump it onto the Ebase REST or the potential to investigate what potential there is in our NetScallers.

Thanks
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#6

Postby Jon » Thu Sep 01, 2016 4:21 pm

Steve,

You should be able to get the user (if any) by calling client.request.getRemoteUser() from the REST code. This is the same call as the Ebase system makes to extract a Windows userid for an interactive session. I would guess that if the request is coming from a Windows app e.g. Excel, then this would return the Windows userid. You might find that it also contains the Windows domain name and you might need to strip this off.

Jon
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#7

Postby Steve James » Fri Sep 02, 2016 7:38 am

Ahhhh ok thanks.

I'm back in the office on Tues so will try then.
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#8

Postby Steve James » Tue Sep 06, 2016 8:14 am

Hi Jon, back in the office today and I've tried what you suggested.

That is attempting to get the user id via "client.request.getRemoteUser()"

I'm getting the following error
ReferenceError: "client" is not defined.
I've tried a different .net rest service that we have internally in both Power Query and Power BI and it works exactly as expected. That is anonymous requests are not supported so Power Query and Power BI whinge "the user was not authorized" until I select "Use my current Windows credentials"

I've also tried pointing PowerQuery and PowerBI at an Ebase form to prove that the Ebase Tomcat running under IIS can pass the credentials successfully. It does although the intial page back gives a 302 error so Power BI and Power Query do not actually show any of the content (this is just to prove the point rather than needing pull Ebase form content into Power BI and Power Query).

Thanks
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#9

Postby Jon » Tue Sep 06, 2016 9:17 am

"client" missing from the REST service API is our problem, we can address that in the next release. In the meantime you should be able to use this temporarily instead:

Code: Select all

var user = formservlets.HttpRegister.getHttpServletRequest().getRemoteUser();
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#10

Postby Steve James » Tue Sep 06, 2016 9:21 am

Thanks Jon, same issue with formservlets ie
ReferenceError: "formservlets" is not defined.
Thanks
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#11

Postby Jon » Tue Sep 06, 2016 9:27 am

Sorry, should be..

Code: Select all

Packages.formservlets.HttpRegister.getHttpServletRequest().getRemoteUser();
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#12

Postby Steve James » Tue Sep 06, 2016 9:33 am

Perfect, spot on.

Thanks very much Jon.
0 x


Who is online

Users browsing this forum: No registered users and 18 guests