53 Commits

Author SHA1 Message Date
shadlaws
9b9f1a7b07 #2031 - Add class_exists() before method_exists() if class existence is unknown.
- fixed all instances of this in core code
- deleted previous Zend Guard Loader workaround in MY_Kohana.php
- updated Bootstrap.php to reflect deleted MY_Kohana.php
2013-03-02 13:25:10 +01:00
shadlaws
fd0051dab7 #2006 - Add system::mark_file_for_delete API to delete files at shutdown.
- added system::mark_file_for_delete to be called to mark a file
- added system::delete_marked_files to be called at shutdown to delete the list
- amended system::temp_filename to, by default, add the temp name to the list
- updated a few other places in code where this should be used
2013-02-17 23:19:35 +01:00
Bharat Mediratta
d45a737779 Update copyright to 2013. Fixes #1953. 2013-01-21 01:22:01 -05:00
Bharat Mediratta
bf2bb3e1ea Update copyright to 2012. #1822 2012-02-27 09:48:23 -08:00
Bharat Mediratta
e5175fd277 Fix the standard and REST uploaders to use a callback function to
delete temporary files during shutdown.  Fixes #1788.
2011-10-03 23:19:44 -07:00
Bharat Mediratta
423daa52d5 Update copyright to 2011. 2011-01-21 23:01:06 -08:00
Bharat Mediratta
b5ba61fc53 Create a way for controllers to exempty themselves from maintenance
mode and private gallery mode by setting the following constants in
the controller to true.

  ALLOW_MAINTENANCE_MODE
  ALLOW_PRIVATE_GALLERY

Fixes #1411 and the subsequent refactoring fixes #1551 as well.
2010-12-23 23:34:04 -08:00
Bharat Mediratta
554ca2e683 Take into account the core.url_suffix configuration setting when
parsing REST urls.  This fixes the problem that setting the url suffix
breaks REST.  Fixes #1500.
2010-11-22 22:01:11 -08:00
Bharat Mediratta
0014745d4a Add a button to the user profile page to let you reset your REST API
key.  This is useful if you think it's been compromised in some way.
Fixes ticket #1226.
2010-08-08 21:49:30 -07:00
Bharat Mediratta
71a32e4e24 POST requests create a new entity and should result in a 201 Created
reply with a Location field that matches the URL of the newly created
resource.  Fixes ticket #1178.
2010-07-16 14:23:03 -07:00
Bharat Mediratta
ed704e6a3b Trap 404s and return Rest_Exception instead. Fixes ticket #1213. 2010-07-16 12:16:20 -07:00
Bharat Mediratta
456d54ea2d Throw exceptions as appropriate, but allow the Kohana exception
handling framework to handle the exception and delegate to our
template, which will JSON encode the response.
2010-06-19 14:07:37 -07:00
Bharat Mediratta
9b78867427 Simplify rest::get_access_key($user) to rest::access_key() that
returns just the access key string for the active user.  That's how we
use the API, so keep it simple.
2010-06-18 20:43:14 -07:00
Bharat Mediratta
295a42e0f1 change single to double quotes. 2010-06-18 20:20:05 -07:00
Tim Almdal
30849d10b1 Tweak the error response for rest requests to make it easier for the client to extract error information. 2010-06-10 08:18:15 -07:00
Tim Almdal
d5b80f2944 Don't use the standard error formatting for exceptions that have occurred as part of a REST request. Format the exception as a json encoded text string so the client can extract the fault information if they so choose. 2010-06-08 14:35:35 -07:00
Tim Almdal
9bb4c954bb Merge bharat_dev rest implementation 2010-04-07 08:07:41 -07:00
Tim Almdal
f2ed1eeab2 Merge branch 'master' into talmdal_dev
Conflicts:
	modules/rest/controllers/rest.php
