A minimal voting system through github identities
This project was created as a help to help ensure the quality of internal documentation at SEB. It is integrated as an iframe where every documentation path serves as a page id. It shows all users the votes currently in place for that page id, but to be able to vote, the user needs to login in through github's oauth flow. It uses bitnamis version of postgres and is thus able to run in OpenShift environments without the need to run as root.
Since these are not freely distributed, you need to to either change the HTML to include a different icon, or acquire a Font Awesome license key. To build with your key, create a .npmrc file to the root of the project and include the auth token there.
npm i
npm start
/npm e2e-test
or use docker compose
docker-compose up
- step inside the container
- run
npm start
/npm e2e-test
When running the tests it is sometimes practical to mock the github endpoint. This is done with the nock npm package and is enabled with the mockGithub
in settings.js
-
Create an Oauth app.
-
Set the app Authorization callback URL to http://localhost:5000/authorized to run locally or where ever you are deploying + /authorized
-
Deploy the application (or fill in the docker-compose) somewhere with the following environment variables, they will be given to the application through settings.js:
- githubUrl - either https://github.com or optionally an enterprise github installation e.g https://github.yourcompany.se
- client_id - fetch this from your newly created Oauth app
- client_secret - fetch this from your newly created Oauth app
- state_password - a randomly generated string, preferably 32 characters
-
To make sure everything works accordingly, visit http://localhost:5000/?page_id=exampleid&redirect_uri=http://localhost:5000, if you are running locally. This should give you a working frame for voting for page id "exampleid". If you are able to login and place votes, everything is ready to be integrated in an iframe.
-
Create an iframe inside your application where the votes should take place with the necessary params (pageId, ), e.g:
<iframe id="thumbs-up-frame" src="<URL of the deployed THUMBS_UP service>?redirect_uri=<URL to be redirected to after authed>&page_id=<ID of the page to be voted upon>></iframe>