thisチュートリアルを使用してidentityserver3とMVC4クライアントをセットアップしました。私がクライアントに 'Implicit'フローを使用するように設定したとき、物事は予想どおりに機能していて、私は 'profile'スコープに戻ります。つまり、私はクレームfirst_nameとgiven_nameを見つけることができます。私の設定コードの下に。Identityserver3 - HybridFlowがプロファイルスコープを返さない
クライアントとユーザーの設定
public static class Users
{
public static List<InMemoryUser> Get()
{
return new List<InMemoryUser>
{
new InMemoryUser
{
Username = "Bob",Password = "password",Subject = "1",
Claims = new []
{
new Claim(Constants.ClaimTypes.GivenName,"firstName"),
new Claim(Constants.ClaimTypes.FamilyName,"lastName")
}
}
};
}
}
public static class Clients
{
public static IEnumerable<Client> Get()
{
return new[]
{
new Client
{
ClientId = "MVC",
ClientName = "MVC Client Name",
RedirectUris = new List<string>
{
"https://localhost:44302/"
},
Flow = Flows.Implicit,
AllowAccessToAllScopes = true
}
};
}
}
私は 'コンタクト'
[Authorize]
public ActionResult Contact()
{
ClaimsPrincipal principal = User as ClaimsPrincipal;
return View(principal.Claims);
}
という名前のホームコントローラのアクションを確保してきた私のMVCアプリケーションで
public void Configuration(IAppBuilder app)
{
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
app.Map("/identity", appBuilder => {
appBuilder.UseIdentityServer(new IdentityServer3.Core.Configuration.IdentityServerOptions
{
SiteName = "Site Name",
SigningCertificate = LoadCertificate(),
RequireSsl = false,
Factory = new IdentityServer3.Core.Configuration.IdentityServerServiceFactory()
.UseInMemoryClients(Clients.Get())
.UseInMemoryUsers(Users.Get())
.UseInMemoryScopes(StandardScopes.All)
});
});
app.UseCookieAuthentication(new Microsoft.Owin.Security.Cookies.CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = "https://localhost:44302/identity",
ClientId = "MVC",
RedirectUri = "https://localhost:44302/",
ResponseType = "id_token",
SignInAsAuthenticationType = "Cookies",
Scope = "openid profile"
});
}
のIdentity Serverの設定
そして最後に、ここでは単純なビューにある
@model IEnumerable<System.Security.Claims.Claim>
@foreach (var item in Model)
{
<div>
<span>@item.Type</span>
<span>@item.Value</span>
</div>
}
</div>
私はこのアプリを実行すると、セキュアな「コンタクト」のリンクをクリックした後、私は、サーバーをSTSにリダイレクトされていますし、資格情報を提供した後、私は出力の下に見ることができます。
はSTSによって返され、特許請求の範囲内に存在するGIVEN_NAMEとFAMILY_NAMEを主張注意。
問題:私はハイブリッドフローをサポートするために、クライアントを変更
瞬間。私はが戻っを得ていないが、私は私のコードの変更の下に作られたGIVEN_NAMEとFAMILY_NAME
を主張しています。
クライアント構成
public static IEnumerable<Client> Get()
{
return new[]
{
new Client
{
ClientId = "MVC",
ClientName = "MVC Client Name",
RedirectUris = new List<string>
{
"https://localhost:44302/"
},
Flow = Flows.Hybrid,//Changed this to Hybrid
AllowAccessToAllScopes = true
}
};
}
サーバー構成
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = "https://localhost:44302/identity",
ClientId = "MVC",
RedirectUri = "https://localhost:44302/",
ResponseType = "code id_token token", //Changed response type
SignInAsAuthenticationType = "Cookies",
Scope = "openid profile"
});
applicatonを実行した後、私はSTSによって返されたクレームの下に見ることができます
GIVEN_NAMEとFAMILY_NAMEにを主張(注)この時間が不足しています。
私は何かを見逃しましたか?
私はハイブリッドフローと同じ問題があります。どのように解決しましたか? – barteloma