简体   繁体   English

从外部站点进行身份验证

[英]Authenticate from external site

Firstly i have tried to google all my questions of this but has not found the solution to my answer. 首先,我尝试过搜索所有有关此问题的信息,但没有找到答案的解决方案。 I am trying to either use and existing browser session or authenticate if the session does not exist. 我正在尝试使用现有的浏览器会话,或者如果该会话不存在,则进行身份验证。

I have Site A: https://mysite.com/Login.aspx This site is the site i am trying to either use existing browser session or authenticate with if no session exists 我有网站A: https : //mysite.com/Login.aspx该网站是我尝试使用现有浏览器会话或如果不存在会话进行身份验证的网站

Site B: http://myinternalsite.com/work.php This is my internal site that i am trying to build so i can perform some function against Site A 站点B: http : //myinternalsite.com/work.php这是我尝试构建的内部站点,因此我可以对站点A执行某些功能

I first thought that i could use jquery jsonp post to the site which i think i can do but it must first be authenticated or Site A will just redirect all posts to the login page. 我首先认为我可以使用jquery jsonp发布到我认为可以执行的站点,但必须首先进行身份验证,否则站点A会将所有帖子重定向到登录页面。 I have used external third party ui testing sites that use basic http authentication to take screenshots of my Site A but im unsure how to replicate that authentication process on my end. 我已经使用了使用基本http身份验证的外部第三方ui测试站点来获取站点A的屏幕截图,但不确定如何在我端复制该身份验证过程。

Im looking for a direction or example to get me in the right direction, it seems like it should be easy enough but ive never used authentication in php so i am lost :( 我正在寻找一个方向或例子来使我朝正确的方向发展,这似乎应该很容易,但是我从未在php中使用身份验证,所以我迷路了:(

Im not sure if this is exact solution but it might lead you to the correct path. 我不确定这是否是正确的解决方案,但可能会导致您找到正确的路径。 I had similar problem. 我有类似的问题。

I had 2 websites and from second website i wanted to monitor website 1. Meaning i wanted to get all statistics, users online, updates, page visits etc... from website 1 to website 2. 我有2个网站,我想从第二个网站监视网站1。这意味着我想让所有统计数据,用户在线,更新,页面访问等...从网站1到网站2。

To achieve this i created a Sender.php controller inside website 1 (note im using MVC framework). 为了实现这一点,我在网站1内创建了一个Sender.php控制器(请注意,我使用MVC框架)。 Sender.php was grabbing all information above and was posting to website 2 using cron job . Sender.php正在获取上述所有信息,并使用cron job发布到网站2上。

I had Reciever.php in website 2 where all above data was posted. 我在网站2上有Reciever.php,上面发布了所有上述数据。 All i had to do in Reciever.php is to grab data, sanitize it and display on screen as statistics. 我在Reciever.php中要做的就是获取数据,清理数据并在屏幕上显示为统计数据。

Not sure what you are trying to do, but I'll give you an example of what I think you want to do. 不确定您要做什么,但是我会举例说明我想做的事情。

site 1 网站1

Your aspx form, sending login information or session information to site 2 您的aspx表单,将登录信息或会话信息发送到站点2

site 2 网站2

Retrieve that information sanitize it, and check it against for example a database if that user exists and or if the user session send by site 1 is logged in. you could use a authenticate function, checking the database to see if session or users exists 检索该信息以对其进行清理,并针对该数据库(例如,如果该用户存在)或是否已登录站点1发送的用户会话进行了检查。您可以使用身份验证功能,检查数据库以查看会话或用户是否存在

site 2 网站2

<?php
    $user_is_loggedin = 1; // this should come from database or function check user
    if ($user_is_loggedin == TRUE) {
     echo 1; // return user id, current session stored in database on site2
    } else {
     echo 0;
    }
?>

site 1: dont know aspx so.. 网站1:不知道aspx如此..

if (reponse == FALSE ) {
 //REDIRECT TO LOGIN
} ELSE {
 // Do whatever you would like with that reponse
}

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

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