A library designed to host common components for a cluster of microservices sharing a single sign on.
- A common exception class, supporting both status code and custom error code to map to more detailed error message or serve as i18n key.
- A common FastAPI app for interaction with service, like login ,registration and unregistration.
- a connector for minio object store.
- a connector for beanie, a mongo odm compatible with pydantic.
pip install awesome-sso
from awesome_sso.service.settings import Settings
settings = Settings()
settings.init_app(
symmetric_key='YOUR_SYMMETRIC_KEY', # to encode and decode service token
public_key='YOUR_PUBLIC_KEY', # to decode the token signed by sso
user_model=USER_MODEL, # user orm needs to inherit AwesomeUser from `awesome_sso.user.schema`
service_name='YOUR_SERVICE_NAME', # for service discovery, to recognize service
sso_domain='YOUR_SSO_DOMAIN', # for service registration and sync user
)
from awesome_sso.service import Service
from fastapi import FastAPI
app = FastAPI()
service = Service()
service.init_app(YOUR_FASTAPI_APP)
app.mount('/YOUR/PATH', YOUR_FASTAPI_APP)
then open the api doc, you will see the apis in awesome_sso.service.user.route
- create your own environment for poetry, and simply run:
pip install poetry
- alternatively, you can refer to poetry's official page
- to be able to use
poe
directly,pip install poethepoet
- project setup:
poetry install
- create your own branch to start developing new feature.
- before creating pr, make sure you pass
poe lint
and./run_test.sh
.- what happened inside
./run_test.sh
is that a minio server is setup for you temporarily, and teardown and unit test is finished. - notice that
poe test
would also work if you already have a minio up and running. You need the following env variable:MINIO_ACCESS_KEY
,MINIO_SECRET_KEY
,MINIO_ADDRESS
upon runningpoe test
.
- what happened inside
- for a list of available poe command,
poe
- after you submit a pr, you should check if pipeline is successful.
poetry version [new_version]
git commit -m"Bump version"
git push origin develop
- create new release on github.
- Create release off develop branch, auto generate notes, and review release note.
- Publish release