[英]use Owin OAuth 2.0 in multi tenant site
我目前在多租戶CMS中使用Owin 2.0。 我需要根據租戶更改Facebook應用ID和機密的方法。
問題是Owin配置代碼先執行。 Request.Url不是解決方案。 請給我一個切實可行的解決方案。 目前,我只能從URL區分租戶。
將此答案用作有用的提示而非解決方案
您應該使用FacebookAuthenticationProvider
為每個租戶自定義完整流程。 FacebookAuthenticationProvider
公開了三個有助於自定義的事件。
提示:在Visual Studio中使用對象瀏覽器
FacebookAuthenticationOptions fbOptions = new FacebookAuthenticationOptions();
fbOptions.AppId = "DefaultAppId";
fbOptions.AppSecret = "DefaultSecret";
fbOptions.CallbackPath = new PathString("DefaultTenantWithCallBackUrl");
fbOptions.Provider = new FacebookAuthenticationProvider()
{
OnApplyRedirect = (FacebookApplyRedirectContext context) =>
{
/*a way to change the facebook app id and secret depending on the tenant.*/
/*Redirect to tenant specific built url */
},
OnAuthenticated = (FacebookAuthenticatedContext context) =>
{
/*process tenant specific logic*/
return Task.FromResult(0);
},
OnReturnEndpoint = (FacebookReturnEndpointContext context) =>
{
/*process tenant specific logic*/
return Task.FromResult(0);
}
};
app.Use(typeof(FacebookAuthenticationMiddleware), app, fbOptions);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.