2016-02-04 17 views
7

https://www.somesite.com(ユーザーサイト)とhttps://admin.anothersite.com(管理サイト)の2つのサイトがあり、アクセス制御にIdentity Server 3を使用しています。これはhttps://identity.somesite.comでホストされています。Identity Serverとユーザー偽装

サイトは、同一のクライアント(異なるリダイレクトURL)としてアイデンティティサーバーにCookieベースの認証で設定されています。管理サイトのユーザーがユーザーサイトのユーザーを偽装できる仕組みを提供したいと思います。

私はIssueLoginCookieを使用してクッキーを発行することができますが、その呼び出しはIDサーバー上にある必要があるので、別のドメインにあるとすれば、その動作がどうなるかわかりません。

アイデンティティサーバーでのユーザー偽装をサポートするにはどうすればよいですか?

更新

私は今、adminサイトはそうのようなURLを生成します:

var url = 'http://localhost:61826/connect/authorize' 
    + '?state=' + encodeURIComponent(((Date.now() + Math.random()) * Math.random()).toString().replace(".", "")) 
    + '&nonce=' + encodeURIComponent(((Date.now() + Math.random()) * Math.random()).toString().replace(".", "")) 
    + '&client_id=mvc' 
    + '&redirect_uri=' + encodeURIComponent('http://localhost:64822/') 
    + '&scope=' + encodeURIComponent('openid profile roles api1') 
    + '&acr_values=' + encodeURIComponent('loginas:3230') 
    + '&response_type=' + encodeURIComponent('id_token token') 
    + '&prompt=login'; 

window.location.href = url; 

これは、ピックアップに私のカスタムIUserServicePreAuthenticateAsync方法でログインイベントを、私を可能にし、ログインを傍受。私の現在の実装は:

public override async Task PreAuthenticateAsync(PreAuthenticationContext context) 
{ 
    if (context.SignInMessage.AcrValues.Any(acr => acr.StartsWith("loginas:"))) 
    { 
     // Would need to also ensure that the user has the relevant persmissions to impersonate another user 
     var subjectId = _owinContext.Authentication.User.GetSubjectId(); 

     var login = new AuthenticatedLogin 
     { 
      Name = "Impersonating For Fun", 
      Subject = "3230", 
      Claims = new List<Claim> 
      { 
       new Claim(Constants.ClaimTypes.Subject, "3230") 
      }, 
      PersistentLogin = true, 
      IdentityProvider = Constants.BuiltInIdentityProvider, 
      AuthenticationMethod = "Cookies" 
     }; 

     _owinContext.Environment.IssueLoginCookie(login); 

     var impersonationClaims = new List<Claim> 
     { 
      new Claim("AdminUserId", subjectId) 
     }; 

     context.AuthenticateResult = new AuthenticateResult("3230", "Impersonating For Fun", impersonationClaims); 
    } 

    await Task.FromResult(0); 
} 

ユーザはログインページに表示されず、正しくターゲットURLにリダイレクトされます。ただし、ユーザーは新しいユーザーに変更されず、元のユーザーのままになります。私は何が欠けていますか?

答えて

0

ドメインワイドクッキーを設定していますか?ブラウザで確認できますか?

関連する問題