2014-12-03 16 views
7

Birden çok mvc uygulaması için Thinctecture identityserver v3'ü basit bir sts olarak kullanmaya çalışın.
Sağlanan örnek uygulamalar ile sorunsuz çalışabiliyorum ama hepsi gömülü bir kimlik sunucusu kullanıyor. Ben ayrı bir uygulama olmak için identityserver ihtiyacım var, bu yüzden birkaç uygulama için sts olarak kullanabilirsiniz. Kimlik sunucusunu çalıştırmayı denediğimde ve örnek mvc uygulamasını bağladığımda bir şey eksik görünüyor.thinktecture identityserver v3

örnek MVC uygulaması katanayı

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions... 

kullanır ama nasıl düzgün harici uygulama hizmeti için yapılandırma için anlayamıyorum. Tahminim doğru uç noktayı kullanmıyorum.

İşte mvc olarak benim bağlı parti yapılandırmam. Ben istisna olsun yetki gerektiren bir görünüme gidin istediğiniz her seferinde 44333

mvc uygulamasında: : Sonra son v3 burada bakir çalışan IS var.

Yığın İzleme:

[HttpRequestException: Response status code does not indicate success: 404 (Not Found).] 
    System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() +87960 
    Microsoft.IdentityModel.Protocols.<GetDocumentAsync>d__0.MoveNext() +496 

[IOException: Unable to get document from: https://localhost:44333/.well-known/openid-configuration] 
    Microsoft.IdentityModel.Protocols.<GetDocumentAsync>d__0.MoveNext() +830 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 
    System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24 
    Microsoft.IdentityModel.Protocols.<GetAsync>d__0.MoveNext() +512 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 
    System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24 
    Microsoft.IdentityModel.Protocols.<GetConfigurationAsync>d__3.MoveNext() +1332 

burada MVC uygulamasında tam yetkilendirme yapılandırma olduğunu.

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions 
{ 
    //Authority = "https://localhost:44319/identity", 
    Authority = "https://localhost:44333", 
    ClientId = "mvc", 
    Scope = "openid profile roles", 
    RedirectUri = "https://localhost:44319/", 

    SignInAsAuthenticationType = "Cookies", 
    UseTokenLifetime = false, 

    Notifications = new OpenIdConnectAuthenticationNotifications 
    { 
     SecurityTokenValidated = async n => 
      { 
       var id = n.AuthenticationTicket.Identity; 

       // we want to keep first name, last name, subject and roles 
       var givenName = id.FindFirst(Constants.ClaimTypes.GivenName); 
       var familyName = id.FindFirst(Constants.ClaimTypes.FamilyName); 
       var sub = id.FindFirst(Constants.ClaimTypes.Subject); 
       var roles = id.FindAll(Constants.ClaimTypes.Role); 

       // create new identity and set name and role claim type 
       var nid = new ClaimsIdentity(
        id.AuthenticationType, 
        Constants.ClaimTypes.GivenName, 
        Constants.ClaimTypes.Role); 

       nid.AddClaim(givenName); 
       nid.AddClaim(familyName); 
       nid.AddClaim(sub); 
       nid.AddClaims(roles); 

       // keep the id_token for logout 
       nid.AddClaim(new Claim("id_token", n.ProtocolMessage.IdToken)); 

       // add some other app specific claim 
       nid.AddClaim(new Claim("app_specific", "some data")); 

       n.AuthenticationTicket = new AuthenticationTicket(
        nid, 
        n.AuthenticationTicket.Properties); 
      }, 
     RedirectToIdentityProvider = async n => 
      { 
       if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.LogoutRequest) 
       { 
        var idTokenHint = n.OwinContext.Authentication.User.FindFirst("id_token"); 

        if (idTokenHint != null) 
        { 
         n.ProtocolMessage.IdTokenHint = idTokenHint.Value; 
        } 
       } 
      } 
    } 
}); 
+0

Eh ben biraz daha var az /identity eksik, ancak yine de herkes sunmak istiyorsa benim aptallığı rehberlik takdir ediyorum. Otoriteyi değiştirerek ve MeadataAddress'i mvc konfigürasyonuna ekleyerek çalışmasını sağlamak üzereydim. Authority = "https://idsrv3.com", MetadataAddress = "https: // localhost: 44333/core/.well-bilinen/openid-configuration", – Aaron792000

+0

Kullandığınız Startup.cs dosyasının içeriğini ekleyebilir misiniz? IdentityServerv3 yapılandırmak için? Ayrıca IdSrv3'ü yapılandırmak için bir eğitici hazırladım, orada Idsrv yapılandırması var ve ayrıca kullanıcı onay verdikten sonra bazı genel kaynakları isteyen bir Mvc uygulaması var: [eğiticiye bağlantı] (http://cedric-dumont.com/tutorials/ identityserver-v3-membersreboot-angularjs-webapi-2-ve-mvc-mix-it-giriş /) –

+0

Bu sorunu özendiriyorum, sayfayı yenileyerek çözdüm. STS sitesi biraz zaman yanıt vermiyor gibi görünüyor. –

cevap

0

Sizin uç nokta sonuna

İlgili konular