diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3f38dc2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +settings.toml diff --git a/README.md b/README.md index 6fb0861..1a31351 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Some important features it still needs: * JWT authentication, and admin user permissions (kick/ban/etc.) * Support for profile URLs, custom avatar image URLs, custom profile fields to show in-app +* See who all is looking at your camera right now, and kick them off. * Lots of UI cleanup. # Configuration @@ -27,41 +28,128 @@ Some important features it still needs: Work in progress. On first run it will create the settings.toml file for you: ```toml +WebsiteURL = "http://localhost:8080" + [JWT] - Enabled = false - SecretKey = "" + Enabled = true + Strict = true + SecretKey = "change me" [[PublicChannels]] ID = "lobby" Name = "Lobby" Icon = "fa fa-gavel" + WelcomeMessages = ["Welcome to the chat server!", "Please follow the basic rules:\n\n1. Have fun\n2. Be kind"] [[PublicChannels]] ID = "offtopic" Name = "Off Topic" + WelcomeMessages = ["Welcome to the Off Topic channel!"] ``` +A description of the config directives includes: + +* **JWT**: settings for JWT [Authentication](#authentication). + * Enabled (bool): activate the JWT token authentication feature. + * Strict (bool): if true, **only** valid signed JWT tokens may log in. If false, users with no/invalid token can enter their own username without authentication. + * SecretKey (string): the JWT signing secret shared with your back-end app. +* **PublicChannels**: list the public channels and their configuration. The default channel will be the first one listed. + * ID (string): an arbitrary 'username' for the chat channel, like "lobby". + * Name (string): the user friendly name for the channel, like "Off Topic" + * Icon (string, optional): CSS class names for FontAwesome icon for the channel, like "fa fa-message" + * WelcomeMessages ([]string, optional): messages that are delivered by ChatServer to the user when they connect to the server. Useful to give an introduction to each channel, list its rules, etc. + # Authentication -BareRTC supports custom (user-defined) authentication with your app in the form -of JSON Web Tokens (JWTs). Configure a shared Secret Key in the ChatRTC settings -and have your app create a signed JWT with the same key and the following custom -claims: +BareRTC supports custom (user-defined) authentication with your app in the form of JSON Web Tokens (JWTs). JWTs will allow your existing app to handle authentication for users by signing a token that vouches for them, and the BareRTC app will trust your signed token. -```json +The workflow is as follows: + +1. Your existing app already has the user logged-in and you trust who they are. To get them into the chat room, your server signs a JWT token using a secret key that both it and BareRTC knows. +2. Your server redirects the user to your BareRTC website sending the JWT token as a `jwt` parameter, either in the query string (GET) or POST request. + * e.g. you send them to `https://chat.example.com/?jwt=TOKEN` + * If the JWT token is too long to fit in a query string, you may create a `