简体   繁体   English

允许我的ASP.Net MVC网站中的用户访问我的私人WordPress网站

[英]Allow users from my ASP.Net MVC site to access my private WordPress site

I have an ASP .Net MVC site and I would like users who are logged in to my site to be able to access a separate WordPress site which I also own. 我有一个ASP .Net MVC网站,我希望登录到我的网站的用户能够访问我也拥有的单独的WordPress网站。 Otherwise, if a user is not logged into my ASP .Net site, the WordPress site should remain private. 否则,如果用户未登录我的ASP .Net网站,则WordPress网站应保持私有状态。

What is the easiest way to implement this? 实现此目的最简单的方法是什么? I thought about SSO but it seems like overkill for this simple scenario. 我考虑过SSO,但在这种简单情况下似乎有点过头了。 I don't need users identified on the WordPress site; 我不需要WordPress网站上标识的用户; they won't be allowed to post or anything, all they can do is just read my posts there. 他们将不会被允许发布任何信息,他们所能做的就是在那儿阅读我的信息。

I ended up making the whole WP site private except to logged in users by using a plugin (Ultimate Member). 我最终将整个WP网站设为私有,除了使用插件(最终会员)登录用户外。 Then I created a single login which would be used from the .Net site. 然后,我创建了一个将从.Net站点使用的登录名。 The way it works is: 它的工作方式是:

  1. User clicks on link within .Net site to access WordPress site 用户单击.Net网站中的链接以访问WordPress网站
  2. Server-side: performs POST to /wp-login.php with credentials for single WP user 服务器端:使用单个WP用户的凭据对/wp-login.php执行POST
  3. Server-side: retrieve cookies from wp-login.php response 服务器端:从wp-login.php响应中检索Cookie
  4. Client-side: call to custom PHP page on WP site: /setcookies.php and set user's session cookies for WP site domain using cookies from previous step 客户端:调用WP站点上的自定义PHP页面:/setcookies.php,并使用上一步中的cookie设置WP站点域的用户会话cookie
  5. Client-side: open WP site in iframe using session cookies 客户端:使用会话Cookie在iframe中打开WP网站

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM