This project demonstrates how to write a Firefox extension that uses OAuth 2.0 to connect to a Mattermost user's account.
Clone this repository and cd
into it:
$ git clone https://github.com/mattermost/mattermost-firefox-extension
$ cd mattermost-firefox-extension
Create an OAuth 2.0 app on your Mattermost instance with these instructions
Configure the extension by modifying the constants in src/app/views/App.js
:
MATTERMOST_URL
to the URL for your Mattermost instanceOAUTH_APP_CLIENT_ID
to the Client ID you copied last stepLOGIN_HINT
to saml
if your Mattermost users login using a SAML IDP. This will skip the Mattermost login page and go directly to the SAML IDP's loginInstall dependencies and build the extension:
$ npm install
$ npm run build
Add the extension to Firefox:
about:debugging
in your Firefox browsermattermost-firefox-extension
directoryAllow cross-origin requests from your Firefox extension to Mattermost:
about:debugging
ServiceSettings.AllowCorsFrom
in your config.json
to moz-extension://<your-extension-id>
, e.g. moz-extension://ajfkdfomehaklgdhggbfhhicchlangjp
Use the extension
This extension uses React, though it is not a requirement for your extension.
The important demo code lives in src/app/views/App.js
. Read the code and comments in there to get a better understanding of how it works.
Make sure your extension follows the OAuth 2.0 RFC for clients. The implicit grant flow is used.