Skip to content

BrewInteractive/oauth-server

Repository files navigation

Brew Logo

OAuth Server

Docker Pulls Package License

Instagram Linkedin Twitter

Purpose

This project contains implementation of OAuth 2.0 which is the industry-standard protocol for authorization. It's developed by using Spring Boot framework in Java.

Usage Instructions

These instructions provide information on how to use the oauth-server project.

Starting Locally

You can run the server in your local environment with below commands.

Dependency Installation

mvn clean install

Database Connection

You will need a postgres database with OAuth Server entities to run the server. You can run the OAuth Server Hasura in your local environment to get a proper database.

Environment Variables

You will need to add below environment variables to run the server. These values must be provided in env.properties file in the root directory.:

Variable Name Description Required Default Value
DB_HOST Represents the hostname of the database that needs to be connected. YES -
DB_NAME Represents the name of the database that needs to be connected. YES -
DB_USER Represents the user of the database that needs to be connected. YES -
DB_PASSWORD Represents the password of the database that needs to be connected. YES -
AUTHORIZATION_CODE_EXPIRES_MS Represents the expiry time of authorization code in milliseconds. NO 300000
LOGIN_SIGNUP_ENDPOINT Represents the login/signup endpoint of the implementer application. YES -
COOKIE_ENCRYPTION_SECRET Represents the secret while decrypting the user cookie. YES  -
ENABLE_SWAGGER Represents the enabling or disabling the swagger. NO -
USER_IDENTITY_SERVICE_URL Represents the identity service url to get user identity info. NO -
ENABLE_ID_TOKEN Represents the enabling or disabling id_token generation by getting user identity infor from user identity service. NO NO
ERROR_PAGE_URL Represents the page url to redirect on authorize error YES NO

Starting the Server

mvn spring-boot:start

Stopping the Server

mvn spring-boot:stop

Running with Docker

You can run the server in Docker environment with below commands:

First, you need to build the image:

docker build . -t oauth-server

Then, you can run the image with following command:

docker run -d -p 8080:8080 -e DB_HOST=<database_host> -e DB_NAME=<database_name> -e DB_USER=<database_username> -e DB_PASSWORD=<database_password> oauth-server -e LOGIN_SIGNUP_ENDPOINT=<login_signup_endpoint>

Running Tests

You can run the tests with below command:

mvn test

License

OAuth Server is MIT licensed.