This is the identity management service.
Be sure you've read the instructions for contributing.
-
Globally install nvm, avn, and avn-nvm.
curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash npm install -g avn avn-nvm avn setup
-
Create an npm account if you don't have one, then setup your
NPM_AUTH_TOKEN
:npm login # in your current shell as well as in ~/.bashrc (or ~/.zshrc, etc) export NPM_AUTH_TOKEN=$(cat $HOME/.npmrc | grep _authToken | cut -d '=' -f2)
-
Clone the repository.
-
Setup and run mehserve. Then figure out which port you intend to use and create the mehserve config file:
echo 9001 > ~/.mehserve/idm.learnersguild mehserve run
-
Set your
NODE_ENV
environment variable:export NODE_ENV=development
-
# With Homebrew on a mac: brew install rethinkdb
-
Install Redis.
brew install redis
-
Obtain your GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET (see below) by registering a new GitHub OAuth application for your development environment:
- Application name: Learners Guild IDM (dev)
- Homepage URL: http://idm.learnersguild.dev
- Authorization callback URL: http://idm.learnersguild.dev/auth/github/callback
-
Generate a key-pair for JWT token signing / verifying:
openssl genrsa -out /tmp/private-key.pem 2048 openssl rsa -in /tmp/private-key.pem -outform PEM -pubout -out /tmp/public-key.pem
-
Create a free AWS account: https://aws.amazon.com
Make a copy of your access key ID and secret access key. You'll need to include these in your environment variables in the next step.
-
Create your
.env.development
file for your environment. Example:PORT=9001 REDIS_URL=redis://localhost:6379 RETHINKDB_URL=rethinkdb://localhost:28015/idm_development GITHUB_CLIENT_ID=<from above> GITHUB_CLIENT_SECRET=<from above> # Both of the URLs below are needed and remove this commented line APP_BASE_URL=http://idm.learnersguild.dev IDM_BASE_URL=http://idm.learnersguild.dev # For JWT string data below, replace all linebreaks with \n # and include -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- # remove these three commented lines JWT_PRIVATE_KEY="<quoted string data from /tmp/private-key.pem >" JWT_PUBLIC_KEY="<quoted string data from /tmp/public-key.pem replace all linebreaks with \n >" S3_BUCKET=guild-development S3_KEY_PREFIX=db AWS_ACCESS_KEY_ID=<YOUR_AWS_ACCESS_KEY_ID> AWS_SECRET_ACCESS_KEY=<YOUR_AWS_SECRET_ACCESS_KEY>
-
Run the setup tasks:
npm install npm run db:create npm run db:migrate -- up
-
Seed your development database with test member and project data:
npm run db:copy
-
Run the server:
npm start
-
Visit the server in your browser:
open http://idm.learnersguild.dev
-
(OPTIONAL) Add some test users:
npm run data:users -- --verbose --role=learner some-dummy-invite-code
If you've used the db:copy script to seed the database and still aren't logged in, there isn't an idm user in the test data linked to your github account. You'll need to manually insert an invite code to the database and use it to sign up in your local idm service.
Go to localhost:8080
and use the Data Explorer
to run the following command to issue yourself an invitation code.
r.db('idm_development').table('inviteCodes').insert({
id: '58abd2aa-3826-4604-bf7c-f8f2cf7eaad9',
code: 'hand_crafted_artisanal_invite_code',
description: 'hand crafted artisanal invite code',
roles: ['admin', 'member'],
active: true,
createdAt: r.now(),
updatedAt: r.now(),
})
Use the invitation code hand_crafted_artisanal_invite_code
to create an account.
In the event that you see Javascript and C compilation errors when running npm start
,
ensure that your installed node version matches the node version in package.json:
➜ cat package.json | grep node\"
"node": "5.6.x",
➜ node -v
v5.6.0
To run multiple versions of node on your machine, install nvm
and then use 5.6
If you see errors that look like this:
TypeError:
method: GET /
params: {}
TypeError: An internal server error occurred
at Strategy.OAuth2Strategy (/Users/jrob/workspace/learners-guild/idm/node_modules/passport-oauth2/lib/strategy.js:82:34)
at new Strategy (/Users/jrob/workspace/learners-guild/idm/node_modules/passport-github/lib/strategy.js:62:18)
or
TypeError: OAuth2Strategy requires a clientID option
Ensure that your NODE_ENV
is set:
export NODE_ENV=development
When attempting to npm login
, was seeing Error: Failed to replace env in config: ${NPM_AUTH_TOKEN}
.
export NPM_AUTH_TOKEN=""
See the LICENSE file.