본문 바로가기
개발/C#

IIS 폼 인증 공유(.Net Framework)

by 혈중마라농도 2022. 3. 17.

IIS 폼인증에 대해 글을 써봅니다.
폼인증은 여러 사이트에 사용자 정보를 공유할 수 있고, 보안까지 갖춰져 있는 기능입니다. 

https://docs.microsoft.com/en-us/previous-versions/msp-n-p/ff649308(v=pandp.10)?redirectedfrom=MSDN#forms-authentication-tickets 

https://docs.microsoft.com/en-us/previous-versions/aspnet/eb0zx8fc(v=vs.100) 

 

Forms Authentication Across Applications

Table of contents Forms Authentication Across Applications Article 10/22/2014 2 minutes to read In this article --> ASP.NET supports forms authentication in a distributed environment, either across applications on a single server or in a Web farm. When for

docs.microsoft.com

 

How To: Configure MachineKey in ASP.NET 2.0

Table of contents How To: Configure MachineKey in ASP.NET 2.0 Article 07/14/2010 21 minutes to read In this article --> This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these techn

docs.microsoft.com

위의 링크는 Web.config 에 폼인증을 어떻게 설정해야하는가에 대한 얘기와 MachineKey에 대한 얘기입니다.
링크에 대해 간략하게 설명 드리면, 폼인증은 쿠키 기반으로 설정이 되며, 쿠키이름, 도메인명, 암호화방식 3가지를 맞춰주면, 사이트마다 폼인증 공유가 가능하다는 얘기입니다. 암호화 방식은 SHA1, DES, AES 3가지 방식을 제공하며 어떠한 방식으로 쓰던지 문제가 되지 않습니다.

폼인증 설정 Web.config

 

 

아래의 내용은 MachineKey에 관한 내용이며, 테스트에서 우여곡절이 있던 부분입니다.
.Net Framework는 3.5와 4.5간에 많은 차이가 있고, IIS 응용프로그램 풀도, 2.0 과 4.0 이 나눠져서 3.5는 응용프로그램에서 2.0을 쓰고, 4.5부터는 응용프로그램에서 4.0을 사용합니다.
 폼인증 방식도 3.5와 4.5간에 암호화 방식이 달라서? 다르다는게 말이 안되지고 버전간의 호환이 되야 정상일 듯 보이나,
3.5와 4.5 사이트간의 폼인증 공유가 잘 되지 않습니다.!!!
제가 테스트한 바로는 4.5에 문제가 있는듯합니다.
.Net Framework 3.5 Site - .Net Framework 3.5 Site (공유됨)
.Net Framework 3.5 Site - .Net Framework 4.5 Site (공유안됨)
.Net Framework 4.5 Site - .Net Framework 4.5 Site (공유안됨)

그래서 아래와 같이 CompatibilityMode 를 3가지로 설정할 수 있습니다.

MachineKey CompatibilityMode 가 3가지 있습니다.

아래의 링크는 공식 홈페이지에 설정부분입니다.

https://docs.microsoft.com/en-us/dotnet/api/system.web.configuration.machinekeysection.compatibilitymode?redirectedfrom=MSDN&view=netframework-4.8#System_Web_Configuration_MachineKeySection_CompatibilityMode

 

MachineKeySection.CompatibilityMode Property (System.Web.Configuration)

Gets or sets a value that specifies whether upgraded encryption methods for view state that were introduced after the .NET Framework version 2.0 Service Pack 1 release are used.

docs.microsoft.com

 

 

 

그리고 아래의 링크는 공식 홈페이지는 아니지만, stackoverflow에 올라와 있는 내용입니다. 이 중 캡쳐한 내용입니다.

ASP.NET 4.5에서 폼인증이 잘 안된다는 내용

https://stackoverflow.com/questions/12021863/upgrading-to-asp-net-4-5-mvc-4-forms-authentication-fails/12061090#12061090

 

Upgrading to ASP.NET 4.5/MVC 4 forms authentication fails

I've just downoaded a VS 2012 along with ASP.NET 4.5 and MVC 4.0 and was kicking the tires with a sample app and found that the forms authentication that works perfectly with ASP.NET 4.0/MVC 3 no l...

stackoverflow.com

https://stackoverflow.com/questions/2453677/single-sign-on-with-forms-authentication

 

Single Sign On with Forms Authentication

I am trying to set up Single sign on for 2 websites that reside on the same domain e.g. http://mydomain (top level site that contains a forms-auth login page) http://mydomain/admin (seperately

stackoverflow.com

 

반응형

'개발 > C#' 카테고리의 다른 글

C# Url Combine  (0) 2022.06.10
IIS Module 추가로 Body Log 추가하기  (0) 2022.05.03
IIS ASP.net 폼인증 컴퓨터 키(machineKey) 생성  (0) 2022.02.16
C# parse xml pretty string  (0) 2022.01.20
C# string to int 확장형  (0) 2022.01.11

댓글