473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

forms authentication with loginurl on a remote machine

Hi,

I am making a web application (rather two applications) one which is host
and used by customers when they are just browsing through products.
The second application resides on a secure server. This is going to hold all
account related information for the customers and will also be used for
admin

The login is implemented using forms authentication and i was just reading
up about that... but as everyone already knows.... its all scattered
everywhere...
now
<forms name="CUSTOM.ASPXAUTH"
loginurl="http://mysecuresever/myapplication/login.aspx" />
it is mentioned a couple of places that if it is a remote machine... and not
a local machine they should have the same decryption key.

did a search on decryptionkey and found:
This article describes how to create keys to use for encryption, decryption,
and validation of Forms authentication cookie data. You can use the keys
that you create in this article for the validationKey and the decryptionKey
attributes of the <machineKey> section in the <system.web> element in the
Machine.config and the Web.config files.

now my question is that if i did create the machine key under <system.web>
and specified the keys.... would i then be able to use the cookie set on
both the machines ?

ie can i use it on my app1 to check whether the client is logged in and can
i in app2 (on secure server) use the same cookie for showing customer
related information ?

all this is so messed up.... would be great if someone could help get me a
half decent step in right direction

--
Regards,

HD
Nov 18 '05 #1
9 4605
Hi Hermit,
Thank you for using Microsoft Newsgroup Service. Based on your description.
You've build two ASP.NET web applications(they a part of one web
application logically). Since you used the form authentication and the
login page is on one server, you want the other web app(on another server)
shared the authentication cookie and common cookie info set by the login
web app. Is my understanding of your problem correct?

For this problem, it belongs to the Multi hosting Web applications such as
web farm situation. Generally in ASP.NET web application all the datas set
and retrieve via Response.Cookie or Request.Cookie are encrypted using a
certain key, the key is able to be set in the "MachineKey" element in the
web.config or machine.config file. In addition, the authentication cookie
for the FormAuthentication is auto checked and generated, if you want to
make them identity and shared in different asp.net web application, it's
necessary to set the following features:

1. The Cookie name: The asp.net runtime will retrieve the authentication
cookie via this name, it is set in the "forms" element in web.config as
below:
<forms loginUrl="login.aspx" name="formsauth1" timeout="60" path="/" >
<credentials passwordFormat="Clear">
<user name="username" password="password"/>
</credentials>
</forms>
2. also, the "path" attribute is also important, but you can remain the
default value "/" so that the authentication cookie
will be sent to each web app.

3. the Machine key. We can also override this in web.config:
<machineKey validationKey="You custom key" decryptionKey="You custom key"
validation="SHA1" />
If multiple applications use identical, explicit values for the
<machineKey> element, an authentication cookie that is sent from one
application is decrypted by another application successfully.

For more information on the above features, you can refer the tech articles
in MSDN:

Forms Authentication Requests Are Not Directed to loginUrl Page
http://support.microsoft.com/?id=313116

Create Keys by Using Visual C# .NET for Use in Forms Authentication
http://support.microsoft.com/?id=312906

Hosting Multiple Web Applications
http://msdn.microsoft.com/library/de...us/dnnetsec/ht
ml/thcmch20.asp

If you have any questions on it, please feel free to let me know.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 18 '05 #2
Steven,

Thanks for writing in. Gotta read up a bit cause i have an 70-315 tomorrow
but i will give it a try some time in coming days.

One thing though - is it necessary for the config file to have user info and
does the passwordFormat have to be cleartext ?
Will look up the articles and thanks a lot,

HD

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:py**************@cpmsftngxa07.phx.gbl...
Hi Hermit,
Thank you for using Microsoft Newsgroup Service. Based on your description. You've build two ASP.NET web applications(they a part of one web
application logically). Since you used the form authentication and the
login page is on one server, you want the other web app(on another server)
shared the authentication cookie and common cookie info set by the login
web app. Is my understanding of your problem correct?

For this problem, it belongs to the Multi hosting Web applications such as
web farm situation. Generally in ASP.NET web application all the datas set
and retrieve via Response.Cookie or Request.Cookie are encrypted using a
certain key, the key is able to be set in the "MachineKey" element in the
web.config or machine.config file. In addition, the authentication cookie
for the FormAuthentication is auto checked and generated, if you want to
make them identity and shared in different asp.net web application, it's
necessary to set the following features:

1. The Cookie name: The asp.net runtime will retrieve the authentication
cookie via this name, it is set in the "forms" element in web.config as
below:
<forms loginUrl="login.aspx" name="formsauth1" timeout="60" path="/" >
<credentials passwordFormat="Clear">
<user name="username" password="password"/>
</credentials>
</forms>
2. also, the "path" attribute is also important, but you can remain the
default value "/" so that the authentication cookie
will be sent to each web app.

3. the Machine key. We can also override this in web.config:
<machineKey validationKey="You custom key" decryptionKey="You custom key"
validation="SHA1" />
If multiple applications use identical, explicit values for the
<machineKey> element, an authentication cookie that is sent from one
application is decrypted by another application successfully.

