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

Fix error that invite link doesn't work inside chat #2246

Merged
merged 27 commits into from
Jul 25, 2024

Conversation

Silver-IT
Copy link
Member

Summary of Changes

@Silver-IT Silver-IT requested a review from taoeffect July 23, 2024 00:13
@Silver-IT Silver-IT self-assigned this Jul 23, 2024
@Silver-IT Silver-IT linked an issue Jul 23, 2024 that may be closed by this pull request
Copy link
Member Author

@Silver-IT Silver-IT left a comment

Choose a reason for hiding this comment

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

Ready for the review!

Copy link

cypress bot commented Jul 23, 2024

Passing run #2794 ↗︎

0 112 10 0 Flakiness 0

Details:

Merge 6330f3d into 6380d4d...
Project: group-income Commit: e9a0a33305 ℹ️
Status: Passed Duration: 10:52 💡
Started: Jul 25, 2024 2:19 AM Ended: Jul 25, 2024 2:30 AM

Review all test suite changes for PR #2246 ↗︎

@@ -44,7 +44,7 @@ export function notifyAndArchiveProposal ({ state, proposalHash, proposal, contr
export function buildInvitationUrl (groupId: string, groupName: string, inviteSecret: string, creatorID?: string): string {
const rootGetters = sbp('state/vuex/getters')
const creatorUsername = creatorID && rootGetters.usernameFromID(creatorID)
return `${location.origin}/app/join#?${(new URLSearchParams({
return `${location.origin}/app/join?${(new URLSearchParams({
Copy link
Member

Choose a reason for hiding this comment

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

@corrideat Need your review on this

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, the hash symbol # was not needed since we saved all the parameters inside query which lies after ?.

Copy link
Member

@corrideat corrideat Jul 24, 2024

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

(also, if for some reason it works without a #, that's a bug: the query must not contain secrets)

Copy link
Member

Choose a reason for hiding this comment

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

@Silver-IT This PR needs to be closed while keeping this URL using a #.

The reason we're using a hash here is because the hash prevents the server from learning about what groups the user is joining, and also prevents the invite secret from being shared with the server.

Copy link
Member

@taoeffect taoeffect Jul 25, 2024

Choose a reason for hiding this comment

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

Why is it bug? I have updated all the related codes, and works fine all time.
The invite link is created, there is a secret inside. Why is it fine to contain secret in hash, and why not in query?

I answered both of these questions in my reply above.

The reason we're using a hash here is because the hash prevents the server from learning about what groups the user is joining, and also >>>> prevents the invite secret from being shared with the server. <<<

If the invite secret is shared with the server then it's not so secret anymore and the server could use it to join the group.

Regarding:

Why # and ? are there all together?

I'm not sure, perhaps it's to make it easier for using with URLSearchParams?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the invite secret is shared with the server then it's not so secret anymore and the server could use it to join the group.

So do you mean the first one is good in terms of secret and the second one is bad?

http://localhost:8000/app/join#?groupId=z9brRu3VXVfvXAHFxjuzphoq8mSsPt4Y8fVREeM5g9mPoSVEhFUG&groupName=Dreamers&secret=%5B%22edwards25519sha512batch%22%2Cnull%2C%224nGfJcEZjoVk7MOnPAZlKUBJeQbQthkK2YPAb%2BTXJwxpEIZfXdqJpTuQssNu0MrZUDbGsIrn5bOJdIODk5zRKw%3D%3D%22%5D
http://localhost:8000/app/join?groupId=z9brRu3VXVfvXAHFxjuzphoq8mSsPt4Y8fVREeM5g9mPoSVEhFUG&groupName=Dreamers&secret=%5B%22edwards25519sha512batch%22%2Cnull%2C%224nGfJcEZjoVk7MOnPAZlKUBJeQbQthkK2YPAb%2BTXJwxpEIZfXdqJpTuQssNu0MrZUDbGsIrn5bOJdIODk5zRKw%3D%3D%22%5D

And it's just the format change of invite link. There is no more changes. I can't understand what you mean by secret problem. What is the different on the server side when the user uses these two formats?

Copy link
Member

Choose a reason for hiding this comment

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

So do you mean the first one is good in terms of secret and the second one is bad?

Yes.

What is the different on the server side when the user uses these two formats?

The first one sends all of that information to the server and the second one doesn't.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now, I think I understood what you mean, @taoeffect. So we should use hash instead of query for the security reason.

Copy link
Member

Choose a reason for hiding this comment

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

Yep! 👍

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

Review ready!

@@ -44,7 +44,7 @@ export function notifyAndArchiveProposal ({ state, proposalHash, proposal, contr
export function buildInvitationUrl (groupId: string, groupName: string, inviteSecret: string, creatorID?: string): string {
const rootGetters = sbp('state/vuex/getters')
const creatorUsername = creatorID && rootGetters.usernameFromID(creatorID)
return `${location.origin}/app/join#?${(new URLSearchParams({
return `${location.origin}/app/join?${(new URLSearchParams({
Copy link
Member

Choose a reason for hiding this comment

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

@Silver-IT This PR needs to be closed while keeping this URL using a #.

The reason we're using a hash here is because the hash prevents the server from learning about what groups the user is joining, and also prevents the invite secret from being shared with the server.

Copy link
Member Author

@Silver-IT Silver-IT left a comment

Choose a reason for hiding this comment

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

Ready for the review!

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for the fixing the hash issue!

One issue:

Running "exec:flow" (exec) task
Error ------------------------------ frontend/views/containers/chatroom/chat-mentions/RenderMessageWithMarkdown.js:42:35

Cannot assign `url.hash` to `routerOptions.route['hash']` because property `hash` is missing in object literal [1].
[prop-missing]

   frontend/views/containers/chatroom/chat-mentions/RenderMessageWithMarkdown.js:42:35
   42|               routerOptions.route['hash'] = url.hash
                                         ^^^^^^

References:
   frontend/views/containers/chatroom/chat-mentions/RenderMessageWithMarkdown.js:40:35
   40|             routerOptions.route = { path, query }
                                         ^^^^^^^^^^^^^^^ [1]



Found 1 error
The Flow check failed!

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

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

Excellent work @Silver-IT !

@taoeffect taoeffect merged commit 938161d into master Jul 25, 2024
4 checks passed
@taoeffect taoeffect deleted the 2240-invite-links-not-working-reliably branch July 25, 2024 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invite links not working reliably
3 participants