2010-03-31 07:14:06 -07:00
Bharat Mediratta
ca977dce51 Rename "access_token" to "access_key" in the code for consistency. 2010-03-30 14:01:40 -07:00
Tim Almdal
7b35091b47 If the access token is not set, then look in the post data. 2010-03-21 20:45:22 -07:00
Tim Almdal
48b8b4f689 Merge branch 'master' into talmdal_dev 2010-03-13 23:11:53 -08:00
Tim Almdal
13f5d3aa33 Whitespace correction 2010-03-13 23:11:33 -08:00
Tim Almdal
5467e21e8b Changes to support updating the child elements within an album. In this change the urls of the children are sent up asan array of post fields children[0].... children[n]. If an existing child is not included it is deleted. Including a url to an child in another album will move the child. Changing the order of the children will respect the order of the children, if the sort column is 'weight' 2010-03-13 08:39:06 -08:00
Bharat Mediratta
c3c2b45280 Update the copyright to 2010. It's only 3 months into the year :-) 2010-03-03 10:15:34 -08:00
Tim Almdal
7d7da6eb0a Remove redundant print statement. rest::reply() does the print so having the extra print statement could lead to problems. 2010-02-24 11:49:53 -08:00
Bharat Mediratta
aff5d1cef4 Create the concept of a "failed authentication" as semantically
separate from a successful or failed login.

1) Rename user_login_failed event to user_authenticate_failed

2) Rename failed_logins table to failed_auth (bump Gallery module to
   v27 to rename the table)

3) auth::too_many_failed_logins -> auth::too_many_failures

4) auth::record_failed_auth_attempts -> auth::record_failed_attempts
   auth::clear_failed_auth_attempts  -> auth::clear_failed_attempts
2010-02-07 08:45:10 -08:00
Bharat Mediratta
c050acf30a Fix lots of warnings that pop up when we're in E_STRICT mode. They're
mostly issues around uninitialized variables, calling non-static
functions in a static context, calling Session functions directly
instead of on its singleton, passing non-variables by reference, and
subclasses not using the same interface as the parent class.
2010-01-31 16:07:41 -08:00
Bharat Mediratta
d92ee7954e Refactory auth::too_many_failed_logins() out of
auth::validate_too_many_failed_logins() to conceptually separate the
two.
2010-01-30 23:15:18 -08:00
Andy Staudacher
1470b99d1f Protect REST login controller from brute force attacks too.
And make the REST auth token less predictable by using a better source for randomness.
2010-01-30 21:42:57 -08:00
Bharat Mediratta
bcf1caad14 Reshape the rest code to be more consistent with regards to
relationships.  Now when you view a resource, it has 4 top level
elements:

url: the url of this resource
resource: array of key value pairs describing the resource
members: array of urls to members of this collection
relationships: array of array of members.

Relationships are a special type of collection that links two
different resources together.  To remove a relationship, just
DELETE its url.  To create a relationship, POST to its
collection.

Individual modules can add their own relationships to any
resource via a callback mechanism.

Example:
  Array(
    [url] => http://g3.com/rest/item/1
    [resource] => Array (
      [id] => 1
      [album_cover_item_id] => 4
      [captured] =>
      [created] => 1264056417
      [description] =>
      [height] =>
      ...
    )
    [members] => Array(
      [0] => http://g3.com/rest/item/2
      [1] => http://g3.com/rest/item/3
      [2] => http://g3.com/rest/item/4
      [3] => http://g3.com/rest/item/5
      ...
    )
    [relationships] => Array(
      [tags] => Array (
      [0] => http://g3.com/rest/tag_item/2,1
      [1] => http://g3.com/rest/tag_item/23,1
      )
    )
  )
2010-01-22 00:27:00 -08:00
Bharat Mediratta
5119d58e7f Move access key creation into a helper function. 2010-01-20 00:07:03 -08:00
Bharat Mediratta
b09450cf5d Let the Rest_Controller functions throw a Rest_Exception since
the Kohana framework will handle it properly.
2010-01-19 23:30:22 -08:00
Bharat Mediratta
fc4250f5d8 Use $input instead of Input::instance() 2010-01-19 22:37:38 -08:00
Bharat Mediratta
eea9368777 Have the rest calls return an array and print it out in the
controller.  This is a clearer workflow; controllers generate output,
not helpers.  It's also easier to test.
2010-01-19 00:36:19 -08:00
Bharat Mediratta
4197ee39b9 Catch ORM_Validation_Exception and turn it into a 400 Bad Request with
appropriate error output.
2010-01-17 16:58:54 -08:00
Bharat Mediratta
3fffa18e65 Further progress on refining the REST server side code.
1) Deal in fully qualified URL resources through the rest
   interface.  All rest methods are now passed the complete url in
   request->url.

