Skip to content

hackathonbrn/sso-server

Repository files navigation

๐Ÿš€ OAuth Provider Service (SSO)

Self-hosted OAuth2 provider written in TypeScript using Fastify and Prisma.

๐Ÿ“ฆ Features

  • OAuth2 Authorization Code Flow
  • JWT-based tokens (Access & Refresh)
  • Redis session storage
  • PostgreSQL via Prisma ORM
  • REST API with Fastify
  • Cookie & Session support
  • Built-in logging (pino)
  • Environment validation (envalid)
  • Type-safe models using zod

๐Ÿงฑ Tech Stack

Layer Technology
Runtime Node.js >= 22
Framework Fastify
ORM Prisma
DB PostgreSQL
Session Redis + Fastify Session
Auth JWT + OAuth2
Logging Pino
Validation Envalid + Zod

๐Ÿ› ๏ธ Scripts

npm run dev            # Start dev server with hot reload
npm run build          # Build TypeScript to dist/
npm start              # Run compiled app from dist/
npm run prisma::migrate   # Create and apply migrations
npm run prisma::generate  # Generate Prisma client
npm run prisma::pull      # Pull DB schema into Prisma schema

๐Ÿ” Environment Variables

Create .env file:

PORT=3000
NODE_ENV=development

DATABASE_URL="postgresql://user:password@localhost:5432/dbname"

REDIS_HOST=localhost
REDIS_PORT=6379

JWT_SECRET=mysecretkey
SESSION_SECRET=session_secret_key

OAUTH_REDIRECT_URI="http://localhost:3000/oauth/callback"

๐Ÿ“ Project Structure

.
├── source/             # Source code
├── prisma/             # Prisma schema & migrations
├── build/              # Compiled TS output
├── .env                # Environment config
└── README.md

โœ… Development

  1. Install dependencies:

    npm install
  2. Pull database schema:

    npm run prisma::pull
  3. Generate Prisma client:

    npm run prisma::generate
  4. Migrate database:

    npm run prisma::migrate
  5. Start dev server:

    npm run dev

๐Ÿงช Testing

npm test

๐Ÿ“Œ License

BSD 2-Clause License

About

Self-hosted OAuth2 provider written in TypeScript using Fastify and Prisma

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors