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

发布于 2024-10-19 11:31:44 字数 2052 浏览 5 评论 0原文

我已经尝试了好几个小时,但没有成功。我已经浏览了论坛,但我一生都无法让它发挥作用。任何有关此事的说明将不胜感激。

我正在跑步:
原版 2.0.17.8
ProxyConnect 版本 1.8.4
Cakephp 版本 1.3.3
Croogo 版本 1.3.2 (cakephp CMS)

我已经在子文件夹 app/webroot/vanilla 中安装了 Vanilla 论坛,

安装过程很顺利,我将 proxyconnect 插件上传到了 vanilla 插件文件夹中。 我激活它,并加载以下网址(我已取出 http:// 因为我是这里的新手,所以只允许发布 2 个链接)

  • 主站点 URL 您将使用的网站的 URL代理连接
    localhost:8888/cmrs

  • 验证 URL 与 Vanilla 共享身份信息的幕后 URL
    localhost:8888/cmrs/users/authenticate

  • 注册 URL 用户可以在您的网站上注册新帐户的 URL
    localhost:8888/cmrs/register

  • 登录 URL 用户在您的站点上登录的 URL
    localhost:8888/cmrs/users/login?vanilla=1

  • 注销 URL 用户从您的站点注销的 URL
    localhost:8888/cmrs/users/logout?vanilla=1

我在我的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);
    }
}

它会正确输出数据

<?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=';
}
?>

我创建了一个视图authenticate.ctp,如果您直接访问它并且登录

UniqueID=1
Name=admin
[email protected]
TransientKey=
DateOfBirth=
Gender=

, vanilla config.php 我已经

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

在 Cakephp bootstrap.php 中设置了,

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

所以,毕竟当我点击 vanilla 登录时,我会被重定向到蛋糕应用程序登录,当我登录时,我没有登录 Vanilla 论坛。

当我从 Vanilla 注销时,我会被重定向到蛋糕应用程序并从中注销,但不会从 Vanilla 注销。

任何建议将不胜感激。

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
ProxyConnect version 1.8.4
Cakephp Version 1.3.3
Croogo Version 1.3.2 (cakephp CMS)

I have installed the Vanilla forum in a subfolder app/webroot/vanilla

Install goes smoothly and I upload the proxyconnect plugin into the vanilla plugins folder.
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)

  • Main Site URL The URL of your website where you will use ProxyConnect
    localhost:8888/cmrs

  • Authenticate URL The behind-the-scenes URL that shares identity information with Vanilla
    localhost:8888/cmrs/users/authenticate

  • Registration URL The URL where users can sign up for new accounts on your site
    localhost:8888/cmrs/register

  • Sign-In URL The URL where users sign in on your site
    localhost:8888/cmrs/users/login?vanilla=1

  • Sign-Out URL The URL where users sign out of your site
    localhost:8888/cmrs/users/logout?vanilla=1

I have created an action in my users_controller called 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

<?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 protected]
TransientKey=
DateOfBirth=
Gender=

In vanilla config.php I have set

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

In Cakephp bootstrap.php I have set

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.

When I logout from Vanilla I get redirected to the cake app and am logged out from that but not from Vanilla.

Any suggestions would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

错爱 2024-10-26 11:31:44

从输出中删除

TransientKey=
DateOfBirth=
Gender=

,因为这将导致 ini 字符串格式因空白字符串而失败

Get rid of

TransientKey=
DateOfBirth=
Gender=

from your output as this will fail the ini string format due to blank strings

暗地喜欢 2024-10-26 11:31:44

首先,我过去在使用 CakePHP 的 AuthComponent 时被刺痛过一次,因为 cookie 没有按照我在 localhost 上预期的方式工作。我没有花太多时间进行调查,因为代码在生产环境(在真实域名上)中运行。

我建议您在 hosts 文件中添加一个具有真实域名的条目。假设您的生产 URL 为 http://www.example.com/http://forum.example.com/,您可以将虚假的开发子域映射到通过更新您的 hosts 文件来访问相同的域名,如下所示:

127.0.0.1       localhost dev.example.com

然后您将使用 http://dev.example.com:8888/ 而不是 http://localhost:8888/。之后,您需要更新 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');

其次,您应该使用开发工具来检查正在创建的任何 cookie,确保它们实际上是使用正确的域和路径设置创建的(我猜 CakePHP 应该创建 Proxyconnect 可以看到的 cookie)。轻松完成此操作的流行组合是使用 Firefox + Firebug + Firecookie,但许多新浏览器都内置了这些工具(例如,Chrome 中的资源选项卡包含 开发者工具)。

如果 CakePHP(或 Vanilla)安装在子目录中,您可能需要检查是否在子目录中创建了“沙盒”的 cookie。我相信 CakePHP 会默认执行此操作,除非您 ini_set('session.cookie_path', '/');

此外,当 CakePHP 的 Security.level 设置值为 high 时,它将针对每个请求重新生成一个(随机)会话 ID。我会将其设置为 medium,至少在测试时如此。

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. 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. 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:

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/. 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.

// 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). 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).

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. I believe CakePHP will do this by default unless you 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. I would set this to medium, at least while testing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文