2) Create rest::resolve() which lets individual resource definition
   code convert a full url into the appropriate matching resource.
   Implement gallery_rest::resolve() and tag_rest::resolve()

3) Reimplement tag_rest's get() and post() methods.  They're much
   simpler now.

4) Implement the tags_rest helper which supports working with the
   entire tags collection.
2010-01-04 21:48:21 -08:00
Bharat Mediratta
0e3327bca7 Simplify the REST API code. Here's what I did:
1) Simplify gallery_rest to return flat models, no children and do no
   validation for now.
2) Flatten the REST replies and use HTTP codes to indicate
   success/failure instead of additional status messages.
3) Use the message and error code support in the base Exception class,
   instead of brewing our own in Rest_Exception.
4) Get rid of rest::success() and rest::fail() -- we only need
   rest::reply() since all failures are covered by throwing an
   exception.
5) Get rid of /rest/access_key and just use /rest for authentication.
6) Inline and simplify rest::normalize_request since we only use it once
7) Change rest::set_active_user to succeed or throw an exception
8) Extract Rest_Exception::sendHeaders into rest::send_headers()

Here's what's currently broken:
1) Data validation.  There currently is none
2) Logging.  That's gone too
3) image block and tag code is broken
4) Tests are broken
5) No movie support
2010-01-03 20:30:35 -08:00
Tim Almdal
5b9801092b Remove the Rest_Exception::trigger method. 2010-01-02 16:55:06 -08:00
Tim Almdal
28597ba533 Correct file structure tests, Have the tests delete the userid they create so as not to impact other tests. 2010-01-02 14:31:59 -08:00
Tim Almdal
40d496edee Remove extra debug statement in rest_controller::access_key() and restructure the Rest_Tag_Helper_Test to only create items as required for test in each test. 2009-12-31 13:24:00 -08:00
Tim Almdal
4611eb2142 Move the set_active_user and normalize_request methods to rest.php helper 2009-12-31 12:32:54 -08:00
Tim Almdal
1a12a5e3c8 Create a Rest_Exception class and use it to convey status to the client instead of calling rest::forbidden and other rest helper error messages. 2009-12-31 11:51:51 -08:00
Tim Almdal
bccb6fc021 Clean up validation the check for duplicate names or slugs, finish converting the rest API to Kohana 2.4 2009-12-27 08:32:12 -08:00
Tim Almdal
d0dd6650be When normalizing the rest request don't assume that the additional arguments are acutall a path. Leave it up to the handler to determine. 2009-12-23 13:13:03 -08:00
Tim Almdal
cbe5a89a9f Update the api so it allows images to be uploaded. 2009-12-22 12:32:27 -08:00
Tim Almdal
fd7990735c Added validation to the edit functionality, since we can't trust any input 2009-12-21 11:25:11 -08:00
Tim Almdal
2e221a84cc Change how request input is processed.First the input is no longer json encode, All the get variables are loaded, then the post variables if the request is a post, and then the path is extracted from the uri. 2009-12-18 14:59:44 -08:00
Tim Almdal
22e813d0be Updates the the interface based on actually using it. 2009-12-15 10:57:10 -08:00
Tim Almdal
367f2218f6 Use the relative url cache to look up resources instead of the relative path. This allows us to forego the extension as part of the REST url. As well, urls are consistent between normal usage and rest usage. 2009-12-09 08:41:38 -08:00
Tim Almdal
9319f37c4f Correct the error message when the item is not found; remove the check for no request_key (access_token) as athat is treated as public permissions 2009-12-08 23:27:43 -08:00