Labshare Auth Documentation
Setting up LSAuth locally
This document describes the minimal steps to get Labshare Auth and NG-Auth running on a desktop.
Prerequisites
- Node JS version 10 or newer.
- LSC (Labshare Command Line Interface: https://github.com/ncats/lsc
npm i -g @labshare/lsc
- Docker: https://www.docker.com/get-started
- Git
- Code Editor (e.g., VSCode)
- Note: This document will assume MacOS. Differences for Windows will be noted.
- Access to private npm and github for Labshare. (Contact a Labshare admin to get access.)
- Configure NPM credential access:
- npm adduser (https://docs.npmjs.com/cli/adduser)
- Configure Github credentials
- Set your username globally (https://help.github.com/en/github/using-git/setting-your-username-in-git)
\$ git config --global user.name "Jo Rabbit"
- Configure your SSH key: https://help.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh
- Set your username globally (https://help.github.com/en/github/using-git/setting-your-username-in-git)
Installation
Create a folder and navigate into the folder in your console
mkdir labshare
cd labshare
Clone the GitHub repo
Using HTTPS
git clone https://github.com/ncats/auth-monorepo.git
Using SSH
git clone git@github.com:ncats/auth-monorepo.git
NOTE: If you plan to submit changes you should fork the repos. See: https://labshare.atlassian.net/wiki/spaces/LA/pages/613417080/LabShare+Development+Procedures
Install the Dependencies using NPM
cd ng-auth; npm i; cd ..
cd auth; npm i; cd ..
Edit the Configuration for Auth
NOTE: See the docs in GitHub for the most up-to-date config info: configuration
-
Copy the sample-config.json to the /auth/config directory and rename to “local.json”
-
Modify the system.administrators to include your login email address, and the identity issuer, e.g.,
{
"auth": {
"system": {
"administrators": [ { "email": "admin@example.com", "identityIssuer": "https://accounts.google.com" } ]
}
}
}
Note: the issuer
for NIH is https://auth.nih.gov/affwebservices/public/wsfeddispatch
.
Note: Only the NIH provider is configured in the sample config file. To use Google or another provider you will need to configure it first. See: <configuration.md#tenant-authentication-providers>.
Edit the Configuration for NG-Auth
NOTE: See the docs in GitHub for the most up-to-date config info: https://github.com/ncats/auth-monorepo/tree/main/packages/ng-auth
Set the Config Options
To build the project locally, you will need to provide values for the environment variables defined in config/default.js
.
You can do this by either creating a .env
file in the project root and setting values there, or by providing them as environment variables.
Example .env file
SERVICES_AUTH_URL=https://a-ci.labshare.org/_api
SERVICES_AUTH_CLIENT_ID=auth-ui
SERVICES_AUTH_TENANT=ls
UNAUTHORIZED_ROUTE=landing
POST_LOGOUT_REDIRECT_URI=http://localhost:8080
Start NG-Auth
cd ng-auth
lsc start site
Note: You can also add more configurations inside the config folder and pass in the file on the command line.
lsc start site --env={name of your .json/.js file}
Start Auth
Make sure you have Docker Desktop running.
Note for Windows: https://github.com/docker/for-win/issues/868#issuecomment-312639000
Run the following commands in your terminal to start the DB, update the DB to the latest schema, and start the service:
cd auth
export DB_PORT=3306; npm run up; sleep 15; npm run migrate; npm start
Note: If you’re using Windows you should use “set” instead of “export” Note: If you run into a port conflict on 3306, change it to something else like 3307
Log in to NG-Auth (the admin console for Auth)
- Navigate to http://localhost:8080
- Select “Manage Tenants”
- Log in using an admin account configured above
Restarting Auth
Note: If you make any code changes, rebuild and start auth again:
npm run build ; npm start
Alternatively, run npm run watch:build
in a separate terminal to continously rebuild the code. Then you will only have to close and restart the service.