Did you know that GitHub supports table of contents by default 🤔
Guard is a backend service that adds users to Google Spreadsheets only after they authenticate via InNoHassle Accounts. It ensures that only verified Innopolis University community members can access shared spreadsheets.
Guard API is a FastAPI-based service that:
- Gates access to Google Spreadsheets - users must authenticate via InNoHassle Accounts to be added
- Provides automated spreadsheet setup with role-based access control (writer/reader)
- Generates secure join links for spreadsheet access
- Uses Google Service Accounts to manage spreadsheet permissions
- Offers admin interface for configuring spreadsheet integrations
How it works:
- Admin sets up a spreadsheet through Guard and selects a role (writer/reader)
- Admin shares a join link with users
- Users authenticate via InNoHassle Accounts
- Guard adds authenticated users to the spreadsheet with the configured role
- Python 3.14 & uv
- FastAPI
- Google Sheets API - Spreadsheet integration
- Google Drive API - File permissions management
- InNoHassle Accounts SDK - Authentication
- Formatting and linting: Ruff, pre-commit
- Deployment: Docker, Docker Compose, GitHub Actions
For Admins:
- Visit the setup interface at
/google - Add the Guard service account to your Google Spreadsheet as an editor
- Setup the spreadsheet in Guard and choose a role (writer/reader) for users
- Share the generated join link with your users
For Users:
- Receive a join link from the admin
- Click the link and authenticate via InNoHassle Accounts
- Enter your Gmail address
- Guard automatically adds you to the spreadsheet with the configured permissions
This ensures only authenticated Innopolis University community members can access the spreadsheet.
- Install uv and Docker
- Install dependencies:
uv sync
- Copy settings.example.yaml to settings.yaml and configure:
cp settings.example.yaml settings.yaml
- Place your Google Service Account JSON file in the project root (default name:
inh-plugin.json) - Start development server:
uv run -m src.api --reload
Follow the provided instructions (if needed).
- Open in the browser: http://localhost:8013
The api will be reloaded when you edit the code
Important
For endpoints requiring authorization click "Authorize" button in Swagger UI
Tip
Edit settings.yaml according to your needs, you can view schema in
config_schema.py and in settings.schema.yaml
Set up PyCharm integrations
- Run configurations (docs).
Right-click the
__main__.pyfile in the project explorer, selectRun '__main__'from the context menu. - Ruff (plugin).
It will lint and format your code. Make sure to enable
Use ruff formatoption in plugin settings. - Pydantic (plugin). It will fix PyCharm issues with type-hinting.
- Conventional commits (plugin). It will help you to write conventional commits.
We use Docker with Docker Compose plugin to run the service on servers.
- Copy the file with environment variables:
cp .example.env .env - Change environment variables in the
.envfile - Copy the file with settings:
cp settings.example.yaml settings.yaml - Change settings in the
settings.yamlfile according to your needs (check settings.schema.yaml for more info) - Place your Google Service Account JSON file in the project root (default name:
inh-plugin.json) - Install Docker with Docker Compose
- Run the containers:
docker compose up --build --wait - Check the logs:
docker compose logs -f
Check https://github.com/one-zero-eight/fastapi-template for updates once in a while.
- Run
uv sync --upgradeto update uv.lock file and install the latest versions of the dependencies. - Run
uv tree --outdated --depth=1will show what package versions are installed and what are the latest versions. - Run
uv run pre-commit autoupdate
Also, Dependabot will help you to keep your dependencies up-to-date, see dependabot.yaml. {% if cookiecutter.database == "mongo" %}
- Dump:
docker compose exec db sh -c 'mongodump "mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@127.0.0.1:27017/db?authSource=admin" --db=db --out=dump/'
- Restore:
docker compose exec db sh -c 'mongorestore "mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@127.0.0.1:27017/db?authSource=admin" --drop /dump/db'
{% endif %}
We are open to contributions of any kind. You can help us with code, bugs, design, documentation, media, new ideas, etc. If you are interested in contributing, please read our contribution guide.