简体   繁体   English

Vanilla论坛和CAKEPHP与ProxyConnect SingleSignOn(SSO)集成

[英]Vanilla forum and CAKEPHP integration with ProxyConnect SingleSignOn (SSO)

I have been trying in vain for many hours to get this working. 我一直在徒劳地尝试了好几个小时才能使它正常工作。 I have scoured the forums and cannot for the life of me get this to work. 我已经在论坛上进行过搜索,并且无法一生都可以使用它。 Any illumination on the matter would be much appreciated. 对此事的任何照会将不胜感激。

I am running: 我在跑步:
Vanilla version 2.0.17.8 香草版本2.0.17.8
ProxyConnect version 1.8.4 ProxyConnect版本1.8.4
Cakephp Version 1.3.3 Cakephp版本1.3.3
Croogo Version 1.3.2 (cakephp CMS) Croogo版本1.3.2(cakephp CMS)

I have installed the Vanilla forum in a subfolder app/webroot/vanilla 我已经在子文件夹app / webroot / vanilla中安装了Vanilla论坛

Install goes smoothly and I upload the proxyconnect plugin into the vanilla plugins folder. 安装过程很顺利,我将proxyconnect插件上传到vanilla plugins文件夹中。 I activate it, and the load the following urls (I have taken out http:// because I am only allowed to post 2 links as I am a newbie here) 我激活它,并加载以下网址(我取出了http://,因为我是新手,所以只允许发布2个链接)

  • Main Site URL The URL of your website where you will use ProxyConnect 主站点URL您将在其中使用ProxyConnect的网站的URL
    localhost:8888/cmrs 本地主机:8888 / cmrs

  • Authenticate URL The behind-the-scenes URL that shares identity information with Vanilla 身份验证URL与Vanilla共享身份信息的幕后URL
    localhost:8888/cmrs/users/authenticate 本地主机:8888 / cmrs / users / authenticate

  • Registration URL The URL where users can sign up for new accounts on your site 注册URL用户可以在您的网站上注册新帐户的URL
    localhost:8888/cmrs/register 本地主机:8888 / cmrs / register

  • Sign-In URL The URL where users sign in on your site 登录URL用户在您的网站上登录的URL
    localhost:8888/cmrs/users/login?vanilla=1 本地主机:8888 / cmrs / users / login?vanilla = 1

  • Sign-Out URL The URL where users sign out of your site 登出URL用户登出您网站的URL
    localhost:8888/cmrs/users/logout?vanilla=1 本地主机:8888 / cmrs / users / logout?vanilla = 1

I have created an action in my users_controller called authenticate() 我在users_controller中创建了一个名为authenticate()的操作

public function authenticate() {
    $this->layout = 'ajax';
    $this->header('Content-Type: text/plain');
    if($this->Auth->user()) {        
        $data = $this->Auth->user();
        $this->set('data', $data);
    }
}

I have created a view authenticate.ctp which outputs the data correctly if you access it directly and you are logged in 我创建了一个视图authenticate.ctp,如果您直接访问它并登录,它会正确输出数据

<?php  
if(isset($data)) {
    echo 'UniqueID='.$data['User']['id']."\n";
    echo 'Name='.$data['User']['username']."\n";
    echo 'Email='.$data['User']['email']."\n";
    echo 'TransientKey='."\n";
    echo 'DateOfBirth='."\n";
    echo 'Gender=';
}
?>

Outputs 产出

UniqueID=1
Name=admin
Email=you@your-site.com
TransientKey=
DateOfBirth=
Gender=

In vanilla config.php I have set 在香草config.php我已经设置

$Configuration['Garden']['Cookie']['Domain'] = '.localhost';

In Cakephp bootstrap.php I have set 在Cakephp bootstrap.php中,我已设置

ini_set('session.cookie_domain', '.localhost');

So, after all that when I click on signin from vanilla I get redirected to the cake app login and when I login I am not logged in in Vanilla Forum. 因此,毕竟,当我单击从Vanilla登录时,我将重定向到Cake App登录,而当我登录时,我没有登录Vanilla论坛。

When I logout from Vanilla I get redirected to the cake app and am logged out from that but not from Vanilla. 当我从Vanilla中注销时,我将重定向到Cake App,并从中注销,但未从Vanilla中注销。

Any suggestions would be greatly appreciated. 任何建议将不胜感激。

Get rid of 摆脱

TransientKey=
DateOfBirth=
Gender=

from your output as this will fail the ini string format due to blank strings 从您的输出中,因为由于空白字符串,这将导致ini字符串格式失败

Firstly, I have been stung once in the past when working with CakePHP's AuthComponent , with cookies not working the way I had expected on localhost . 首先,过去与CakePHP的AuthComponent一起使用时,我感到AuthComponent ,因为cookie无法像我在localhost上所期望的那样工作。 I didn't spend too much time investigating as the code worked in the production environment (on a real domain name). 由于代码在生产环境中(在真实域名上)有效,因此我没有花太多时间进行调查。

I suggest you add an entry to your hosts file with a realistic looking domain name. 建议您使用逼真的域名将条目添加到hosts文件。 Assuming your production URL will be http://www.example.com/ or http://forum.example.com/ , you can map a fake development subdomain to that same domain name by updating your hosts file like so: 假设您的生产URL为http://www.example.com/http://forum.example.com/ ,则可以通过更新hosts文件将伪造的开发子域映射到相同的域名,如下所示:

127.0.0.1       localhost dev.example.com

You would then access your development environment using http://dev.example.com:8888/ instead of http://localhost:8888/ . 然后,您将使用http://dev.example.com:8888/而不是http:// localhost:8888 /来访问开发环境。 After that, you would then need to update all the URLs in the Proxyconnect settings, and the cookie domains in the Vanilla/CakePHP configuration files to match this new domain. 之后,您将需要更新Proxyconnect设置中的所有URL,以及Vanilla / CakePHP配置文件中的cookie域,以匹配该新域。

// http://dev.example.com:8888/cmrs
// http://dev.example.com:8888/cmrs/users/authenticate
// http://dev.example.com:8888/cmrs/register
// http://dev.example.com:8888/cmrs/users/login?vanilla=1
// http://dev.example.com:8888/cmrs/users/logout?vanilla=1
$Configuration['Garden']['Cookie']['Domain'] = '.example.com';
ini_set('session.cookie_domain', '.example.com');

Secondly, you should be using a development tool to inspect any cookies being created, making sure they are actually being created with the correct domain and path settings (I guess CakePHP should be creating cookies that Proxyconnect can see). 其次,您应该使用开发工具来检查正在创建的任何cookie,确保它们实际上是使用正确的域和路径设置创建的(我猜CakePHP应该创建Proxyconnect可以看到的cookie)。 A popular combination for doing this easily is to use Firefox + Firebug + Firecookie , but many new browsers have these tools built in (eg. the Resources tab in Chrome's included Developer Tools ). 轻松执行此操作的一种流行组合是使用Firefox + Firebug + Firecookie ,但是许多新的浏览器都内置了这些工具(例如,Chrome随附的开发者工具中的“资源”标签)。

If CakePHP (or Vanilla) is installed in a subdirectory, you may need to check cookies are not being created that are "sandboxed" within the subdirectory. 如果CakePHP(或Vanilla)安装在子目录中,则可能需要检查子目录中未创建并被“沙盒包装”的cookie。 I believe CakePHP will do this by default unless you ini_set('session.cookie_path', '/'); 我相信CakePHP将默认执行此操作,除非您ini_set('session.cookie_path', '/'); .

Also, when CakePHP's Security.level setting has a value of high , it will regenerate a (random) session ID on each request. 同样,当CakePHP的Security.level设置的值是high ,它将在每个请求上重新生成(随机)会话ID。 I would set this to medium , at least while testing. 我至少在测试时将其设置为medium

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

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