Skip to content

Repository files navigation

EPB Authentication and Authorisation Server

A Sinatra based web application that is able to authenticate clients to secured API endpoints.

Running the auth server locally

The auth server requires two environment variables to be set: JWT_ISSUER and JWT_SECRET. Corresponding variables with the same names and values need to be set on the API server that connects to the auth server.

If you are running the server locally it is likely that you will be running it alongside another sinatra or rack application. The Makefile runs the server on port 9090 by default. To start the server on a different port run e.g. bundle exec rackup -p 9393

To use this most applications use the EPB_AUTH_SERVER environment variable.

When you start a server that will make calls to the authentication server, make sure you also set this environment variable as follows: EPB_AUTH_SERVER=http://localhost:9090 make run

Makefile Scripts

  • make install

    Install dependencies and perform any additional setup tasks.

  • make test

    Run all acceptance, integration, and unit tests.

  • make run

    Run the auth server, which will be available at http://localhost:9090.

  • make format

    Format source files according to the .editorconfig and prettier defaults

  • make db-setup

    Setup the database (Create > Migrate)

  • make db-teardown

    Drop the current database.

Environmental variables

APP_ENV

Set the Sintra environment. Should be one of "production", "development" or "test".

Sinatra will fallback to RACK_ENV or "development" if unset.

RAILS_ENV

sintra-activerecord uses APP_ENV as the active record environment, but will fallback to RAILS_ENV if it is not supplied.

This should be one of "production", "development" or "test". It will default to "development" if neither APP_ENV or RAILS_ENV is set.

RACK_ENV

Used by rackup to choose the default middleware stack. Should be one of "development" (default) or "deployment". If set to any other value no middleware stack is loaded.

STAGE

The EPB environment. Can be one of "test", "development", "integration", "staging" or "production".

  • Sets the unleash feature flag service app name to toggles-#{stage}
  • Unless "development" or "test", enables Sentry and sets its environment value

DATABASE_URL

Postgres connection string for connecting to the database

EPB_API_DOCS_URL

If present this will allow CORS for services with this origin.

EPB_UNLEASH_URI

The URL of the unleash feature flag service.

EPB_UNLEASH_AUTH_TOKEN

Authentication token for the unleash feature flag service.

JWT_ISSUER

Issuer for the JWT encoded auth token.

JWT_SECRET

Secret for the JWT encoded auth token.

URL_PREFIX

A path prefix for all routes.

For example if /auth the route /api/client becomes /auth/api/client.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages