# README
Identity Provider
Project Setup
Configure Database Connection:
-
Create a PostgreSQL Database: Set up a PostgreSQL database either locally or on a remote server.
-
Copy the Environment File: Duplicate the
.example.env
file provided in the root directory of the project and rename it to.env
. -
Configure Environment Variables: Open the
.env
file in a text editor and fill in the required database connection details, includingDATABASE_NAME
,DATABASE_USER
, andDATABASE_PASSWORD
.
Setup RSA Key Pair
-
Create a Keys Directory: In the root of your project, create a directory named keys.
-
Generate RSA Key Pair: Inside the keys directory, generate an RSA key pair with the following commands:
openssl genpkey -algorithm RSA -out private_key.pem
openssl rsa -pubout -in private_key.pem -out public_key.pem
This will create private_key.pem and public_key.pem files in the keys directory.
Setup air live-reload
For detailed instructions on setting up Air for live-reload, please follow the official documentation.
Before starting the Air server, ensure the Go binary directory is added to your system's PATH environment variable. To achieve this, execute:
export PATH="$PATH:/home/your_username/go/bin"
Database migrations
We use golang-migrate/migrate
for managing database migrations. To create and apply migrations, follow these steps:
-
Install migrate CLI: Install the
migrate
command-line tool by following the instructions provided in the official repository. -
Create a Migration: Run the following command to create a new migration file:
make create_migration NAME=<migration_name>
-
Apply Migrations: To apply pending migrations and update the database schema, run:
make migration_up [N=<number_of_migrations_to_apply>]
-
Rollback Migrations: To rollback the applied migrations, run:
make migration_down [N=<number_of_migrations_to_rollback>]
Using Redis with go-redis/v9
We use go-redis/v9
as our in-memory database solution. To integrate it into your project, follow these steps:
-
Install Redis
go get github.com/redis/go-redis/v9
-
Start Redis server: To start the Redis server, simply run the following command in your terminal:
redis-server