- We don't support authentication on CRM level unfortuantely, we depend on 3rd party oauth services like IYO to do so
- If you're going to implement your own authentication mechanism, then you need a Middleware to do so
- you can Define your own middlewares in
crm.middlewarespackage - By default in production mode we have IYO authentication support using this 2 steps process:
-
we use Caddy Server with IYO to do redirection and authentication for us and put a JWT token in request header
-
We use a Middleware
crm.middlewares.iyoto :- Validate the JWT token, extract user info out of it
- If user not in
userstable, we create a new user, otherwise we update user info - We set session['user'] entry for that user, so later if we found info in session we authorize user directly without hitting the Database
-
- If you want to run the app without
crm.middlewares.iyothen before running the app you may doexport EXCLUDED_MIDDLEWARES=iyo - All session data are invalidated when you restart the CRM app
This done by generating new
app.secret_keysettings for CRM app every time is started
- Put a new middleware in
crm.middlewarespackage - You can get current flask session and request from
flask.sessionandflask.request - write a middleare function decorated by
@app.before_requestand hamdle auth lofic therefrom crm import app from flask import session, request @app.before_request def my_middleware(): pass