The credential and authorization API service for oauth token flow and credential management.
The project requires the following highly-available services to be running:
You can inject the configuration for access to these services as environment variables.
Local development uses a local postgresql database and google cloud sdk image for google pubsub. The default config values will enable the services to speak to one another
npm i
docker-compose up -d
npx knex migrate:latest
npm start # You only need to run npm start if you do not have oauth running as a docker-compose service.
The following environment variables allow you to inject configuration into the oauth API at runtime.
APP_NAMEThe name of this instance of the API.APP_PORTThe port to bind the API to listen to requests on.APP_CORSThe configuration to pass the CORS middleware as a JSON string. See @koa/cors for the full configuration options.LOG_LEVELThe log level to set for the log output. See Pino
DB_CLIENTThe database client. You can usesqlite3for running tests or local development. Default ispg(postgresql).DB_CONNECTION_TIMEOUTThe database connection timeout in milliseconds. Default is10000(10 seconds).DB_CONNECTION_HOSTThe database connection host DNS or IP including port, if necessary. Default islocalhost.DB_CONNECTION_USERThe database connection user. Default isoauth.DB_CONNECTION_PASSWORDThe database connection password. Default isroot.DB_CONNECTION_DATABASEThe database to connect to with. Default isoauth.DB_POOL_MINThe minimum size of the database connection pool. Default is0.DB_POOL_MAXThe maximum size of the database connection pool. Default is2.DB_MIGRATIONS_DIRThe directory path to where migrations files are located. Default is/src/database/migs.DB_MIGRATIONS_EXTThe extension to apply when creating new migration files. Default is.ts,.js.DB_MIGRATIONS_TABLEThe name of the table for logging database migrations. Default isknex_migs.DB_MIGRATIONS_LOAD_EXTSThe map of extensions to match when loading migrations for the migrations directory. Default is.tsand.js.DB_SEEDS_DIRThe directory path to where seed files are located. Default is/src/database/seeds.
PUBSUB_TOPICThe name of the topic to publish password reset email pubsub messages to. Default ismailer.sendPUBSUB_OPTSThe client config to apply to the pubsub client. See PubSub ClientConfig for full config options. Defaults to{ "projectId": "project-id", "apiEndpoint": "localhost:8085" }
GOOGLE_CLIENT_IDYour Google oAuth client ID.GOOGLE_CLIENT_SECRETYour Google oAuth client secret.
FACEBOOK_API_VERSIONThe API version to perform requests against. Defaults tov7.0.FACEBOOK_APP_IDYour Facebook app ID.FACEBOOK_APP_SECRETYour Facebook app secret.FACEBOOK_APP_TOKENYour Facebook app token.
CRYPTO_SECRETThe secret to use to encrypt stored passwords. Defaults topacopaco.
JWT_SECRETThe secret to use to sign access tokens with. Defaults topacopaco.JWT_DURATION_SECSThe duration in seconds until access tokens expire. Defaults to86400.JWT_REFRESH_DURATION_SECSThe duration in seconds until refresh tokens expire. Defaults to3600.JWT_RESET_DURATION_SECSThe duration in seconds until reset token tokens expire. Defaults to3600.COOKIE_KEYSThe map of keys to sign cookies with. Defaults topacoandpacopaco.COOKIE_OPTSThe options to pass when setting cookies on responses and reading cookies on requests. Defaults to{ "signed": true, "path": "/", "httpOnly": true, "secure": false, "overwrite": true, "sameSite": true }
cp config/test.example.yml config/test.yml
## Ensure you add working credentials for Google and Facebook OAuth to the config/test.yml configuration
docker-compose up -d
npm t