Showing posts with label integration. Show all posts
Showing posts with label integration. Show all posts

Monday, March 26, 2012

Integration with Authentication

I don't remember seeing this in the documentation, and it is rather early in the curve, but going forward, I think it would be good to hear some suggestions with how to properly integration with various Authentication schemes, such as Forms and Windows Authentication. Also, if there is something that I have missed, please point it out. Smile [:)]
Wally

Hi Wally,
there is a login method that you can use for Forms authentication:
var x = new Web.Services.AuthenticationService();
x.login("username", "password", _callback);

integration with asp.net services

Is there any documentation or examples online for creating atlas
applications that use the asp.net services?

Wally

--
Wallace B. McClure
"The Harder I Work, the Luckier I Get."
Listen to "The ASP.NET Podcast" at http://www.aspnetpodcast.com/
Database Award: http://url123.com/vc3er
Microsoft MVP - Visual Developer ASP/ASP.NET
AspInsider
"AJAX for ASP.NET" Coming Soon!
ADO.NET Book: http://url123.com/vc2bu
865-693-3004
118 Durwood Rd.
Knoxville, TN 37922
http://www.scalabledevelopment.com/
Blog: http://weblogs.asp.net/wallym/

Have you looked at theservices quickstarts? They have examples on doing this.

David


I have not seen any examples on integrating with things like membership,
authentication, and authorization. Do you have a URL?

Wally

wrote in message news:1196178@.66.129.67.202...
> Have you looked at the services quickstarts? They have examples on doing
> this.
>
> David
>
I have not seen any examples on integrating with things like membership,
authentication, and authorization. Do you have a URL?

Wally

wrote in message news:1196178@.66.129.67.202...
> Have you looked at the services quickstarts? They have examples on doing
> this.
>
> David
>
Sorry, I misunderstood your reference to "asp.net services" as meaning calling asmx asp.net web services from script. Let me check whether there is a sample relating to auth and membership.

The current integration with Membership and Forms authentication is limited to two methods on Web.Services.AuthenticationSerivce:

login

validateUser

The first method accepts a username, password and clientside event hookups for completion, errors and timeouts. Back on the server it validates the credentials with thedefault Membership provider. Assuming the call to ValidateUser succeeds, the "login" method returns a forms authentication cookie by calling FormsAuthentication.SetCookie(). When the call to ValidateUser succeeds, the result from "login" is true - failed credentials result in a "false" return value and no cookie.

The code for this looks something like:

function OnSubmitLogin() {
//Use the built in Atlas authentication service to make a call to the server.
//This call will verify credentials, and if the credentials are good, the server will
//issue a forms authentication cookie.
Web.Services.AuthenticationService.login(username.value, password.value, OnLoginComplete);
return false;
}

//The asynchronous completion event where you process the result of calling the server
function OnLoginComplete(result) {
password.value = '';

//On success there will be a forms authentication cookie in the browser.
if (result) {
username.value = '';
textLoggedIn.style.visibility = "visible";
textNotLoggedIn.style.visibility = "hidden";

buttonLoginLogout.innerText = "Click me to logout!";
buttonLoginLogout.onclick = OnSubmitLogout;
}
else {
textLoggedIn.style.visibility = "hidden";
textNotLoggedIn.style.visibility = "visible";
}
}

The "validateUser" works similarly to "login", but no forms auth cookie is set.


Awesome info. I had been scanning through the Atlas.js file and I was
trying to understand the difference between login and validateUser. That
info really helps.

Wally

wrote in message news:1197028@.66.129.67.202...
> The current integration with Membership and Forms authentication is
> limited to two methods on Web.Services.AuthenticationSerivce:
>
> login
>
> validateUser
>
> The first method accepts a username, password and clientside event hookups
> for completion, errors and timeouts. Back on the server it validates the
> credentials with the default Membership provider. Assuming the call to
> ValidateUser succeeds, the "login" method returns a forms authentication
> cookie by calling FormsAuthentication.SetCookie(). When the call to
> ValidateUser succeeds, the result from "login" is true - failed
> credentials result in a "false" return value and no cookie.
>
> The code for this looks something like:
>
> function OnSubmitLogin() {
> //Use the built in Atlas authentication service to make a call to the
> server.
> //This call will verify credentials, and if the credentials are good,
> the server will
> //issue a forms authentication cookie.
> Web.Services.AuthenticationService.login(username.value,
> password.value, OnLoginComplete);
> return false;
> }
>
> //The asynchronous completion event where you process the result of
> calling the server
> function OnLoginComplete(result) {
> password.value = '';
>
> //On success there will be a forms authentication cookie in the
> browser.
> if (result) {
> username.value = '';
> textLoggedIn.style.visibility = "visible";
> textNotLoggedIn.style.visibility = "hidden";
>
> buttonLoginLogout.innerText = "Click me to logout!";
> buttonLoginLogout.onclick = OnSubmitLogout;
> }
> else {
> textLoggedIn.style.visibility = "hidden";
> textNotLoggedIn.style.visibility = "visible";
> }
> }
>
> The "validateUser" works similarly to "login", but no forms auth cookie is
> set.
>
No problem. I had hoped that there was something I was missing in the
quickstarts. :-)

Wally

wrote in message news:1196977@.66.129.67.202...
> Sorry, I misunderstood your reference to "asp.net services" as meaning
> calling asmx asp.net web services from script. Let me check whether there
> is a sample relating to auth and membership.
>

Integration with ViewState

Sometimes, I store information in the viewstate statebag. Since this information goes back to the server on a roundtrip, I have access to the information. If I want to send that same information back to the server, how should I handle the situation where the information is stored in the statebag? Should I go back and use hidden fields that javascript can get at? is there some type of way to reach into the statebag from the client-side javascript? I realize that the statebag is not considered to be secure so would it be possible to include some type of javascript decoder in atlas to get at values in the statebag?
WallyHi Wally,
I didn't see any viewstate support at the moment, and I think Microsoft is thinking of AJAX methods as I. If you try the Atlas web controls you will see that there is no Click event for the server.

I don't think we'll be creating solutions to change view state from the client. Often times this is not possible - view state may be encrypted. More often though, its simply not efficient to try and parse that content using script.

However, server controls that preserve the server-based programming model, while providing richer experience will use view state creatively, to provide the right behavior if an ajax-style page does need to postback for some reason.