Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isAdmin flag to RLMSyncUser #4699

Merged
merged 2 commits into from
Mar 31, 2017
Merged

Add isAdmin flag to RLMSyncUser #4699

merged 2 commits into from
Mar 31, 2017

Conversation

austinzheng
Copy link
Contributor

@austinzheng austinzheng commented Feb 25, 2017

Changes:

  • Sync users now expose a property indicating whether or not they are Realm Object Server administrator users

Requires: realm/realm-object-store#396

To do:

  • Verify it works with a version of ROS with the corresponding server change
  • Write test(s)

@austinzheng austinzheng self-assigned this Feb 25, 2017
@austinzheng austinzheng force-pushed the az/add-admin-check branch 2 times, most recently from 168b0ff to 40d2ede Compare March 2, 2017 18:38
@austinzheng austinzheng requested a review from bdash March 2, 2017 18:38
@austinzheng
Copy link
Contributor Author

I've manually verified that this works, but without a way to programmatically create admin vs non-admin users we can't write a test for it. I've added a FIXME; maybe this is simple enough that we can put off writing the test.

@@ -253,6 +254,7 @@ + (void)_performLogInForUser:(RLMSyncUser *)user
return;
}
user->_user = sync_user;
user.isAdmin = model.refreshToken.tokenData.isAdmin;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this state that should be tracked on object store's SyncUser class? I see that it already has SyncUser::is_admin(), which represents something different than this flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. There are actually two issues here:

  • One is that, as you said, the flag should be tracked on the object store class instead. If the user fetches another RLMSyncUser object pointing to the same user, it won't have the proper flag set.
  • The other is that the terminology is really confusing. We have the notion of a "client side admin user", which is a user who uses the admin token to open Realms, and a "server side admin user", which is a user flagged by ROS as an 'admin'. Perhaps we should rename the public API to "isObjectServerAdmin" or something similar.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ISTM that the concepts are really:

  • A user can be an admin or a normal user. Distinguishing those is what this PR is about.
  • The initial admin user (I think? Or is it more than just the initial user?) can authenticate via a special access token, bypassing the normal authentication flow. This is what SyncUser's m_is_admin currently tracks. This concept should probably be renamed to make it clear that it's about how the authentication is handled.

@austinzheng
Copy link
Contributor Author

I rebased and merged onto latest master. This can probably be reviewed now.

One thing I noticed was that git's conflict resolution algorithm might move changelog entries to random places in the changelog without complaining about merge conflicts. Something to watch out for (I suspect this may have happened to me in the past).

Changes:
- Sync users now expose a property indicating whether or not they are Realm Object Server administrator users
- Updated object store pointer
@@ -70,6 +70,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (nullable, nonatomic, readonly) NSURL *authenticationServer;

/**
Whether the user is an Realm Object Server administrator user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra "user" at the end feels redundant.

CHANGELOG.md Outdated

### Bugfixes

* None.
* Fix an issue where the project would fail to compile with clang 4.0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't relevant to Cocoa at the moment since no Xcode version exists that uses Clang 4.0.

@austinzheng
Copy link
Contributor Author

Object server tests pass and I verified things work manually as well. I'll merge it when CI finishes.

@austinzheng austinzheng merged commit fd853af into master Mar 31, 2017
@austinzheng austinzheng deleted the az/add-admin-check branch March 31, 2017 19:45
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants