Skip to content

decentfox/freeauth-api

Repository files navigation

Make authentication and authorization easy and free.

Documentation

Development

Setup environment

Install the EdgeDB CLI (required EdgeDB 3.0+), prep environment, install dependencies, and initial project:

make setup

During the first installation, you will enter an interactive session to initialize the EdgeDB project:

Specify the name of EdgeDB instance to use with this project [default: FreeAuth]: 
> FreeAuth

Note: Instance name must follow the pattern defined by the regular expression: ^[a-zA-Z_0-9]+(-[a-zA-Z_0-9]+)*$.

If you already have a FreeAuth instance in your local environment, you can choose to use the same FreeAuth instance in your project:

Do you want to use existing instance "FreeAuth" for the project? [y/n]
> y

Run FreeAuth admin server in dev mode

make dev

Configuring mail settings

After executing the make setup command, you will have a .env file under freeauth-admin folder.

You could overwrite mail-related settings in the .env file, which includes:

  • MAIL_FROM_NAME: default FreeAuth
  • MAIL_FROM: default None
  • MAIL_USERNAME: default None
  • MAIL_PASSWORD: default None
  • MAIL_PORT: default 25
  • MAIL_SERVER: default localhost
  • MAIL_STARTTLS: default False
  • MAIL_SSL_TLS: default False

Each is explained in https://sabuhish.github.io/fastapi-mail/getting-started/#connectionconfig-class

Configuring SMS settings

We support the following SMS providers:

You could overwrite SMS-related settings in the .env file, which includes:

  • SMS_PROVIDER: default None, the name of the SMS provider, which can be tencent-cloud or aliyun.
  • SMS_SECRET_ID: default None
  • SMS_SECRET_KEY: default None
  • SMS_REGION: default None, for tencent-cloud only, the region where TencentCloud SMS service is located, see available regions.
  • SMS_APP_ID: default None, for tencent-cloud only, the SDKAppID after adding an application in the TencentCloud console.
  • SMS_AUTH_CODE_TPL_ID: default None, the template code for auth code.

Open the EdgeDB UI

edgedb ui

Automatic API documents

DB Migrations

  1. Create a migration:
make db
  1. Apply migrations:
make up

Generate query APIs

make genqlapi

Format and lint the code

Execute the following command to apply formatting:

make lint

Run unit tests

Run all the tests with:

make test

Reset test DB before running tests (if any schema changes):

make testdb