Claims based login for resftul api
I'd like to see an expansion on this post http://www.sitefinity.com/blogs/svetlayankova/posts/11-11-01/getting_started_with_restful_services_in_sitefinity.aspx using the new claims based authentication
Hi Kristian,
Thank you for your suggestion!
We'll try to have this rolled out by the end of the week.
All the best,
Svetla
the Telerik team
Any word on this information being released? There is a similar thread that went unanswered as well. Thanks.
Hi Kristian and Charles,
Attached is a code sample that accomplishes the task.
A quick run-through of the sample:
Thank you for the detailed response! I know a lot of other people will find this extremely helpful as well. I think this should be part of the official documentation in some form whether it's the exact sample or an outline of the necessary steps. It's essential to fully leverage the restful api services.
Again, this is a great start. However, it does not provide a mechanism to log yourself out if you're logged in a different session. This happens to me often while testing different browsers if I forget to log off. There isn't sample code in the forums on how to do this programmatically server side. You can use sitefinity's own self sign out page but many people want to do this automatically to bypass it. My current workaround is to edit the database table directly which I know is not recommended. Can this even be done with the provided restful api?
I have a code snippet that automatically logs the user out, then logs the user in. I think this solution can be modified to assist you with the functionality you are looking for.
var currentUser = SecurityManager.AuthenticateUser(System.Web.Security.Membership.Provider.Name, username, pwd, rememberMe);
if
(currentUser == UserLoggingReason.UserAlreadyLoggedIn)
SecurityManager.Logout();
currentUser = SecurityManager.AuthenticateUser(Membership.Provider.Name, username, pwd, rememberMe);
I'm trying to get this working with 5.1 and the same application suffers the same fate as my homegrown solution. Both are able to authenticate and get a token but then they fail to authorize on subsequent calls.
When I run this sample against my 5.1 installation it gets logged in, but upon clicking "List Data" the call to the SF API gets a 401.