CakePHP的2.0和移动应用认证 [英] CakePHP 2.0 and mobile application authentication

查看:157
本文介绍了CakePHP的2.0和移动应用认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要疯了在这里!我有一个网站,我想提出在CakePHP中,将形成一个移动应用程序的后端。它不是一个移动网站,它的设计纯粹用于智能电话应用

这就是说:该应用程序需要登录用户。但我似乎无法找到实现这个正确的方式。 的BasicAuthenticate AuthComponent好像很讨厌我,不会使调试容易。这里有一个的的OAuth 2.0提供的插件CakePHP的2.0 ,但我想不出如何使它2条腿,因为应用程序将不会依赖于网站上显示登录表单。

我真的需要弄清楚要采取的这些路径,以及如何使它发挥作用,但只是没有人愿意合作。任何人有什么我需要做的任何信息?

更新的基本认证的问题竟然是由于的Virtualmin preferring使用FCGId,以允许进程作为同一所有者的网站的内容运行。因为我已经切换回mod_php的,它工作正常。

所以我的问题是,现在更多使用 CakePHP的,OAuth的服务器腿的设置。

解决方案

 公共职能beforeFilter(){
    父母:: beforeFilter();
    $这个 - > Auth->允许('指数','查看');
    $这个 - >集(LOGGED_IN',$这个 - > Auth->的loggedIn());
    $这个 - >集(CURRENT_USER',$这个 - > Auth->用户());
    如果($这个 - >名称=='具体'){
            //对于特定的控制器
            $这个 - > Auth->身份验证=阵列(基本);
    } 其他 {
            // 其他东西
    }
}
 

结算KVZ休息插件,它可能是利益 https://github.com/kvz/cakephp的-rest-插件

I'm going nuts over here! I've got a website I am making in CakePHP that will form the back end of a mobile application. It is not a mobile website, it's designed purely to be used for a smartphone application.

That being said: The application needs the user to login. But I just cannot seem to find the right way to implement this. The BasicAuthenticate AuthComponent seems to hate me and doesn't make debugging easy. There's an OAuth 2.0 Provider plugin for CakePHP 2.0, but I can't figure out how to make it 2 legged, as the app won't be relying on the website to display a login form.

I really need to figure out which of these paths to take and how to make it work but just neither one wants to work. Anybody have any info on what I need to do?

Update The Basic Auth issue turned out to be due to Virtualmin preferring to use FCGId to allow the process to run as the same owner as the content of the website. I have since switched it back to mod_php and it works fine.

So my question is now more about using cakephp-oauth-server in a 2 legged setup.

解决方案

public function beforeFilter() {
    parent::beforeFilter();
    $this->Auth->allow('index','view');
    $this->set('logged_in', $this->Auth->loggedIn());
    $this->set('current_user',$this->Auth->user());
    if($this->name == 'Specific') {
            // for the specific controller
            $this->Auth->authenticate = array('Basic');
    } else {
            // everything else
    }
}

checkout KVZ's rest plugin it may be of interest https://github.com/kvz/cakephp-rest-plugin

这篇关于CakePHP的2.0和移动应用认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