Skip to content

Commit

Permalink
Support node production build and add docs for node server setup (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
byn9826 authored Sep 6, 2024
1 parent 6f0978c commit bec6865
Show file tree
Hide file tree
Showing 27 changed files with 222 additions and 160 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@typescript-eslint/no-unused-vars": "error",
"comma-dangle": "off",
"@typescript-eslint/comma-dangle": ["error", "always-multiline"],
"no-undef": "off"
"no-undef": "off",
"import/no-named-as-default-member": "off"
}
}
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Melody Auth

**Melody Auth** is turnkey OAuth & authentication system leveraging Cloudflare’s infrastructure. It provides a robust and user-friendly solution for implementing and hosting your own oauth and authentication system with minimal configuration required.
**Melody Auth** is turnkey OAuth & authentication system that can be seamlessly deployed on Cloudflare’s infrastructure, utilizing Workers, D1, and KV, or self-hosted with Node.js, Redis, and PostgreSQL. It provides a robust and user-friendly solution for implementing and hosting your own oauth and authentication system with minimal configuration required.

## Features Supported
- OAuth 2.0 Support (Authorize, Token Exchange, Token Revoke, App Consent, App Scopes, RSA256 based JWT Authentication)
Expand All @@ -10,10 +10,12 @@
## Why Melody Auth?

### 1. Self-Controlled
[Server Setup](https://auth.valuemelody.com/auth-server.html)
- Deploy the entire system within minutes
- Leverage Cloudflare's infrastructure to minimize DevOps overhead.
- Full access to the source code
[Server Setup (Cloudflare)](https://auth.valuemelody.com/auth-server.html#environment-setup-cloudflare)
[Server Setup (Node)](https://auth.valuemelody.com/auth-server.html#environment-setup-node)
[Mailer Setup](https://auth.valuemelody.com/auth-server.html#mailer-setup)
- Deploy the entire system within minutes, either using Cloudflare’s infrastructure or self-hosted with Node.js, Redis, and PostgreSQL.
- Minimize DevOps overhead by leveraging Cloudflare, or maintain full control with a self-hosted solution.
- Full access to the source code for customization and scalability.

### 2. Admin Panel
[Admin Panel Setup](https://auth.valuemelody.com/admin-panel.html)
Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineUserConfig({
lang: 'en-US',

title: 'Melody Auth',
description: 'A turnkey OAuth & authentication system leveraging Cloudflare’s infrastructure.',
description: 'Effortless OAuth and Authentication, Built for Flexibility and Control.',

theme: defaultTheme({
logo: 'https://raw.githubusercontent.com/ValueMelody/melody-homepage/main/logo.jpg',
Expand Down
12 changes: 6 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ actions:
type: secondary

features:
- title: Effortless Deployment
details: Streamlined installation process for rapid implementation.
- title: Transparent Architecture
details: Full source code visibility, enabling thorough audits and modifications.
- title: Cloudflare-Powered
details: Utilizes Cloudflare's infrastructure for exceptional reliability and enhanced security measures.
- title: Flexible Deployment Options
details: Deploy quickly on Cloudflare’s edge network for low-latency global access or choose a self-hosted option with Node.js, Redis, and PostgreSQL for full control over your infrastructure.
- title: Comprehensive OAuth & Authentication Features
details: Melody Auth supports the OAuth 2.0 framework, along with advanced features like multi-factor authentication, brute-force protection, role-based access control, and seamless user authorization flows.
- title: Developer-Friendly Tools
details: With a user-friendly admin panel, React SDK for seamless front-end integration, and a powerful server-to-server REST API, developers can manage apps, users, and roles easily while ensuring secure communication between services.
---
81 changes: 57 additions & 24 deletions docs/auth-server.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Server Setup

## Prerequisites

- A Cloudflare account
- Node.js and npm installed on your local machine

## Installation and Setup
## Environment Setup (Cloudflare)

### 1. Cloudflare Account Setup
1. Sign up for a Cloudflare account if you don't have one already.
Expand Down Expand Up @@ -64,7 +59,62 @@ npm run prod:deploy
```
Now you are all set, you can verify your server by accessing: `[your_worker_url]/.well-known/openid-configuration`

## Email Functionality Setup
### Cloudflare Local development
To set up your local development environment, follow these steps:
```
git clone git@github.com:ValueMelody/melody-auth.git
cd melody-auth
npm install
npm run build
cd server
# Configure your email-related environment variables in dev.vars
cp dev.vars.example dev.vars
npm run dev:secret:generate
npm run dev:migration:apply
npm run dev:start
```

## Environment Setup (Node)

### 1. Node, Postgres and Redis setup
Begin by setting up your PostgreSQL and Redis servers, and ensure you have the connection strings ready for integration. Please also ensure you are using <b>Node.js version 20.05 or higher</b> for compatibility.

### 2. Project setup
```
git clone git@github.com:ValueMelody/melody-auth.git
cd melody-auth
npm install
npm run build
cd server
# Add your PostgreSQL and Redis connection strings to dev.vars
# Configure your email-related environment variables in dev.vars
cp dev.vars.example dev.vars
npm run node:secret:generate
npm run node:migration:apply
npm run node:dev
```

### 3. Production Build
To prepare for production, follow these steps:
1. Update server/src/routes/other.tsx file
```
# Comment out the current swagger.json import statement:
// import swaggerSpec from '../scripts/swagger.json';
# Uncomment the other swagger.json import statement which contains with { type: "json" }:
import swaggerSpec from '../scripts/swagger.json' with { type: "json" }
```

2. Run the following commands to build and start the server:
```
cd server
npm run node:build
npm run node:start
```

## Mailer Setup
Melody Auth supports email-based features such as password reset, email verification and email MFA. To make sure these features works as expected, you need to set up SendGrid or Brevo integration and configure the necessary environment variables in your Cloudflare Worker.

### Prerequisites
Expand Down Expand Up @@ -105,23 +155,6 @@ Melody Auth supports email-based features such as password reset, email verifica
- Priority Between SendGrid and Brevo:
- If both SendGrid and Brevo keys and sender addresses are provided, SendGrid will take precedence.

## Local Development Environment Setup
To set up your local development environment, follow these steps:
```
git clone git@github.com:ValueMelody/melody-auth.git
cd melody-auth
npm install
npm run build
cd server
cp dev.vars.example dev.vars # Your email functionality related env vars should be put here
npm run dev:secret:generate
npm run dev:migration:apply
npm run dev:start
```



## Additional Configs

Melody Auth offers a range of customizable options to tailor the server to your specific needs. You can modify these settings by adjusting the values in the `[vars]` section of the `server/wrangler.toml` file.
Expand Down
Loading

0 comments on commit bec6865

Please sign in to comment.