For more information on the above features, you can refer the tech articles in MSDN:

Forms Authentication Requests Are Not Directed to loginUrl Page
http://support.microsoft.com/?id=313116

Create Keys by Using Visual C# .NET for Use in Forms Authentication
http://support.microsoft.com/?id=312906

Hosting Multiple Web Applications
http://msdn.microsoft.com/library/de...us/dnnetsec/ht ml/thcmch20.asp

If you have any questions on it, please feel free to let me know.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3
Hi Hermit,

Thanks for your response. As for the FormAuthentication, it provides some
buildin authorization such as
alow="*"
deny="?" or explicitly specify some user names. However I always think you
can generate a custom database for storing user
account infos and do the user checking and authorization mannually.
And as for the format the password sent, normally such authentication mode
as "Base authentication", "form authentication" which need the client to
provide user credentials(passwords) all send the credentials in clear
text(encoded by base64). So if you use such authentication mode, it is
recommended that you use some security protection on the datas transfers
between the client and server, for example, the "SSL".

In addition, I've reviewd the MSDN on the Formauthentication and found some
articles mainly aimed at "FormAuthentication", here is one which confirms
the problem we discussed in the former messages:

#Forms Authentication Across Applications
http://msdn.microsoft.com/library/en...sauthenticatio
nacrossapplications.asp?frame=true

#the main topic on FormAuthentication
http://msdn.microsoft.com/library/en...ookieauthentic
ationprovider.asp?frame=true

Please check out the above suggestion to see whether they are helpful. If
you have any questions , feel free to let me know.
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 18 '05 #4
Hi Hermit,
Have you had a chance to try my suggestion or have you resolved the
problem? If you need any help, please feel
free to let me know .
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #5
Steven,

I had already set the machine key value for one of the apps... all i had to
do was use the same machine key and authentication across.
all i did was just copied the web.config file over to the other place...

yes i am already using authenticaiton and role info stored in the db and am
hashing the password before storage during registration.

And it did work just fine on my local dev machine with two different apps.

The only difference in web.config files is that the loginurl for one of the
app specifies the absolute url of second apps authentication module.
And the authentication ticket is being shared across the apps...
I still havent uploaded the to the webservers... am making some changes in
registration and would like to test it out before i put it up...

Thanks a lot.... i havent had a chance to read those articles just yet but
will do...
Till next time...
--
Regards,

HD

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:v%***************@cpmsftngxa07.phx.gbl...
Hi Hermit,
Have you had a chance to try my suggestion or have you resolved the
problem? If you need any help, please feel
free to let me know .
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #6
Steven,

