mirror of
https://github.com/simple-login/app.git
synced 2025-02-23 23:34:05 +08:00
re-organize README
This commit is contained in:
parent
95ae2ec254
commit
6d9d017c08
1 changed files with 48 additions and 42 deletions
90
README.md
90
README.md
|
@ -77,6 +77,10 @@ the following section will show a step-by-step guide on how to get your own emai
|
||||||
|
|
||||||
[3. Contributing Guide](#contributing)
|
[3. Contributing Guide](#contributing)
|
||||||
|
|
||||||
|
[4. API](#api)
|
||||||
|
|
||||||
|
[5. OAuth2/OpenID Connect](#oauth)
|
||||||
|
|
||||||
|
|
||||||
## General Architecture
|
## General Architecture
|
||||||
|
|
||||||
|
@ -615,7 +619,49 @@ then open http://localhost:7777, you should be able to login with the following
|
||||||
john@wick.com / password
|
john@wick.com / password
|
||||||
```
|
```
|
||||||
|
|
||||||
### API
|
### Database migration
|
||||||
|
|
||||||
|
The database migration is handled by `alembic`
|
||||||
|
|
||||||
|
Whenever the model changes, a new migration has to be created.
|
||||||
|
|
||||||
|
If you have Docker installed, you can create the migration by the following script:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sh new_migration.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure to review the migration script before committing it.
|
||||||
|
Sometimes (very rarely though), the automatically generated script can be incorrect.
|
||||||
|
|
||||||
|
We cannot use the local database to generate migration script as the local database doesn't use migration.
|
||||||
|
It is created via `db.create_all()` (cf `fake_data()` method). This is convenient for development and
|
||||||
|
unit tests as we don't have to wait for the migration.
|
||||||
|
|
||||||
|
### Code structure
|
||||||
|
|
||||||
|
The repo consists of the three following entry points:
|
||||||
|
|
||||||
|
- wsgi.py and server.py: the webapp.
|
||||||
|
- email_handler.py: the email handler.
|
||||||
|
- cron.py: the cronjob.
|
||||||
|
|
||||||
|
Here are the small sum-ups of the directory structures and their roles:
|
||||||
|
|
||||||
|
- app/: main Flask app. It is structured into different packages representing different features like oauth, api, dashboard, etc.
|
||||||
|
- local_data/: contains files to facilitate the local development. They are replaced during the deployment.
|
||||||
|
- migrations/: generated by flask-migrate. Edit these files will be only edited when you spot (very rare) errors on the database migration files.
|
||||||
|
- static/: files available at `/static` url.
|
||||||
|
- templates/: contains both html and email templates.
|
||||||
|
- tests/: tests. We don't really distinguish unit, functional or integration test. A test is simply here to make sure a feature works correctly.
|
||||||
|
|
||||||
|
The code is formatted using https://github.com/psf/black, to format the code, simply run
|
||||||
|
|
||||||
|
```
|
||||||
|
black .
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
SimpleLogin current API clients are Chrome/Firefox/Safari extension and mobile (iOS/Android) app.
|
SimpleLogin current API clients are Chrome/Firefox/Safari extension and mobile (iOS/Android) app.
|
||||||
These clients rely on `API Code` for authentication.
|
These clients rely on `API Code` for authentication.
|
||||||
|
@ -1144,49 +1190,9 @@ Output:
|
||||||
200 if user is upgraded successfully
|
200 if user is upgraded successfully
|
||||||
4** if any error.
|
4** if any error.
|
||||||
|
|
||||||
### Database migration
|
|
||||||
|
|
||||||
The database migration is handled by `alembic`
|
|
||||||
|
|
||||||
Whenever the model changes, a new migration has to be created.
|
## OAuth
|
||||||
|
|
||||||
If you have Docker installed, you can create the migration by the following script:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sh new_migration.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
Make sure to review the migration script before committing it.
|
|
||||||
Sometimes (very rarely though), the automatically generated script can be incorrect.
|
|
||||||
|
|
||||||
We cannot use the local database to generate migration script as the local database doesn't use migration.
|
|
||||||
It is created via `db.create_all()` (cf `fake_data()` method). This is convenient for development and
|
|
||||||
unit tests as we don't have to wait for the migration.
|
|
||||||
|
|
||||||
### Code structure
|
|
||||||
|
|
||||||
The repo consists of the three following entry points:
|
|
||||||
|
|
||||||
- wsgi.py and server.py: the webapp.
|
|
||||||
- email_handler.py: the email handler.
|
|
||||||
- cron.py: the cronjob.
|
|
||||||
|
|
||||||
Here are the small sum-ups of the directory structures and their roles:
|
|
||||||
|
|
||||||
- app/: main Flask app. It is structured into different packages representing different features like oauth, api, dashboard, etc.
|
|
||||||
- local_data/: contains files to facilitate the local development. They are replaced during the deployment.
|
|
||||||
- migrations/: generated by flask-migrate. Edit these files will be only edited when you spot (very rare) errors on the database migration files.
|
|
||||||
- static/: files available at `/static` url.
|
|
||||||
- templates/: contains both html and email templates.
|
|
||||||
- tests/: tests. We don't really distinguish unit, functional or integration test. A test is simply here to make sure a feature works correctly.
|
|
||||||
|
|
||||||
The code is formatted using https://github.com/psf/black, to format the code, simply run
|
|
||||||
|
|
||||||
```
|
|
||||||
black .
|
|
||||||
```
|
|
||||||
|
|
||||||
### OAuth flow
|
|
||||||
|
|
||||||
SL currently supports code and implicit flow.
|
SL currently supports code and implicit flow.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue