0
모든 프로젝트가 잘 작동하는 단일 프로젝트를 구축하는 데 어려움을 겪고 있습니다.IdentityServer4 + Web Api + Spa를 하나의 프로젝트에 함께 사용
- 스파
- StaticFiles
- 웹 API (MVC)
- 자신감 (Swashbuckle)
- IdentityServer4
-
012 3,516,
- 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를 파이프 라인의 활성 이잖아되는 방식으로 웹 API 부분을 분리하기 위해 사투를 벌인거야.
지금은 쿠키, Google, Twitter, OIDC, 무기명 등의 추가 된 인증 스키마가 모두/api Route에 사용됩니다.
무엇이 놓치나요? 왜/api는 UseIdentityServerAuthentication이라고 불리는 베어러 토큰 체계를 사용하지 않는가?
업데이트 : 나는 당신이 응용 프로그램을 분기하는 Map
을 사용할 수 없습니다 여기 https://github.com/ChrisRichner/CoreWebApp.Quickstart
안녕하십니까, 개인 계정 및 소셜 로그인과 함께 작동하는 IdentityServer4로 보안 웹 API를 만들 수 있었습니까? 만약 그렇다면, 나는 정말로 도움을 주실 것입니다 : ( –
내 개념 증명 코드는 정확히 당신이 묘사하는 것을 수행합니다. 당신은 무엇을 알고 싶습니까 –
고마워, 제발 여기 내 질문에 좀 도와 줄래? http : // stackoverflow. co.kr/questions/39644055/identityserver4-net-core-web-api-implementation-individual-user-accounts-with-s –