Just a quick query.... in the two apps i have... it works fine on my local
machine... but was talking to someone who was implementing a very similar
method.... and it was then that i noticed... that the returnURL value...
when it was forwarded to secure application contained
"/virtualdir/virtualdir2/index.aspx"
This would mean that in a scenario like mine.. where the second app is on a
different server i would have to set a manual redirection to the first
applicaton... (cause returnURL is not a fully qualified URL....

however i did notice... that passport authentication (i know its a totally
different mechanism) but the returnURL is indeed fully qualified...

Was also reading some posts earlier when someone mentioned that the behavior
was indeed very similar till beta 1 but was later on change to not have full
URL
would appreciate you comments on this...

--
Regards,

HD

PS: still havent tried it on my live servers (messed up the permissions on
db and am waiting for it to be restored... )

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Steven,

I had already set the machine key value for one of the apps... all i had to do was use the same machine key and authentication across.
all i did was just copied the web.config file over to the other place...

yes i am already using authenticaiton and role info stored in the db and am hashing the password before storage during registration.

And it did work just fine on my local dev machine with two different apps.

The only difference in web.config files is that the loginurl for one of the app specifies the absolute url of second apps authentication module.
And the authentication ticket is being shared across the apps...
I still havent uploaded the to the webservers... am making some changes in
registration and would like to test it out before i put it up...

Thanks a lot.... i havent had a chance to read those articles just yet but
will do...
Till next time...
--
Regards,

HD

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:v%***************@cpmsftngxa07.phx.gbl...
Hi Hermit,
Have you had a chance to try my suggestion or have you resolved the
problem? If you need any help, please feel
free to let me know .
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 18 '05 #7
Hi Hermit,
Thanks for your response. As for the problem you described in the reply.
The "ReturnUrl" will be cut to a relative path to the "localhost". I've
reviewed some materials of the ASP.NET FormsAuthentication, haven't found
any docs that explictly mentioned on this. However, I think since in the
"web farm"(multi server) situation for FormsAuthentication, we've specify
the identical Machinekey in the config files. We can manually create the
auth ticket/Cookie and redirect to whatever page(url) we want.(that is
basically, replacing the RedirectFromLoginPage call.) Here is an sample
shows generating a custom authentication ticket/cookie and redirect to a
path.

http://msdn.microsoft.com/library/en...websecurityfor
msauthenticationclassgetredirecturltopic.asp?frame =true

Hope it helps.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #8
Steven,

I am already creating the authentication ticket...

look everything works fine... the only thing is the the returnUTL param
passed to the second app's login contains a relative URL not a full URL

my app looks like this

http://www.myclientsdomain.com
this has a directory where i have set to allow only Adminitrators role...
http://www.myclientsdomain.com/admindir

the authentication and role information is set on another domain
https://secureserver.com/myclientsdomain
on a page called Login.aspx

now when someone tries to access http://www.myclientsdomain.com/admindir
they are redirected to
http://securesever.com/myclientsdoma...dir/index.aspx

This page authenticates the user and since the returnURL is not valid it
would i would have to manually redirect
http://www.myclientsdomain.com/admindir/index.aspx

when using passport i have seen returnURL having the full URL not relative
URL
ie with passport authentication it would be
https://passport.com/whateverpage?re...ndir/index.asp

though all of the return params would be URL encoded... but you see what i
mean right ?

Thanks,

--

Regards,

HD
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:1c**************@cpmsftngxa07.phx.gbl...
Hi Hermit,
Thanks for your response. As for the problem you described in the reply.
The "ReturnUrl" will be cut to a relative path to the "localhost". I've
reviewed some materials of the ASP.NET FormsAuthentication, haven't found
any docs that explictly mentioned on this. However, I think since in the
"web farm"(multi server) situation for FormsAuthentication, we've specify
the identical Machinekey in the config files. We can manually create the
auth ticket/Cookie and redirect to whatever page(url) we want.(that is
basically, replacing the RedirectFromLoginPage call.) Here is an sample
shows generating a custom authentication ticket/cookie and redirect to a
path.

http://msdn.microsoft.com/library/en...websecurityfor msauthenticationclassgetredirecturltopic.asp?frame =true

Hope it helps.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #9
Steven,

Just to let you know... think i am going to drop the idea of second server..
having some issues with the host.... so will try it some other day now...

thanks for all the help...

--

Regards,

HD
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP09.phx.gbl...
Steven,

I am already creating the authentication ticket...

look everything works fine... the only thing is the the returnUTL param
passed to the second app's login contains a relative URL not a full URL

my app looks like this

http://www.myclientsdomain.com
this has a directory where i have set to allow only Adminitrators role...
http://www.myclientsdomain.com/admindir

the authentication and role information is set on another domain
https://secureserver.com/myclientsdomain
on a page called Login.aspx

now when someone tries to access http://www.myclientsdomain.com/admindir
they are redirected to
http://securesever.com/myclientsdoma...dir/index.aspx
This page authenticates the user and since the returnURL is not valid it
would i would have to manually redirect
http://www.myclientsdomain.com/admindir/index.aspx

when using passport i have seen returnURL having the full URL not relative
URL
ie with passport authentication it would be
https://passport.com/whateverpage?re...ndir/index.asp
though all of the return params would be URL encoded... but you see what i
mean right ?

Thanks,

--

Regards,

HD
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:1c**************@cpmsftngxa07.phx.gbl...
Hi Hermit,
Thanks for your response. As for the problem you described in the reply.
The "ReturnUrl" will be cut to a relative path to the "localhost". I've
reviewed some materials of the ASP.NET FormsAuthentication, haven't found any docs that explictly mentioned on this. However, I think since in the
"web farm"(multi server) situation for FormsAuthentication, we've specify the identical Machinekey in the config files. We can manually create the
auth ticket/Cookie and redirect to whatever page(url) we want.(that is
basically, replacing the RedirectFromLoginPage call.) Here is an sample
shows generating a custom authentication ticket/cookie and redirect to a
path.

http://msdn.microsoft.com/library/en...websecurityfor
msauthenticationclassgetredirecturltopic.asp?frame =true

Hope it helps.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
1
by: MJ | last post by:
I'm building an application that has a file structure similar to the following: /myapp/user_login.aspx /myapp/user_page_1.aspx /myapp/user_page_2.aspx /myapp/user_page_3.aspx...
11
by: ElmoWatson | last post by:
I tried on the Security newgroup, as well as other places, and haven't gotten an answer yet - - I'm pulling my hair out over this one. I'm trying to get Forms Authentication working.....I can get...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
0
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET...
4
by: David | last post by:
When using forms authentication on my asp web app, I get the following error Parser Error Message: Unrecognized attribute 'loginURL' Source Error: Line 58: -- Line 59: ...
2
by: Dotnet Guy | last post by:
Hi, I have different asp.net applications as sub applications within an application and was using Framework 1.0. And I use forms authentication across the applications. In the web.config file of...
5
by: Sebastian | last post by:
Hello, I am attempting to share forms authentication between two applications but running into problems. The documentation I've been able to dig up says (to summarize) if the the Web.Config...
4
by: =?Utf-8?B?R3V1czEyMw==?= | last post by:
Hi, I created a web site on a remote server. To logon the user must enter a user id and password. The site is uses Forms Authentication. The web config file looks as follows: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.