Single Sign-on)

Source: Internet
Author: User

 

Problem description:
There is a primary domain name extension 2.0 technology implementation, and distributed on different servers, now requires that the implementation of single point of login in these systems.

The method is as follows:
Add the following two nodes to the Web. config file of each site (subsystem ):
<System. Web>

<Machinekey validationkey = "machinekey"
Decryptionkey = "5f1c24d664a14ab7862fce8f6a98e9e274dc1e21e6bfb060"
Validation = "sha1"/>

<Authentication mode = "forms">
<Forms domain = ".wow52.cn"
Defaulturl = "index.html"
Name = ". XXX. comusernamecookie"
Protection = "all"
Loginurl = "/userlogin. aspx"/>
</Authentication>

</System. Web>

Used to generate a node <machinekey>CodeAs follows:
Using system;
Using system. text;
Using system. Security. cryptography;

Namespace crypto
{
Public class keycreator
{
Public static void main (string [] ARGs)
{
String [] commandlineargs = system. environment. getcommandlineargs ();
String decryptionkey = createkey (system. Convert. toint32 (commandlineargs [1]);
String validationkey = createkey (system. Convert. toint32 (commandlineargs [2]);

Console. writeline ("<machinekey validationkey = \" {0} \ "decryptionkey = \" {1} \ "validation = \" sha1 \ "/>", validationkey, decryptionkey );
}

Static string createkey (INT numbytes)
{
Rngcryptoserviceprovider RNG = new rngcryptoserviceprovider ();
Byte [] buff = new byte [numbytes];

RNG. getbytes (buff );
Return bytestohexstring (buff );
}

Static string bytestohexstring (byte [] bytes)
{
Stringbuilder hexstring = new stringbuilder (64 );

for (INT counter = 0; counter {< br> hexstring. append (string. format ("{0: X2}", bytes [Counter]);
}< br> return hexstring. tostring ();
}< BR >}< br> compile the above Code to obtain the hashconfigcs.exe file
enter hashconfigcs.exe 24 64 key.txt
the content of the key.txt file is node

Note:
The Forms authentication in Asp.net is based on cookies.AlgorithmEncryption and signature are performed. By default, machine is used. in the config file, the <machinekey> node configuration information (key, and algorithm) is completed. <machinekey> in config usesAutogenerateThe keys on different servers are basically different, so you must manually specify them.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.