Closed primeminister closed 13 years ago
I would like to know the same thing as pm above on point one. What is this class for anyway. I thought you already store that somewhere in logs by the field" Controller? unless i am missing something.
For my application, I don't need logging or rate limiting, but I created rest_logs table anyway to get past "missing table" error. I was able to make some other headway by just making the callbacks an empty array around line 57 in rest.php. but this still results in "Unable to establish Class" warning/error and I am getting a parsing warning on xml output.
The latter may be my problem, but it would be nice to find a clean way to turn off logging/limiting to take that out of the troubleshooting picture.
Jim
The class error is fixed in both my and m3nt0r's forks. My fork actually simplifies the code quite a bit and makes the readme more readable. It was definitely a pain in the ass to set this plugin up, so hopefully my commits make their way into the core.
Jose,
Thanks for that info. I had not seen your fork/s yet, but I am browsing now. I may wait a bit to see if your fixes are merged to core. I agree that would be great. Meanwhile I try to figure out REST in general :)
Jim
My commits have been merged.
He @josegonzales and @kvz,
I update my Rest plugin version to the latest of master. Still got the issue of 'Unable to establish class' and I don't know how I can remove that feedback issue
What configuration are you using?
public $components = array(
'RequestHandler',
'Security',
//'Auth',
'Session',
'Rest.Rest' => array(
'skipControllers'=>array(
'pages',
'gebruikers'
),
'onlyActiveWithAuth'=>false,
'catchredir' => true, // Recommended unless you implement something yourself
'debug' => 2,
'actions' => array(
'index' => array(
'extract' => array(
'results.{n}.Order' => 'orders',
),
),
'toplist' => array(
'extract' => array(
'results.{n}.Res' => 'items',
)
),
'latest' => array(
'extract' => array(
'results.{n}.Campagne' => 'campagnes',
),
),
'view' => array(
'extract' => array(
'result.0' => 'item'
),
),
),
'log'=>null,
'extensions' => array('xml', 'json', 'csv'),
'auth'=>array(
'requireSecure'=>false,
'keyword' => '',
'fields'=>array(
'apikey'=>'apikey',
'email'=>'email',
),
),
),
);
I don't use the standard auth with the header TRUEREST etc. Just email and an apikey.
Maybe to solve my issue is to overwrite the Rest->credential() method. but don;t know how without changing the plugin itself
Here is my config:
public $components = array(
'RequestHandler',
'Rest.Rest' => array(
'auth' => array(
'requireSecure' => false,
'keyword' => 'AKEYWORD',
'fields' => array(
'class' => 'class',
'apikey' => 'password',
'username' => 'username',
),
),
'actions' => array(
'default_page' => array(
'extract' => false,
'embed' => false,
),
'one_items' => array(
'extract' => false,
'embed' => false,
),
),
'meta' => array('enable' => false)
)
);
I do overwrite my ApiController::beforeFilter()
as well to do some fancy footwork for extensions and Authsome
integration:
public function beforeFilter() {
// Default to json
if (empty($this->params['url']['ext'])) {
$this->params['url']['url'] .= '.' . $this->extensionDefault;
$this->params['url']['ext'] = $this->extensionDefault;
$this->Rest->Controller->params['url']['ext'] = $this->extensionDefault;
$this->RequestHandler->ext = $this->extensionDefault;
}
if (!in_array($this->params['url']['ext'], array('json', 'xml'))) {
$this->params['url']['url'] = str_replace('.' . $this->params['url']['ext'], '.json', $this->params['url']['url']);
$this->params['url']['ext'] = $this->extensionDefault;
$this->Rest->Controller->params['url']['ext'] = $this->extensionDefault;
$this->RequestHandler->ext = $this->extensionDefault;
}
$credentials = $this->Rest->credentials(true);
if ($this->Authsome->get('guest') && $this->Rest->isActive()) {
if (empty($credentials)) {
return $this->Rest->abort($this->_responses[401], $this->_responses[401]);
}
$credentials = array(
'login' => $credentials['username'],
'credential' => $credentials['password'],
);
if (!$this->Authsome->login('credentials', $credentials)) {
return $this->Rest->abort($this->_responses[403], $this->_responses[403]);
}
}
parent::beforeFilter();
}
nice. I added a keyword and added class to my auth settings but still get the meta feedback warning. Do you got the same with your settings?
He didn't pull in my changes to ignore the "class" key, so your request will either need to set the class, or you could redefine $_SERVER['HTTP_AUTHORIZATION']
to have the &class=class
' string in the request where necessary before you log the user in.
Is it possible for you to do something like 'class'=>false
in your config?
Ok. Solved it by setting the ratelimit['enabled'] = false.
Now my next issue why the added GET credentials are not in the META part of the response.
Thanks Jose!
He Kevin, Me again ;) Can you elaborate on the following questions?
That is it I think for now. :)