{"id":52120,"date":"2026-06-05T17:06:56","date_gmt":"2026-06-05T21:06:56","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=52120"},"modified":"2026-06-05T17:06:56","modified_gmt":"2026-06-05T21:06:56","slug":"permissions-in-the-cloudkit-public-database","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2026\/06\/05\/permissions-in-the-cloudkit-public-database\/","title":{"rendered":"Permissions in the CloudKit Public Database"},"content":{"rendered":"<p><a href=\"https:\/\/www.rambo.codes\/posts\/2021-12-06-using-cloudkit-for-content-hosting-and-feature-flags\">Guilherme Rambo<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.rambo.codes\/posts\/2021-12-06-using-cloudkit-for-content-hosting-and-feature-flags\">\n<p>When using the public database for content hosting or feature flags, you don&rsquo;t want any random iCloud user to have the rights to publish or edit content on your behalf or to change the feature flags that control your app&rsquo;s behavior for all of your users, that would be really bad.<\/p><p>That&rsquo;s where CloudKit&rsquo;s security roles come in. You can think of them as Unix access control groups for record types. They allow you to restrict the types of operations that users belonging to a given group (security role) can perform on any given record type, and you can then assign security roles to specific users.<\/p>\n<p>[&#8230;]<\/p>\n<p>The creator role means &ldquo;the user who has created this record&rdquo;. So it&rsquo;s possible to allow any authenticated user to create a record of a given type in the public database, but not read or write to any record other than the ones that they have created themselves.<\/p>\n<p>[&#8230;]<\/p>\n<p>But the most interesting thing about security roles for content hosting and similar applications is that we can define our own security roles and assign them to specific users.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/mastodon.social\/@simonbs\/116036103122531645\">Simon B. St&oslash;vring<\/a>:<\/p>\n<blockquote cite=\"https:\/\/mastodon.social\/@simonbs\/116036103122531645\">\n<p>So can we actually use CloudKit&rsquo;s public database to store user-specific and\/or sensitive data without it being widely available? So it&rsquo;s more like a traditional database an app can build functionality on?<\/p>\n<p>Can anyone confirm this?<\/p>\n<p>If that&rsquo;s the case, I&rsquo;ve totally misunderstood the public database for years. I have always considered it suitable only for sample data and other data meant to be broadly accessible without auth.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/mstdn.social\/@strnmn\/116039865092133739\">Moritz Sternemann<\/a>:<\/p>\n<blockquote cite=\"https:\/\/mstdn.social\/@strnmn\/116039865092133739\">\n<p>yep correct! That&rsquo;s the conclusion I also came to when working more with CloudKit a while ago. You can definitely have data in the public database that&rsquo;s only readable by the user who created it.<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/iosdev.space\/@jaanus\/116076490413700767\">Jaanus Kase<\/a>:<\/p>\n<blockquote cite=\"https:\/\/iosdev.space\/@jaanus\/116076490413700767\">\n<p>The main distinction for me is, who owns the data<\/p>\n<p>Private db: user owns data, I as developer literally have no way to access it. Also it&rsquo;s counted towards the user&rsquo;s iCloud storage quota<\/p>\n<p>Public db: I as developer own the data, and my app has storage quota not tied to any user<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Guilherme Rambo: When using the public database for content hosting or feature flags, you don&rsquo;t want any random iCloud user to have the rights to publish or edit content on your behalf or to change the feature flags that control your app&rsquo;s behavior for all of your users, that would be really bad.That&rsquo;s where CloudKit&rsquo;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2026-06-05T21:06:59Z","apple_news_api_id":"28a9c677-b98d-408d-a4f8-4a72bcc6157c","apple_news_api_modified_at":"2026-06-05T21:07:00Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AKKnGd7mNQI2k-EpyvMYVfA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[916,16,31,2741,30,2742],"class_list":["post-52120","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cloudkit","tag-icloud","tag-ios","tag-ios-26","tag-mac","tag-macos-tahoe-26"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/52120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=52120"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/52120\/revisions"}],"predecessor-version":[{"id":52122,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/52120\/revisions\/52122"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=52120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=52120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=52120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}