2016-09-14 7 views
1

ログインページのIdentityServer3のIdentityのクライアントからredirectUrlを取得したいと考えています。 EX:私はそれを打つと、 "localhost:54483/payments/5466cdaa-2005-4947-b4dc-cc6a49b83dfd/checkout"リンク を私はIndentityServerのログインページにリダイレクトされ、リダイレクトリンクを取得する必要がありますここIdentityServer3ログインページのクライアントからリダイレクトリンクを取得

public class CustomViewService: DefaultViewService 
{ 
    private gtoken _gtoken; 
    public CustomViewService(DefaultViewServiceOptions config, IViewLoader viewLoader, gtoken gtoken) : base(config, viewLoader) 
    { 
     _gtoken = gtoken; 
    } 

    public override Task<Stream> Login(LoginViewModel model, SignInMessage message) 
    { 
     //TODO need to get redirect link here 
     return base.Login(model, message); 
    } 
} 
中( http://localhost:54483/payments/5466cdaa-2005-4947-b4dc-cc6a49b83dfd/checkout)上記

は私のクライアントの設定です:あなたは、リダイレクトが起こるしたいと思う理由

public void Configuration(IAppBuilder app) 
    { 

     // turn off any default mapping on the JWT handler 
     AntiForgeryConfig.UniqueClaimTypeIdentifier = "sub"; 
     JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>(); 

     app.Map("/api", idsrvApp => 
     { 
      idsrvApp.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions 
      { 
       Authority = "http://localhost:5001", 
       ValidationMode = ValidationMode.Local, //set to validation endpoint if we want to support JWT revocation 

       RequiredScopes = new[] { "payment" } 
      }); 
     }); 


     Func<IOwinContext, bool> notApiRequest = (ctx) => 
     { 
      return !ctx.Request.Path.StartsWithSegments(new PathString("/api")); 
     }; 

     app.MapWhen(notApiRequest, idsrvApp => 
     { 
      idsrvApp.UseCookieAuthentication(new CookieAuthenticationOptions 
      { 
       AuthenticationType = "Cookies", 
       CookieName = Constants.AUTH_COOKIE_NAME 
      }); 


      idsrvApp.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions 
      { 
       Authority = "http://localhost:5001", 
       ClientId = "06de763b-ad15-4225-a147-9f7b5da61cdf", 
       RedirectUri = "mylocal", 
       ResponseType = "id_token", 
       Scope = "openid", 
       SignInAsAuthenticationType = "Cookies", 
      }); 
     }); 
    } 

答えて

0

私は理解していません。私はその論理を見ません。

identityServer3のマニュアルは読んでいますか?あなたはそこに表示されます:

GET /認可/接続のclient_id = CLIENT1 &スコープ= OpenIDのメールAPI1 & response_type = id_tokenトークン& REDIRECT_URI = http://localhost:54483/payments/5466cdaa-2005-4947-b4dc-cc6a49b83dfd/checkout

*リンク:?https://identityserver.github.io/Documentation/docsv2/endpoints/authorization.html

これは、ユーザーがログインしていないことを確認すると、(上記のHTTP GETメソッドがエンドポイントにリンクしても、IDサーバーにログインページが表示されますが)ユーザーをIDサーバーのログインページに送信します。ログインページにリクエストして、リダイレクトURLを送信します。リダイレクトURLがそのクライアントに許可されていることを確認してください(ドキュメントをチェックしてください)。

p.s. APIとIDサーバーを同じプロジェクトに保つ​​ことはお勧めしません。

+0

ご返信ありがとうございます。 私のシナリオは、ユーザーが署名なしであればリンク(http:// localhost:54483/payments/5466cdaa-2005-4947-b4dc-cc6a49b83dfd/checkout)で支払いをチェックアウトするときにIdentityServerのログインページにリダイレクトしてから私はアイデンティティサーバー側でビジネスログインを行うためにリダイレクトリンクを取得する必要があります。アイデンティティサーバー側でクライアントのリダイレクトリンクはどこにありますか? ありがとう –

+0

私はidentityserverのリダイレクトリンクにアクセスする方法がわかりません。 しかし、私はまだあなたが次のようにすればもっと簡単だと信じています: ユーザーがページに来る(またはWeb API呼び出しを行う) - >ユーザーがログインしている場合にサーバー側をチェックする - >現在のページを取得するurl - >ユーザーをログインにリダイレクトし、現在のページをリダイレクトURLにします。 (この方法では、ユーザがログインして支払いリンクに来た場合と同じ状況になります) アイデンティティサーバは、アイデンティティを提供しているアプリケーションの種類を知りません – theCuriousOne

関連する問題