BAID's backbone: A unified OAuth2 server for BAID's Seiue LMS and Feishu logins.
Used by WebArtistryBAID/helium, WebArtistryBAID/whale, WebArtistryBAID/baid-speaker, and other third-party services.
Overview · Development · Production · Environment Variables · Contribution · License
- At BAID, students use Seiue LMS to authorize to school services, and faculty uses Feishu. This custom OAuth2 server is designed to integrate BAID's Seiue LMS and Feishu logins into a single system, so that individual services do not have to integrate both systems.
- As a developer, you can press Ctrl+D on the LinkBAID homepage after logging in to create an OAuth2 application. After setting up the redirect URIs, terms of service/privacy policy pages, homepage URI, description, and scopes, you can start accepting authorizations from users.
- As a user, you can log in to any service that uses LinkBAID with your school credentials easily. You can also manage your authorizations in the home page.
- Applications can be restricted so that only specific users can authorize.
To run in development:
-
Install Node.js and npm.
-
Copy
.env.exampleto.env. -
Run
npm install. -
Set up a PostgreSQL database and set
DATABASE_URLin.env. -
Set
HOSTED=http://localhost:3000,UPLOAD_ROOT=public/uploads, andUPLOAD_SERVE_PATH=uploads. -
Apply Prisma migrations and generate the client:
prisma migrate deploy prisma generate
-
Fill the remaining environment variables.
-
Run
npm run devto start the development server.
- After pulling migrations, run
prisma migrate deploy, thenprisma generate. - To create your own migration, edit
prisma/schema.prismaand runprisma migrate dev --name describe_change. Commit the schema and the entireprisma/migrations/directory together. - On production, run
prisma migrate deploy, thenprisma generatebefore building and restarting Project Whale. Monitor the messages carefully, do NOT reset the database!
To run in production:
- Install Node.js and npm.
- Copy
.env.exampleto.env. - Run
npm install. - Set up a PostgreSQL database and set
DATABASE_URLin.env. - For a fresh database, run
prisma migrate deploy. - Run
prisma generate. - Fill the remaining environmental variables.
- Run
npm run buildto build the production server. - Using
pm2, runpm2 start npm --name linkbaid -- run startto start the production server. You can also usepm2 saveto save the process list andpm2 startupto configure it to start on boot. - LinkBAID runs on port 52321 by default.
- Create a reverse proxy with Nginx as appropriate such that Nginx handles HTTPS and serves static files. An example Nginx configuration is shown below. HTTPS can usually be configured with Let's Encrypt.
server {
listen 443 ssl;
server_name link.example.com;
ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to/privkey.pem;
client_max_body_size 11M;
location ^~ /uploads/ {
alias /home/web/linkbaid/uploads/; # By setting up Nginx to serve files from /uploads/, we must set `UPLOAD_SERVE_PATH` to `/uploads` (users access uploaded files on `https://.../uploads/...`) and `UPLOAD_PATH` to `uploads` (uploaded files are saved to `/home/web/whale/uploads/`)
autoindex off;
add_header X-Content-Type-Options nosniff always;
try_files $uri =404;
}
location / {
proxy_pass http://localhost:52321;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}| Name | Description |
|---|---|
DATABASE_URL |
The database URL to use. |
JWT_SECRET |
The JWT secret key to use. You can generate one with openssl rand -hex 32. |
SEIUE_CLIENT_ID |
The client ID received from Seiue LMS for authentication. |
FEISHU_APP_ID |
The app ID received from Feishu for authentication. |
FEISHU_APP_SECRET |
The app secret received from Feishu for authentication. |
HOSTED |
The location where OneLogin is hosted. No trailing slashes. |
UPLOAD_ROOT |
The directory where uploaded files are stored. In development, this is public/uploads. |
UPLOAD_SERVE_PATH |
The path where uploaded files are served. In development, this is uploads. |
BOTTOM_TEXT |
In case you need this. |
To contribute, simply open a pull request.
LinkBAID is a unified OAuth2 server for BAID's Seiue LMS and Feishu.
Copyright (C) 2026 Team WebArtistry
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.