GitHub - melvinodsa/go-iam: iam platform written in golang (original) (raw)

go-iam

codecov Go Report Card GoDoc Mentioned in Awesome Go

go-iam is a lightweight, multi-tenant Identity and Access Management (IAM) server built in Golang. It provides robust authentication and fine-grained authorization for modern applications. With support for custom roles, third-party auth providers, and multi-client setups, go-iam gives you full control over access management in a scalable and modular way.

โœ… Admin UI: go-iam-ui
๐Ÿณ Docker Setup: go-iam-docker
๐Ÿ” Backend: go-iam
๐Ÿ“ฆ SDK: go-iam-sdk
๐Ÿš€ Examples: go-iam-examples๐Ÿ’ฌ Reddit Community: r/GoIAM

go-iam overview


โœจ Features

๐Ÿ”€ Multi-Tenancy

๐Ÿ” Authentication Provider Integration

๐Ÿงฉ Client Management

๐Ÿงฑ Role-Based Access Control (RBAC)

๐Ÿ› ๏ธ Admin UI


๐Ÿงฐ Tech Stack

Component Tech
Backend Golang
Database MongoDB
Caching (opt) Redis
Frontend React + Vite (PNPM)

๐Ÿš€ Getting Started

Option 1: ๐Ÿ”ง Manual Setup (Development)

Prerequisites

Run the Backend

git clone https://github.com/melvinodsa/go-iam.git cd go-iam cp sample.env .env go run main.go

Use the official go-iam-docker repo to spin up everything with Docker Compose, including:

Steps

git clone https://github.com/melvinodsa/go-iam-docker.git cd go-iam-docker cp sample.env .env docker compose up -d

Access

๐Ÿงช Testing

Running Tests

Due to the extensive test suite in this project, it's important to use the correct testing command to avoid test caching issues that might cause local tests to pass while CI/CD fails.

Use this command for reliable testing:

go test -count=1 ./... -v --race -cover

Flags explanation:

Why -count=1 is important:

Running Specific Test Suites

Test specific package

go test -count=1 ./services/user -v --race -cover

Test specific function

go test -count=1 ./services/user -v --race -cover -run TestCopyUserResources

๐Ÿ“ฆ Environment Variables

Some important environment variables used in .env:

Variable Description
LOGGER_LEVEL Logger level 1 - Debug (refer., https://docs.gofiber.io/api/log/)
DB_HOST MongoDB URI (e.g., mongodb://user:pass@host/db)
JWT_SECRET Secret key used for generating and verifying JWT tokens
REDIS_HOST, REDIS_PASSWORD, ENABLE_REDIS Redis host address and toggle to enable Redis caching
ENCRYPTER_KEY Optional symmetric key for encrypting sensitive fields - change this
AUTH_PROVIDER_REFETCH_INTERVAL_IN_MINUTES Interval in minutes to refetch and sync third-party auth providers
TOKEN_CACHE_TTL_IN_MINUTES Interval for which the authentication token should be valid

License