Sunday, March 11, 2012

Login scheme with Atlas

Thanks for the help guys...

Do you need for info or are all my questions just too difficult to answer?


hello.

1. how are you checking the contents of each of those items? I mean, you say that you're getting the loggin pages? well, that shouldn't happen. the atlasglob.axd handler should return several javascript instructions with localized definitions. not sure on what you mean by atlas web service js file though...

2. well, the web authentication service uses the membership class for validating the credentials passed from the client side and the setauthcookie method of the formsauthentication class to generate the cookie that is used to identify the current session. it looks like you're not using this approach in your case (ie, you generate your own custom cookie instead of relying in the default that is generated by the formsauthentication class). what you can do is build your own web service which does that and then call this service instead of using the default authentication classes introduces by atlas (take a look at the authenticationwebservice class introduced by atlas on the server side).

3. what do you mean by this? well, if your web service method which performs the validation adds the necessary cookies to the current response object, they'll be automatically sent to the browser. as for redirecting, well, i'd say that the easiest way is to do that on the client callback method: when the credentials are valid, you'll automatically have the cookie added to the cookies collection so you just need to change the current location by using the window.location property.


Thanks for the reply Luis. Mydescription might have been a bit vague 'cause I was very tired at the time Iwrote it.

I useFirebug in Firefox. In Inspector mode you can look into the JS files. The errormessages I get is: missing ; beforestatement

atlasglob.axd (line 3)

<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

And

missing ; before statement

js (line 3)

<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

After a few seconds I get two “uncaughtexception: Access denied for Window.writeDebug” errors. I’ve tried to makea new Atlas site but I still get a similar error and atlasglob.axd still appearto contain the page that points to it. I almost sure it has to do with wrongconfigurations in web.config. Like I have two system.web blocks.. There isdefinitely some areas of the web.config that I don’t understand.

The reasons why I choose toimplement my own MembershipProvider and MembershipUser is because I want to usethe framework as much as possible, while not making any database changes. SoSys.Services.AuthenticationService.loginworks fine for me. It uses my MembershipProvider and validates fine. But afterthe validation I want to use GetUser from the MembershipProvider class andstore the user in the Cache object. But how can I do that from a webservice? Myversion of GetUser makes multiple database calls so I don't want to call itfrom every page. The nice thing about AJAXcompared to the current implementation is that I can send messages back to thebrowser about how far the initialization is, without updating the entire page.

I thought of a workaroundthat’s better but still.. Anyway can you install Firebug and verify that it isnot Firebug but my application that’s the problem?

Regards, Jon.


I'm actually having an issue releated to the credentials and the ajax... I'm not sure if it goes in this thread, but it's definitely something up here... I have a timer set to refresh the page every 5 minutes. The site is using windows authentication (passthrough if in IE). On the third or fouth time it refreshes the page, the credentials are then invalid and it prompts (infinitely) to login again, even in IE with passthrough authentication. Even if I type the correct password, it still prompts again. Now on the other hand, if I set this to Forms auth, and use the login controls and make the user login with their windows credentials, this doesn't happen... Is there just something about using passthrough windows authentication that doesn't work with XmlHTTPRequest? (The same issue happens in firefox when the user is prompted for credentials the first time, it'll keep them for a few refershes and then it pukes) I'm thinking the token expires, but I don't have this issue with non-ajax requests. Does the ajax request not call the same 'token refreshing' stuff that the loading of a page by hand does?
atlasglob.axd and my webservice (which Atlas transforms into javascript) had the login page because the user wasn't validated. If you have a site that requires login you have to allowanonymous access to the virtual folder "ScriptServices" that Atlas sets up behind the scenes. If you create a new Atlas web site from the create website dialog, VS will generate a web.config file for you and in that you will find:
<!-- Uncomment this if your site globally denies access to anonymous users. The authentication service and profile service are located under the virtual "ScriptServices" directory. Since you normally call the authentication web service with an un-authenticated user, the following location tag can be used to grant access to anonymous users. If you use anonymous profile support you will also need to grant access to anonymous users. <location path="ScriptServices"> <system.web> <authorization> <allow users="*" /> </authorization> </system.web> </location> -->

Sounds easy enough but what it doesn't state, is that has to come before your own authorization definition! Hope others will read this and not waste as much time as I have on this.

Cheers, Jon.

No comments:

Post a Comment