Skip to content

Latest commit

 

History

History
149 lines (99 loc) · 10.2 KB

README.md

File metadata and controls

149 lines (99 loc) · 10.2 KB

Lectern Server

Container Registry Badge

Lectern Server is a standalone web service that provides a REST API to manage and share Data Dictionary schemas.

Technology

Lectern Server is a NodeJS service written in TypeScript.

It is published as a container on ghcr.io: Lectern Container Registry

Development

PNPM Monorepo Package Manager

This project uses pnpm instead of npm to facilitate a monorepo workspace.

You should install dependencies for the entire mono repo using:

pnpm install

Dependencies

Lectern Server relies on a MongoDB database to store dictionaries. To get you started, we provide a docker-compose configuration that will run a new instance of MongoDB in a container.

You can start the dependency dockers with (run from this directory):

docker-compose up -d

Build & Run

To build the server, and all modules it depends on:

pnpm nx build @overture-stack/lectern-server

or

pnpm build

To run the server:

pnpm nx start @overture-stack/lectern-server

or

pnpm start

To run the server in development mode, with hot reloading and exposing the node debugger:

pnpm nx debug server

Creating Docker Image

The Dockerfile that defines the Lectern Server image is located here in the server module directory, but building the container must be done with the workspace root as the docker context. The .dockerignore at the workspace root defines which files are included in context.

From the root of the workspace you can build the container with:

docker build --no-cache -t lectern -f apps/server/Dockerfile .

Configuration

Lectern Server accepts configuration parameters through environment variables.

A template for environment variables is found at ./.env.example.

From Source

When running from source as detailed in Build & Run, the application will look for a file named .env in the apps/server directory. The easiest way to manage this is to copy apps/server/.env.example into a new file named apps/server/.env.

cp .env.example .env

The file has all the available configurations with values set to match the applications default configuration.

From Container

When launching Lectern from container using Docker, you can pass an environment file to the container on start up by adding --env-file path/to/file.env to the command.

The .env file you pass to this command can follow the formatting of the template provided in ./.env.example.

Configuration Variables

All available configurations can be found in the example .env file: ./.env.example

Variable Name Required Type Default Description
OPENAPI_PATH No String /api-docs Path to Swagger UI with API documentation.
PORT No Number 3000 Port Lectern Server API will listen to.
CORS_ALLOWED_ORIGINS No String[] - List of domains that will be allowed by CORS. Multiple domains can be listed, separated by commas. Example: http://localhost:5173,https://example.com
AUTH_ENABLED No Boolean false Set to true to enable Authorization restrictions on all endpoints that modify data. For more details see Authorization.
AUTHZ_SERVICE_ID When AUTH_ENABLED is true String - Service ID configured for your app from AuthZ.
AUTHZ_SERVICE_UUID When AUTH_ENABLED is true String - Unique Id provided by AuthZ needed for the creation of verification tokens.
AUTHZ_ENDPOINT When AUTH_ENABLED is true String (URL) - Authz URL to query for authorization.
AUTH_PROVIDER_HOST When AUTH_ENABLED is true String (URL) - Authentication API URL (CILogon) service.
AUTH_CLIENT_ID When AUTH_ENABLED is true String - Client ID used for authentication service.
AUTH_CLIENT_SECRET When AUTH_ENABLED is true String - Client secret used for authentication service.
MONGO_DB No String lectern Name of Database to connect with in MongoDB
MONGO_HOST No String localhost Host of MongoDB
MONGO_PASS No String password Password used for MongoDB Connection
MONGO_HOST No Number 27017 Port of MongoDB
MONGO_USER No String admin User name for MongoDB Connection
VAULT_ENABLED No Boolean false Set to true to enable reading secret values from Vault. See Vault for Secret Storage.
VAULT_ROLE When VAULT_ENABLED is true String - Role to use for Vault connection, needs permission to read from VAULT_SECRETS_PATH
VAULT_SECRETS_PATH When VAULT_ENABLED is true String - Path to location in Vault that holds Lectern relevant secrets
VAULT_TOKEN When VAULT_ENABLED is true String - Access Token to read from Vault using specified VAULT_ROLE

Vault for Secret Storage

Lectern has an optional integration with Hashicorp Vault. If you use Vault to store configuration secrets, you can have Lectern connect to your Vault instance on startup. Some of the configuration variables will be read from Vault and used in the application config.

For Lectern Server, all MonogDB Configuration properties can be provided by Vault. If Vault is enabled, and Vault contains a secret with the same name as a MongoDB configuration variable, the secret will then be used in preference to any values provided in the Environment. This is useful for maintaing MongoDB connection details securely in Vault instead of in your deployment environment.

Authorization

Dictionary-Manager handles Authorization for protected endpoints through a different method in comparison to Lectern's Overture's Ego authorization service. Dictionary-Manager handles auth with two services; CILogon to handle authentication and AuthZ to handle authorization of protected endpoints.

Attention:

Auth is disabled by default. This helps reduce obstacles when starting to use Lectern and allows it to function without a supporting Auth server.

Any instance of Lectern running in a production environment should have authorization enabled.

Enabling Authentication/Authorization

For production environments, to enable Auth add the following defined in section above Configuration Variables as environmental variables.