|
| 1 | +# Gemini Code Assistant Context |
| 2 | + |
| 3 | +This document provides context for the Gemini code assistant to understand the `oauth2id` project. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +`oauth2id` is a single sign-on (SSO) portal based on the OAuth 2.0 and OpenID Connect (OIDC) protocols. It is a Ruby on Rails application that also supports SAML 2.0. The application serves as a central identity provider. |
| 8 | + |
| 9 | +The frontend uses JavaScript with the Stimulus framework and is managed by Webpacker. The UI is based on the `vali-admin` theme (Bootstrap 4). The project uses `pnpm` as its JavaScript package manager. |
| 10 | + |
| 11 | +The backend is a Ruby on Rails 7.2 application. Key technologies include: |
| 12 | +- **Web Server:** Puma |
| 13 | +- **Authentication:** Devise and `devise-jwt` |
| 14 | +- **Authorization:** Pundit |
| 15 | +- **OAuth2/OIDC:** Doorkeeper and `doorkeeper-openid_connect` |
| 16 | +- **SAML:** `saml_idp` |
| 17 | +- **Database:** The default setup uses SQLite3 for development, but the project is configured to support MySQL and PostgreSQL. |
| 18 | +- **Deployment:** Capistrano is used for deployment. |
| 19 | + |
| 20 | +## Building and Running |
| 21 | + |
| 22 | +The project can be run locally for development or as a Docker container. |
| 23 | + |
| 24 | +### Running with Docker |
| 25 | + |
| 26 | +1. **Build the image:** |
| 27 | + ```bash |
| 28 | + docker build --tag ericguo/oauth2id:main . |
| 29 | + ``` |
| 30 | +2. **Run the container:** |
| 31 | + ```bash |
| 32 | + docker run -p 3000:3000 -d --restart always --name oauth2id --env RAILS_MASTER_KEY=<YourMasterKey> -v ./storage:/rails/storage ericguo/oauth2id:main |
| 33 | + ``` |
| 34 | + (Replace `<YourMasterKey>` with the actual Rails master key). |
| 35 | + |
| 36 | +### Running Locally (Development) |
| 37 | + |
| 38 | +1. **Install dependencies:** |
| 39 | + ```bash |
| 40 | + # Install Ruby gems |
| 41 | + bundle install |
| 42 | +
|
| 43 | + # Install Node.js packages |
| 44 | + pnpm install |
| 45 | + ``` |
| 46 | + |
| 47 | +2. **Setup database:** |
| 48 | + ```bash |
| 49 | + # Copy database configuration |
| 50 | + cp config/database.yml.sample config/database.yml |
| 51 | +
|
| 52 | + # Create and migrate the database |
| 53 | + bin/rails db:create |
| 54 | + bin/rails db:migrate |
| 55 | + ``` |
| 56 | + |
| 57 | +3. **Setup credentials:** |
| 58 | + ```bash |
| 59 | + # Create the credentials file if it doesn't exist |
| 60 | + bin/rails credentials:edit |
| 61 | + ``` |
| 62 | + |
| 63 | +4. **Run the development servers:** |
| 64 | + The `Procfile.dev` defines the processes to run. Use a tool like `foreman` or run them in separate terminals. |
| 65 | + ```bash |
| 66 | + # Run Rails server |
| 67 | + bin/rails s -p 3000 |
| 68 | +
|
| 69 | + # Run Webpack dev server |
| 70 | + bin/webpack-dev-server |
| 71 | + ``` |
| 72 | + The `README.md` also contains instructions for setting up `puma-dev` for local HTTPS development. |
| 73 | + |
| 74 | +## Testing |
| 75 | + |
| 76 | +The test suite is run using Minitest. |
| 77 | + |
| 78 | +1. **Setup the test environment:** |
| 79 | + ```bash |
| 80 | + # Install dependencies (if not already done) |
| 81 | + bundle install |
| 82 | + pnpm install |
| 83 | +
|
| 84 | + # Copy database configuration |
| 85 | + cp config/database.yml.sample config/database.yml |
| 86 | +
|
| 87 | + # Migrate the test database |
| 88 | + bin/rails db:migrate RAILS_ENV=test |
| 89 | + ``` |
| 90 | + |
| 91 | +2. **Run the tests:** |
| 92 | + The CI configuration uses `bin/rails test:all`. |
| 93 | + ```bash |
| 94 | + bin/rails test:all |
| 95 | + ``` |
| 96 | + |
| 97 | +## Development Conventions |
| 98 | + |
| 99 | +* **Linting:** |
| 100 | + * Ruby code is linted with RuboCop (see `.rubocop.yml`). |
| 101 | + * JavaScript code is linted with ESLint (see `.eslintrc.js`). |
| 102 | +* **CI/CD:** The project uses GitLab CI (see `.gitlab-ci.yml`) for running tests and deploying to staging. |
| 103 | +* **Package Management:** Ruby gems are managed with Bundler. JavaScript packages are managed with `pnpm`. |
0 commit comments