RESTful ws - access the current authenticated user

Using Servoy to administrate the content of your website? Discuss all webrelated Servoy topics on this forum!

RESTful ws - access the current authenticated user

Postby udrescu_bogdan » Wed Sep 08, 2010 1:31 pm

Hello,

I've implemented the new authentication mechanism for my RESTful service (http basic authentication).

I need to know in my RESTful methods who is the authenticated user each time the method is called - the user that is sent in the HTTP Authorization parameter and validated by servoy engine (I think). I tried to get the username/UUID from the security ( security.getUserUID() ), but it returns nothing.

Thank you,
Bogdan.
udrescu_bogdan
 
Posts: 336
Joined: Fri Jun 18, 2010 3:27 pm
Location: Craiova, Romania

Re: RESTful ws - access the current authenticated user

Postby tgs » Wed Sep 08, 2010 5:42 pm

Thomas Schnaus
SAN Developer
yomotec GmbH
User avatar
tgs
 
Posts: 886
Joined: Wed Oct 04, 2006 12:05 pm
Location: Germany

Re: RESTful ws - access the current authenticated user

Postby sbutler » Wed Sep 08, 2010 10:29 pm

The way the restful webservices plugin is implemented, you can't really implement authentication and get back the Servoy user id (at least not reliably). When you make a call to the webservice you can't expect to always be using the same client since the rest_ws plugin uses a pool of clients. The HTTP Auth option on the updated restful webservices plugin should only be used to restrict access to the web service. It should not be used for session info (like to get users id was used on the HTTP Auth) because that goes against the idea of a "Restful" web service. (although I agree it would be nice to be able to get that info)

If you want a statefull web service, where each client gets its own headless client on the server and can save session based info (and add table filters, etc), I can send you a demo of the web services plugin that we use.

The other option would be to request a new feature to support user/tenant filtering in the rest_ws plugin, but in proper restful format. So for example, instead of:
Code: Select all
http://<serverUrl>/servoy-service/rest_ws/solutionName/formName

You would need an option like:
Code: Select all
http://<serverUrl>/servoy-service/rest_ws/USERNAME/solutionName/formName

and then combine that with the http auth so that it restricts the authentication to only that USERNAME in the url. That would follow proper restful format, and would work better with the plugin since the USERNAME is being passed in the URL, so you can still do client pooling. The trick is to combine that with the HTTP Auth so that it restricts auth to that URL based on the USERNAME specified.
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: RESTful ws - access the current authenticated user

Postby Lachness » Sun Mar 13, 2011 9:54 pm

Hello,

http://<serverUrl>/servoy-service/rest_ws/USERNAME/solutionName/formName

Has anyone requested this addition to the webservice solution provided by Servoy?

I don't plan to use session info with the username/UID. But it would be a convenient way to tie information to the user.

These calls would be done in every webservice method.

Code: Select all
function ws_read(id) {

    if (id) {
        var userName = security.getRestUserName()
        var userInfo = myMethodGetInfo(userName)
        .......
        .......
      }
}
Lachlan Dunlop
LachNet, Inc
Mac OS 10.6, Windows 7 64bit, Gentoo Linux 64bit
Servoy 5.2x, 6.0x
Lachness
 
Posts: 51
Joined: Tue Feb 12, 2008 10:39 pm
Location: Saint Paul, MN USA

Re: RESTful ws - access the current authenticated user

Postby ptalbot » Mon Mar 14, 2011 12:36 am

Passing anything other than session IDs in a URL is a security breach.
Nothing would prevent anyone to "pretend" he is another user if you did it this way.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC


Return to Web Development

Who is online

Users browsing this forum: No registered users and 4 guests

cron