これらのすべてのものがうまく一緒にプレーできる単一のプロジェクトを構築しようとしています。IdentityServer4 + Web Api + Spaを1つのプロジェクトにまとめて
- スパ
- StaticFiles
- のWeb API(MVC)
- SWAGGER(Swashbuckle)
- IdentityServer4
- IdentityServer4.AspNetIdentity
- IdentityServer4.EntityFramework
- 社会ログイン
私はIdentityServer4.Samples \ Quickstart6_AspNetIdentityコードでnuget後の統合nugetを始めました。
// spa
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseCors("any");
// api
app.Map(new PathString("/api"), map =>
{
map.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = PublicHostUri,
ScopeName = ScopeName,
ScopeSecret = "secret",
RequireHttpsMetadata = PublicHostUri.ToLower().StartsWith("https"),
SaveToken = true,
EnableCaching = true
});
map.UseMvc();
});
// sts
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
app.UseIdentity();
app.UseIdentityServer();
// Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme,
AutomaticAuthenticate = false,
AutomaticChallenge = false
});
app.UseTwitterAuthentication(new TwitterOptions
{
ConsumerKey = "6XaCTaLbMqfj6ww3zvZ5g",
ConsumerSecret = "Il2eFzGIrYhz6BWjYhVXBPQSfZuS4xoHpSSyD9PI"
});
app.UseGoogleAuthentication(new GoogleOptions
{
AuthenticationScheme = "Google",
DisplayName = "Google",
SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme,
ClientId = "434483408261-55tc8n0cs4ff1fe21ea8df2o443v2iuc.apps.googleusercontent.com",
ClientSecret = "3gcoTrEDPPJ0ukn_aYYT6PWo"
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseSwagger();
app.UseSwaggerUi();
私は、ベアラAuthenticationSchemeは/ APIパイプラインのアクティブザッツ唯一の認証であるような方法でWeb APIの一部を分離するのに苦労しています。
Cookie、Google、Twitter、OIDC、ベアラのような追加されたAuthenticationSchemesはすべて、/ apiルートに使用されています。
私は何が間違っていますか?なぜ/ apiはUseIdentityServerAuthenticationという名前のベアラトークンスキームを使用するだけではありませんか?
アップデート:私はあなたが分岐アプリにMap
を使用することはできませんここhttps://github.com/ChrisRichner/CoreWebApp.Quickstart
こんにちは、あなたは、個々のアカウントだけでなく、社会的なログインと連携IdentityServer4で保護されたWeb APIを構築することができましたか?はい、私は本当にいくつかの助けに感謝します:( –
私の概念証明コードは、あなたが何を記述しているかを正確に行います。あなたは何を知りたいですか? –
ありがとう、私の質問でここで助けてくださいできますか?http:// stackoverflow。 com/questions/39644055/identityserver4-net-core-web-api-implement-individual-user-accounts-with-s –