Skip to content

Generate client API keys for retrieval of tokens to use overhide services.

Notifications You must be signed in to change notification settings

overhide/overhide-client-auth

Repository files navigation

overhide.io

A free and fully open-sourced ecosystem of widgets, a front-end library, and back-end services — to make addition of "logins" and "in-app-purchases" (IAP) to your app as banal as possible.


overhide-client-auth

Client API key registration, token retrieval, and validation.

Tokens retrieved with this service are used to authorize into other overhide services: just provide as a Bearer ${..} token in the Authorization header.

For help, reach out on r/overhide.

Quick Start Docker

  1. npm install
  2. create a valid .npmrc.dev (from .npmrc.sample template)
  3. npm run compose-dev
  4. jump to "First Time DB Setup" section for the first-time DB setup
  5. jump to "Database Evolutions" section, especially the "For Docker" subsection
  6. your oh-client-auth container failed since your DB wasn't setup--now it is--find your oh-ledger container name: docker ps -a; look for oh-client-auth with an "Exited" status.
  7. start it again: docker start <container name>
  8. do a docker logs <container name> to make sure it's up
  9. browse to http://localhost:8100/register

Quick Start Non-Docker

  1. npm install
  2. jump to "First Time DB Setup" section for the first-time DB setup
  3. npm run start

Configuration

See .npmrc.sample.

Get the recaptcha keys from Google. Set as RECAPTCHA_SITE_KEY and RECAPTCHA_SECRET_KEY.

First Time DB Setup

All the DB connectivity configuration points assume that the DB and DB user are setup.

For localhost Docker, psql into the container:

npm run psql-dev
\c "oh-client-auth"
\dt

The 'adam' role and 'ohledger' DB should already be created and connected to with the above command (as per .npmrc.dev environment passed into docker-compose).

If not, to manually create:

postgres=# create database "oh-client-auth";
postgres=# create user adam with encrypted password 'c0c0nut';
postgres=# grant all privileges on database "oh-client-auth" to adam;

Make sure to set the configuration points in your .npmrc appropriately.

Now you're ready to run database evolutions on the new database.

Database Evolutions

There is a single Node file to check for and perform database evolutions.

Run it from the application node with npm run db-evolve.

It will evolve the database to whatever it needs to be for the particular application version.

The main/js/lib/database.js has an init(..) method which should check that the database is at the right evolution for that version of the app.

Consider currently running nodes before evolving: will they be able to run with the evolved DB? Perhaps stop them all before evolving.

Check

To check the database pre/post evolution (first time DB setup already done):

  • log into DB
  • list tables
npm run psql-dev
\dt oh-client-auth.*

If you need to select role and DB:

set role oh-client-auth;
\c oh-client-auth;

More commands: https://gist.github.com/apolloclark/ea5466d5929e63043dcf

Evolve

If running using Docker, jump into a container to run the evolution:

docker run -it --rm --link postgres:postgres --network oh_default oh-client-auth /bin/sh

Then run the evolution:

npm run db-evolve

Rate Limiting

Access to these APIs is gated via config points:

  • RATE_LIMIT_MAX_REQUESTS_PER_WINDOW
  • RATE_LIMIT_WINDOW_MS

This only applies to requests with a token other than the INTERNAL_TOKEN (if set). INTERNAL_TOKEN requests are not rate-limited.

All rate-limits are shared across nodes sharing the same RATE_LIMIT_REDIS_NAMESPACE if RATE_LIMIT_REDIS_URI is set to a redis instance.

About

Generate client API keys for retrieval of tokens to use overhide services.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages