막혔습니다.Azure AD B2C에 대한 OWIN/OIDC를 사용하여 사용자 지정 Umbraco 컨트롤러 인증
RenderMvcController
에서 상속받은 사용자 지정 Umbraco 컨트롤러가 있고 Index()
동작 메서드가 눌려지면 파일이 반환됩니다. 이 방법이 효과적이지만, 내가하고자하는 일은 AuthorizeAttribute
으로 동작을 꾸미고 사용자가 인증하도록 요구하는 것입니다.
namespace MyNamespace.Controllers
{
public class MyModelController : RenderMvcController
{
[Authorize]
public ActionResult Index(RenderModel model)
{
// ...
}
}
}
인증은 Azure AD B2C 응용 프로그램과의 OWIN 및 OpenId Connect를 사용하여 수행해야합니다. 이것은 또한 작동하지만 테스트되었지만 Umbraco가 아닌 상황에서 테스트되었습니다.
주제와 관련된 수많은 스레드와 코드를 읽었지 만 Umbraco에서이를 통합하는 데 어려움을 겪고 있습니다. UmbracoDefaultOwinStartup
에서 상속받은 사용자 지정 시작 클래스가 있습니다. 맞춤 경로를 AuthController
에 등록하고 IAppBuilder.UseOpenIdConnectAuthentication()
을 통해 OIDC를 구성합니다.
하지만 Umbraco 접착제가 필요하며 쿠키 구성 방법을 이해하는 데 문제가 있습니다. 시작 Configuration()
메서드가 호출되었는지 확인했습니다.
namespace MyNamespace
{
public class CustomOwinStartup : UmbracoDefaultOwinStartup
{
public override void Configuration(IAppBuilder app)
{
base.Configuration(app);
ConfigureAuth(app);
RouteTable.Routes.MapRoute(
"CustomAuth",
"CustomAuth/{action}",
new { controller = "Auth" }
);
}
private void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/CustomAuth/SignUpSignIn") // TODO: What should I put here?
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseOpenIdConnectAuthentication(
// Passing options that are tested and working
);
}
}
}
그리고 나서 당분간은 매우 간단한 내 인증 컨트롤러가 있습니다. Umbraco 사용자와 인증 정보를 동기화 할 필요가 없습니다.
namespace MyNamespace.Controllers
{
public partial class CustomAuthController : Controller
{
public CustomAuthController() : base()
{
}
public void SignUpSignIn()
{
if (!Request.IsAuthenticated)
{
HttpContext.GetOwinContext().Authentication.Challenge();
return;
}
Response.Redirect("/"); // TODO: Maybe this should redirect me back to original route MyModel/Index in some way
}
}
}
내가 이것을 실행하고 나는이 오류가 내 속성 장식 사용자 정의 Umbraco 컨트롤러를 통해 시도하는 경우 :
Page not found
No umbraco document matches the url
'/login.aspx?ReturnUrl=MYORIGINALROUTEHTTPENCODED'
. This page can be replaced with a custom 404. Check the documentation for "custom 404".
내 생각 엔이 때문에 Web.config
의 <authentication mode="Forms">
설정입니다 만, 경우이다 이 항목을 제거하거나 mode
이라는 속성을 "None"
으로 설정하면 백 오피스 로그인에 영향을주지 않을까요?
누구나 나를 올바른 방향으로 안내 할 수 있다면 매우 감사합니다!
[이 샘플 앱] (https://github.com/Azure-Samples/active-directory-b2c-dotnet-webapp-and-webapi/blob/master/TaskWebApp/App_Start/)을 검토하셨습니까? Startup.Auth.cs)는 owin w/b2c를 사용합니까? – spottedmahn
예, OIDC 구성자로 전달할 옵션 개체의 기초입니다. – Viktor
좀 더 자세히 설명하기 위해 샘플 앱을 사용하여 작동하도록했으나 이제는 그대로두고 자하는 인증이있는 기존 Umbraco 애플리케이션에 동일한 인증 레이어를 추가하려고합니다. Umbraco의 프런트 엔드 사용자 저장소에 연결할 수있는 사용자 지정 인증이 필요하지 않습니다. 이후 auth-then-forget 만 수행하기 때문입니다. 또는 어쩌면 auth-then-maybe-log. 나머지 사이트는 공개적으로 액세스 할 수 있습니다. – Viktor