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 authentication to chat messages #879

Merged
merged 6 commits into from
Jan 15, 2021

Conversation

tomasvidhall
Copy link
Contributor

@tomasvidhall tomasvidhall commented Dec 29, 2020

Closes #876

Follow-up to #871 which implements the new auth logic implemented in #853 for chat messages. I think this code will make it possible for spectators to send chat messages (with no sender id though), but it will be impossible to impersonate another player in the chat.

Please feedback and improve @delucis @nicolodavis

Checklist

  • Use a separate branch in your local repo (not master).
  • Test coverage is 100% (or you have a story for why it's ok).

delucis
delucis previously requested changes Jan 4, 2021
Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

Thanks @tomasvidhall and Happy New Year! This looks good in general. I have one question about leaving the chat open to spectators — let me know what you think.

The other comments recommend some more precise typing that will help with future refactoring. Updating these might require some changes in the tests to fix some TypeScript errors — if anything isn’t clear, I’ll be happy to help.

} else {
({ metadata } = await this.storageAPI.fetch(key, { metadata: true }));
}
if (this.auth && chatMessage.sender !== undefined) {
Copy link
Member

@delucis delucis Jan 4, 2021

Choose a reason for hiding this comment

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

I’m not 100% sure about allowing spectators to post messages without authentication, although this is an improvement over allowing them to claim to be a player. Is this a functionality you need? In general I would lean towards only permitting players to post, but am open to being more flexible if you definitely need it (or perhaps adding a server option to enable spectator chat).

src/client/transport/socketio.ts Outdated Show resolved Hide resolved
src/server/transport/socketio.ts Outdated Show resolved Hide resolved
src/client/transport/local.ts Outdated Show resolved Hide resolved
Metadata is only used for authentication, which always runs 
asynchronously in any case. If the storage API actually is synchronous, 
`await` will have no effect.
@delucis delucis dismissed their stale review January 15, 2021 20:21

Resolved in subsequent commits

@delucis delucis merged commit c178a41 into boardgameio:master Jan 15, 2021
@delucis
Copy link
Member

delucis commented Jan 15, 2021

Thanks for getting this rolling @tomasvidhall. I wanted to get this released, so I’ve merged this for now without spectator chat. Please feel free to open a PR adding that back in later if you need it!

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.

Authenticate chat messages
2 participants