-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement invites and private mode in freedom-social-firebase providers #33
Merged
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b9f024a
Refactored authenticate method, starting email provider
dborkan d484163
More changes...
dborkan 54e5161
Create or login to account based on userId and password in version st…
dborkan 590e3c0
Email provider
dborkan 0c0ed62
More fixes for email provider
9b415fe
Invite mode for Google+
3b0bc0e
Cleanup
d460426
Refactor common code
3a3df5b
Refactor
ad0c948
Merge branch 'master' of github.com:freedomjs/freedom-social-firebase…
1c9e3a2
Fix FB oauth scope
4f6b66a
Function renames, cleanup
bd9a808
Changes to /friends directory structure
60ce81b
Code cleanup
3670c72
Changes for code review
240cc7b
Add newline
696dff2
Add version (v parameter) to invite string
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
{ | ||
"rules": { | ||
// This section is for the old, pre-invite Facebook provider. It can be deleted once that provider is no longer in use. | ||
"facebook-users": { | ||
"$user_id": { | ||
".read": "$user_id === auth.uid", | ||
".write": "$user_id === auth.uid", | ||
"friends": { | ||
"$friend_id": { | ||
".read": "$user_id === auth.uid || $friend_id === auth.uid", | ||
"inbox": { | ||
".write": "$friend_id === auth.uid && root.child('facebook-users').child($user_id).child('friends').hasChild($friend_id)", | ||
} | ||
} | ||
}, | ||
"clients": { | ||
".read": "$user_id === auth.uid || root.child('facebook-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
} | ||
} | ||
}, | ||
// This section is for the old, pre-invite Google+ provider. It can be deleted once that provider is no longer in use. | ||
"google-users": { | ||
"$user_id": { | ||
".read": "$user_id === auth.uid", | ||
".write": "$user_id === auth.uid", | ||
"friends": { | ||
"$friend_id": { | ||
".read": "$user_id === auth.uid || $friend_id === auth.uid", | ||
"inbox": { | ||
".write": "$friend_id === auth.uid && root.child('google-users').child($user_id).child('friends').hasChild($friend_id)", | ||
} | ||
} | ||
}, | ||
"clients": { | ||
".read": "$user_id === auth.uid || root.child('google-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
} | ||
} | ||
}, | ||
// This section is for the experimental "Firebase Email" social provider and can be ignored (only used for the Firebase email prototype). | ||
"simplelogin-users": { | ||
"$user_id": { | ||
".read": "$user_id === auth.uid", | ||
".write": "$user_id === auth.uid", | ||
"friends": { | ||
"$friend_id": { | ||
".read": "$user_id === auth.uid || $friend_id === auth.uid", | ||
"inbox": { | ||
".write": "$friend_id === auth.uid && root.child('simplelogin-users').child($user_id).child('friends').hasChild($friend_id)", | ||
} | ||
} | ||
}, | ||
"clients": { | ||
".read": "$user_id === auth.uid || root.child('simplelogin-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
}, | ||
"friendRequestsWithToken": { | ||
"$permission_tokenn": { | ||
".write": "root.child('simplelogin-users').child(auth.uid).child('receivedInviteTokens').hasChild($permission_tokenn) && root.child('simplelogin-users').child($user_id).child('generatedInviteTokens').hasChild($permission_tokenn)" | ||
} | ||
}, | ||
"receivedFriendRequests": { | ||
"$friend_id": { | ||
".write": "$friend_id === auth.uid" | ||
} | ||
}, | ||
"acceptedFriendRequests": { | ||
"$friend_id": { | ||
".write": "$friend_id === auth.uid && root.child('simplelogin-users').child($user_id).child('sentFriendRequests').hasChild($friend_id)" | ||
} | ||
}, | ||
"profile": { | ||
".read": "root.child('simplelogin-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
} | ||
} | ||
}, | ||
// This section is also for the experimental "Firebase Email" social provider and can be ignored (only used for the Firebase email prototype). | ||
"simplelogin-user-mapping": { | ||
".read": "true", | ||
".write": "true" | ||
}, | ||
// All new rules for invite-based Google and Facebook social providers go here. | ||
"v2": { | ||
"facebook-users": { | ||
"$user_id": { | ||
/* | ||
* By default, only Alice can read and write to Alice's directory. | ||
*/ | ||
".read": "$user_id === auth.uid", | ||
".write": "$user_id === auth.uid", | ||
"friends": { | ||
/* | ||
* Alice has 1 directory per Facebook friend. | ||
*/ | ||
"$friend_id": { | ||
/* | ||
* For Alice's friend Bob, either Alice or Bob can read Alice's | ||
* directory for Bob (directory at /v2/facebook-friends/<Alice_id>/friends/<Bob_id>) | ||
*/ | ||
".read": "$user_id === auth.uid || $friend_id === auth.uid", | ||
"inbox": { | ||
/* | ||
* Bob can write to Alice's inbox for him only if he is already listed as a friend under Alice. | ||
* e.g. Bob can only write to /v2/facebook-friends/<Alice_id>/friends/<Bob_id>/inbox/ | ||
* if /v2/facebook-friends/<Alice_id>/friends/<Bob_id>/ already exists. | ||
*/ | ||
".write": "$friend_id === auth.uid && root.child('v2/facebook-users').child($user_id).child('friends').hasChild($friend_id)", | ||
}, | ||
"inviteResponses": { | ||
/* | ||
* Bob can only write to inviteResponses/$permission_tokenn for himself, if Bob has an entry in receivedPermissionTokens | ||
* which matches an entry in Alice's generatedPermissionTokens directory (not readable by Bob). | ||
* e.g. Bob can only write to /v2/facebook-friends/<Alice_id>/friends/<Bob_id>/inviteResponses/<permission_token> | ||
* if there is an entry with the same permission_token at /v2/facebook-friends/<Bob_id>/receivedPermissionTokens/<permission_token>/ | ||
* and another entry with the same permission_token at /v2/facebook-friends/<Alice_id>/generatedPermissionTokens/<permission_token>/ | ||
*/ | ||
"$permission_tokenn": { | ||
".write": "$friend_id === auth.uid && root.child('v2/facebook-users').child(auth.uid).child('receivedPermissionTokens').hasChild($permission_tokenn) && root.child('v2/facebook-users').child($user_id).child('generatedPermissionTokens').hasChild($permission_tokenn)" | ||
} | ||
} | ||
} | ||
}, | ||
"clients": { | ||
// Bob can only read from Alice's /clients/ directory if Bob is listed as a friend under Alice's /friends/ directory. | ||
".read": "$user_id === auth.uid || root.child('v2/facebook-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
}, | ||
"profile": { | ||
s// Bob can only read from Alice's /profile/ directory if Bob is listed as a friend under Alice's /friends/ directory. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: s// should be // |
||
".read": "root.child('v2/facebook-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
} | ||
} | ||
}, | ||
// This section is identical to the /v2/facebook-users/ rules only with "google" used instead of "facebook". TODO: we should look for a way to combine these rules. | ||
"google-users": { | ||
"$user_id": { | ||
".read": "$user_id === auth.uid", | ||
".write": "$user_id === auth.uid", | ||
"friends": { | ||
"$friend_id": { | ||
".read": "$user_id === auth.uid || $friend_id === auth.uid", | ||
"inbox": { | ||
".write": "$friend_id === auth.uid && root.child('v2/google-users').child($user_id).child('friends').hasChild($friend_id)", | ||
}, | ||
"inviteResponses": { | ||
"$permission_tokenn": { | ||
".write": "$friend_id === auth.uid && root.child('v2/google-users').child(auth.uid).child('receivedPermissionTokens').hasChild($permission_tokenn) && root.child('v2/google-users').child($user_id).child('generatedPermissionTokens').hasChild($permission_tokenn)" | ||
} | ||
} | ||
} | ||
}, | ||
"clients": { | ||
".read": "$user_id === auth.uid || root.child('v2/google-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
}, | ||
"profile": { | ||
".read": "root.child('v2/google-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{ | ||
"rules": { | ||
"facebook-users": { | ||
"$user_id": { | ||
".read": "$user_id === auth.uid", | ||
".write": "$user_id === auth.uid", | ||
"friends": { | ||
"$friend_id": { | ||
".read": "$user_id === auth.uid || $friend_id === auth.uid", | ||
"inbox": { | ||
".write": "$friend_id === auth.uid && root.child('facebook-users').child($user_id).child('friends').hasChild($friend_id)", | ||
} | ||
} | ||
}, | ||
"clients": { | ||
".read": "$user_id === auth.uid || root.child('facebook-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
} | ||
} | ||
}, | ||
"google-users": { | ||
"$user_id": { | ||
".read": "$user_id === auth.uid", | ||
".write": "$user_id === auth.uid", | ||
"friends": { | ||
"$friend_id": { | ||
".read": "$user_id === auth.uid || $friend_id === auth.uid", | ||
"inbox": { | ||
".write": "$friend_id === auth.uid && root.child('google-users').child($user_id).child('friends').hasChild($friend_id)", | ||
} | ||
} | ||
}, | ||
"clients": { | ||
".read": "$user_id === auth.uid || root.child('google-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
} | ||
} | ||
}, | ||
"simplelogin-users": { | ||
"$user_id": { | ||
".read": "$user_id === auth.uid", | ||
".write": "$user_id === auth.uid", | ||
"friends": { | ||
"$friend_id": { | ||
".read": "$user_id === auth.uid || $friend_id === auth.uid", | ||
"inbox": { | ||
".write": "$friend_id === auth.uid && root.child('simplelogin-users').child($user_id).child('friends').hasChild($friend_id)", | ||
} | ||
} | ||
}, | ||
"clients": { | ||
".read": "$user_id === auth.uid || root.child('simplelogin-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
}, | ||
"friendRequestsWithToken": { | ||
"$permission_token": { | ||
".write": "root.child('simplelogin-users').child(auth.uid).child('receivedInviteTokens').hasChild($permission_token) && root.child('simplelogin-users').child($user_id).child('generatedInviteTokens').hasChild($permission_token)" | ||
} | ||
}, | ||
"receivedFriendRequests": { | ||
"$friend_id": { | ||
".write": "$friend_id === auth.uid" | ||
} | ||
}, | ||
"acceptedFriendRequests": { | ||
"$friend_id": { | ||
".write": "$friend_id === auth.uid && root.child('simplelogin-users').child($user_id).child('sentFriendRequests').hasChild($friend_id)" | ||
} | ||
}, | ||
"profile": { | ||
".read": "root.child('simplelogin-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
} | ||
} | ||
}, | ||
"simplelogin-user-mapping": { | ||
".read": "true", | ||
".write": "true" | ||
}, | ||
"v2": { | ||
"facebook-users": { | ||
"$user_id": { | ||
".read": "$user_id === auth.uid", | ||
".write": "$user_id === auth.uid", | ||
"friends": { | ||
"$friend_id": { | ||
".read": "$user_id === auth.uid || $friend_id === auth.uid", | ||
"inbox": { | ||
".write": "$friend_id === auth.uid && root.child('v2/facebook-users').child($user_id).child('friends').hasChild($friend_id)", | ||
}, | ||
"inviteResponses": { | ||
"$permission_token": { | ||
".write": "$friend_id === auth.uid && root.child('v2/facebook-users').child(auth.uid).child('receivedPermissionTokens').hasChild($permission_token) && root.child('v2/facebook-users').child($user_id).child('generatedPermissionTokens').hasChild($permission_token)" | ||
} | ||
} | ||
} | ||
}, | ||
"clients": { | ||
".read": "$user_id === auth.uid || root.child('v2/facebook-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
}, | ||
"profile": { | ||
".read": "root.child('v2/facebook-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
} | ||
} | ||
}, | ||
"google-users": { | ||
"$user_id": { | ||
".read": "$user_id === auth.uid", | ||
".write": "$user_id === auth.uid", | ||
"friends": { | ||
"$friend_id": { | ||
".read": "$user_id === auth.uid || $friend_id === auth.uid", | ||
"inbox": { | ||
".write": "$friend_id === auth.uid && root.child('v2/google-users').child($user_id).child('friends').hasChild($friend_id)", | ||
}, | ||
"inviteResponses": { | ||
"$permission_token": { | ||
".write": "$friend_id === auth.uid && root.child('v2/google-users').child(auth.uid).child('receivedPermissionTokens').hasChild($permission_token) && root.child('v2/google-users').child($user_id).child('generatedPermissionTokens').hasChild($permission_token)" | ||
} | ||
} | ||
} | ||
}, | ||
"clients": { | ||
".read": "$user_id === auth.uid || root.child('v2/google-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
}, | ||
"profile": { | ||
".read": "root.child('v2/google-users').child($user_id).child('friends').hasChild(auth.uid)" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: permission_token
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh oops! saw that it's actually $permission_tokenn below; was that intentional?