{"id":754,"date":"2017-07-11T15:53:15","date_gmt":"2017-07-11T15:53:15","guid":{"rendered":"http:\/\/bitcows.com\/?p=754"},"modified":"2017-07-11T15:53:15","modified_gmt":"2017-07-11T15:53:15","slug":"appcelerator-mobile-backend-service-access-control-lists","status":"publish","type":"post","link":"https:\/\/bitcows.com\/?p=754","title":{"rendered":"Appcelerator Mobile Backend Service Access Control Lists"},"content":{"rendered":"<h3>Access Control Lists (ACL)<\/h3>\n<p>Mobile Backend Services are awesome, but sometimes you need them to be limited to some users. Thats where <a href=\"http:\/\/docs.appcelerator.com\/arrowdb\/latest\/#!\/api\/ACLs\" target=\"_blank\" rel=\"noopener\">Access Control Lists (ACL)<\/a> come in. The ACL object implements access control lists for mobile backend service objects. An access control list controls read and write access to any mobile backend service objects it&#8217;s attached to. You assign an ACL to an object via the object&#8217;s <code>acl_id<\/code> or <code>acl_name<\/code> properties. Currently, ACLs can be assigned to the following types of mobile backend service objects: <a href=\"http:\/\/docs.appcelerator.com\/arrowdb\/latest\/#!\/api\/Checkins\" target=\"_blank\" rel=\"noopener\">Checkins<\/a>, <a href=\"http:\/\/docs.appcelerator.com\/arrowdb\/latest\/#!\/api\/CustomObjects\" target=\"_blank\" rel=\"noopener\">CustomObjects<\/a>, <a href=\"http:\/\/docs.appcelerator.com\/arrowdb\/latest\/#!\/api\/Events\" target=\"_blank\" rel=\"noopener\">Events<\/a>, <a href=\"http:\/\/docs.appcelerator.com\/arrowdb\/latest\/#!\/api\/Files\" target=\"_blank\" rel=\"noopener\">Files<\/a>, <a href=\"http:\/\/docs.appcelerator.com\/arrowdb\/latest\/#!\/api\/Photos\" target=\"_blank\" rel=\"noopener\">Photos<\/a>, <a href=\"http:\/\/docs.appcelerator.com\/arrowdb\/latest\/#!\/api\/PhotoCollections\" target=\"_blank\" rel=\"noopener\">PhotoCollections<\/a>, <a href=\"http:\/\/docs.appcelerator.com\/arrowdb\/latest\/#!\/api\/Places\" target=\"_blank\" rel=\"noopener\">Places<\/a>, <a href=\"http:\/\/docs.appcelerator.com\/arrowdb\/latest\/#!\/api\/Posts\" target=\"_blank\" rel=\"noopener\">Posts<\/a>, <a href=\"http:\/\/docs.appcelerator.com\/arrowdb\/latest\/#!\/api\/Reviews\" target=\"_blank\" rel=\"noopener\">Reviews<\/a> and <a href=\"http:\/\/docs.appcelerator.com\/arrowdb\/latest\/#!\/api\/Statuses\" target=\"_blank\" rel=\"noopener\">Statuses<\/a>.<\/p>\n<h3>Examples<\/h3>\n<p>So lets look at how to do this on a photo. (<em>Note: you can also create ACL&#8217;s via the dashboard.<\/em>).<br \/>\nIn this example we are going to create an ACL that gives public read write access to everyone. Then we will apply that ACL to a newly created photo and give it the ACL <code>photo_access<\/code>.<\/p>\n<pre class=\"prettyprint\">\/\/ Logged in as User A:\nCloud.ACLs.create({\n    name: 'photo_access',\n    public_read: \"true\",\n    public_write: \"true\"\n}, function (e) {});      \n\n\/\/ Then create Photo that uses the \"photo_access\" ACL:\nCloud.Photos.create({\n    photo: Titanium.Filesystem.getFile('photo.jpg'),\n    acl_name: 'photo_access'\n}, function (e) { }); <\/pre>\n<p>Now lets say we want to update that access to only allow them write access for certain users. We do that by updating the ACL with <code>public_write: \"false\"<\/code> and a list of users <code>writer_ids: [userB, userC]<\/code> that we will allow to write\/update this photo. However we are still allowing public read access to this ACL.<\/p>\n<pre class=\"prettyprint\">\/\/ Logged in as User A:\nCloud.ACLs.update({\n    name: 'photo_access',\n    public_write: \"false\",\n    writer_ids: [userB, userC]\n}, function (e) {});<\/pre>\n<p>But what if we only wanted certain user to be able to even see this photo? In that case we would do something like this. Now only userB can see this photo along with any admin&#8217;s. <\/p>\n<p>(<em>NOTE: Application administrator are exempt from these ACL&#8217;s they can see everything. The object&#8217;s owner also  has read and write permission as well.<\/em>)<\/p>\n<pre class=\"prettyprint\">\/\/ Logged in as User A:\nCloud.ACLs.update({\n    name: 'photo_access',\n    public_read: \"false\",\n    reader_ids: [userB]\n}, function (e) {});<\/pre>\n<p>Now that you understand ACL&#8217;s get out there and try them. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Access Control Lists (ACL) Mobile Backend Services are awesome, but sometimes you need them to be limited to some users. Thats where Access Control Lists (ACL) come in. The ACL object implements access control lists for mobile backend service objects. An access control list controls read and write access to any mobile backend service objects&hellip;<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/bitcows.com\/?p=754\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":771,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5,6,9,15],"tags":[32,33,49],"class_list":["post-754","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-appcelerator","category-arrowdb","category-coding","category-ios","tag-appc","tag-arduino","tag-ios-2"],"_links":{"self":[{"href":"https:\/\/bitcows.com\/index.php?rest_route=\/wp\/v2\/posts\/754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitcows.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitcows.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitcows.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bitcows.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=754"}],"version-history":[{"count":0,"href":"https:\/\/bitcows.com\/index.php?rest_route=\/wp\/v2\/posts\/754\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bitcows.com\/index.php?rest_route=\/"}],"wp:attachment":[{"href":"https:\/\/bitcows.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitcows.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitcows.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}