2017-04-10 3 views
1

클라이언트에서 백엔드 및 angularjs를 사용하면 서로 다른 도메인에서 작동합니다. 다음과 같이 내가 고르 설정 :ServiceStack 로그인 요청 양식 이후에 세션 쿠키 저장 안 함 형식 십자가

Plugins.Add(new CorsFeature(
       allowCredentials: true, 
       allowOriginWhitelist: new[]{"http://localhost:11104", "http://localhost:61923/"}, 
       allowedMethods: "GET, POST, PUT, DELETE, OPTIONS", 
       allowedHeaders: "Content-Type")); 

쿠키를 얻기 위해 요청을하지만, 다음 쿼리 따라서 인증을 통과하지 않습니다 전송하지 않는 경우.

로그인 요청 :

$http({ 
       method: "POST", 
       url: "http://localhost:61923/auth/Credentials?format=json", 
       params: { "username": $scope.LoginParams.UserName, "password": $scope.LoginParams.Password } 
      }) 

enter image description here

다음 요청 :

$http({ 
       method: "POST", 
       url: "http://localhost:61923/IsAdmin?format=json" 
      }) 

enter image description here

도와주세요, 내가 잘못 뭐하는 거지? (( 감사

답변

3

당신은 withCredentials를 지정하여 HTTP 요청에서 쿠키를 포함 예컨대해야합니다!

$http({ 
    method: "POST", 
    url: "http://localhost:61923/auth/credentials", 
    params: { "username": $scope.LoginParams.UserName, "password": $scope.LoginParams.Password }, 
    withCredentials: true 
})