ASP.NET Core의 OAuth 권한 부여 서비스
Web API 2에서는 아래와 같이 미들웨어를 통해 OAuth Authorization Server를 설정하여 토큰을 발행하는 엔드 포인트를 생성 할 수있었습니다.
//Set up our auth server options.
var OAuthServerOptions = new OAuthAuthorizationServerOptions()
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
Provider = new SimpleAuthorizationServerProvider()
};
// Sets up the token issue endpoint using the options above
app.UseOAuthAuthorizationServer(OAuthServerOptions);
아마도 나는 그것을 놓치고 있지만 ASP.NET Core에서 이것을 수행하는 방법을 알아 내려고 노력하고 있습니다. 나는 출처 ( https://github.com/aspnet/Security )를 살펴 보았지만 실제로 비슷한 것을 보지 못했습니다. 이를 수행하는 새로운 방법이 있습니까? 컨트롤러를 생성하고 직접 수행해야합니까?
미들웨어를 통해 OAuth 인증을 설정하는 방법을 확인했지만 API에서 클레임을 발행하는 인증 부분과 관련이 있습니다.
OAuthAuthorizationServerMiddleware
ASP.NET Core에서 대안을 찾는 데 시간을 낭비하지 마십시오 . ASP.NET 팀은 단순히 이식하지 않기로 결정했습니다. https://github.com/aspnet/Security/issues/83
Katana 3과 함께 제공되는 OAuth2 권한 부여 서버 미들웨어의 고급 포크 인 AspNet.Security.OpenIdConnect.Server를 살펴 보는 것이 좋습니다 . OWIN / Katana 3 버전과 전체. NET Framework 및 .NET Core.
https://github.com/aspnet-contrib/AspNet.Security.OpenIdConnect.Server
ASP.NET Core 1.x :
app.UseOpenIdConnectServer(options =>
{
options.AllowInsecureHttp = true;
options.TokenEndpointPath = new PathString("/token");
options.AccessTokenLifetime = TimeSpan.FromDays(1);
options.TokenEndpointPath = "/token";
options.Provider = new SimpleAuthorizationServerProvider();
});
ASP.NET Core 2.x :
services.AddAuthentication().AddOpenIdConnectServer(options =>
{
options.AllowInsecureHttp = true;
options.TokenEndpointPath = new PathString("/token");
options.AccessTokenLifetime = TimeSpan.FromDays(1);
options.TokenEndpointPath = "/token";
options.Provider = new SimpleAuthorizationServerProvider();
});
이 프로젝트에 대해 자세히 알아 보려면 http://kevinchalet.com/2016/07/13/creating-your-own-openid-connect-server-with-asos-introduction/을 읽는 것이 좋습니다 .
행운을 빕니다!
ASP.NET 5에서 원래 OAuth 인증 서버를 찾는 사람을 위해 코드와 원본 샘플을 여기에 이식했습니다 : https://github.com/XacronDevelopment/oauth-aspnet
이 포트에는 ASP.NET 4.x 리소스 서버가 권한 부여 서버에서 만든 액세스 토큰을 읽을 수 있도록 이전 버전과의 호환성이 포함되어 있습니다.
너겟 패키지는 여기에 있습니다 : https://www.nuget.org/packages/OAuth.AspNet.AuthServer https://www.nuget.org/packages/OAuth.AspNet.Tokens https://www.nuget.org/ 패키지 /OAuth.Owin.Tokens
참조 URL : https://stackoverflow.com/questions/29055477/oauth-authorization-service-in-asp-net-core
'IT박스' 카테고리의 다른 글
Android Studio : 드로어 블 폴더 : 여러 dpi에 이미지를 넣는 방법? (0) | 2021.01.05 |
---|---|
Javascript PascalCase를 underscore_case로 변환 (0) | 2021.01.05 |
내가 "git push"하면 git은 이제 "Create pull request for…"라고 말합니다. (0) | 2020.12.31 |
Project.json 정의 dnx451 대 .dotnet (4.51) (0) | 2020.12.31 |
파이썬 애플리케이션을 정적 바이너리로 컴파일하는 방법이 있습니까? (0) | 2020.12.31 |