CakePHP 2.0 和移动应用程序身份验证 [英] CakePHP 2.0 and mobile application authentication

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

问题描述

我要疯了!我有一个我正在用 CakePHP 制作的网站,它将构成一个移动应用程序的后端.它不是一个移动网站,它的设计纯粹是为了用于智能手机应用程序.

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.

也就是说:应用程序需要用户登录.但我似乎无法找到实现这一点的正确方法.BasicAuthenticate AuthComponent 似乎讨厌我,并没有让调试变得容易. 有一个 CakePHP 2.0 的 OAuth 2.0 Provider 插件,但我不知道如何使它成为两条腿,因为该应用程序不会依赖网站来显示登录表单.

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?

更新 基本身份验证问题原来是由于 Virtualmin 更喜欢使用 FCGId 来允许进程以与网站内容相同的所有者身份运行.我已经将它切换回 mod_php 并且它工作正常.

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.

所以我的问题现在更多是关于在 2 中使用 cakephp-oauth-server腿式设置.

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
    }
}

查看 KVZ 的 rest 插件,它可能会感兴趣 https://github.com/kvz/cakephp-rest-plugin

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

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

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