SkygearIO / skygear-SDK-iOS

Skygear SDK for iOS
https://skygear.io
Other
10 stars 28 forks source link

Remember and apply default ACL settings to records #96

Open cheungpat opened 7 years ago

cheungpat commented 7 years ago

When calling -[SKYContainer defineDefaultAccessWithRecordType] the SDK should remember the settings and apply default ACL settings to record when needed (see below). The default ACL settings does not need to persist across application relaunch because it is expected that the developer will always call this method when the app launches.

The default ACL should not be applied to a record when it is instantiated. The default ACL should only apply when the the developer tries to mutate the record ACL.

Since -[SKYRecord accessControl] is readonly and nil when record is instantiated, it is not reasonable to expect the developer to change the record ACL using methods provided in SKYAccessControl. To make the iOS SDK to match the design of the JS/Android SDK, we should add -[SKYRecord set[Public](No|ReadOnly|Write)Access[For(User|Role)]] that implement record ACL mutation.

When default ACL for the record type is not defined, the fallback ACL will apply. The fallback ACL is public-readable.

If record ACL is null, getting the record ACL will not cause the record ACL to change. Return the default ACL or fallback ACL in this case.

Implement -[SKYRecord get[Public](No|ReadOnly|Write)Access[For(User|Role)]] for getting record ACL.

In earlier versions of the SDK, +[SKYAccessControl (set|get)DefaultAccessControl] sets and gets the default ACL that applies to all record types. These methods should be retained but deprecated. These methods should alter the fallback ACL. In other words, calling these methods will override the fallback ACL of public-readable.

cheungpat commented 7 years ago

I recommend that you don’t make SKYAccessControl/SKYRecord calls SKYContainer for getting the default ACL / fallback ACL.