Confusion with fief and standalone postgresql deployment #162
-
Nice project -- I am starting to get a sense of things, or at least I was last night locally, but now in production I am confused. I've deployed the docker image and tweaked the environment variables to use my postgresql instance in the cloud. Things seem to be working, kind-of. https://members.opensensor.io/admin First thing I note, there are 5 database tables that get created: There is one workspace and one alembic db record, the rest is empty. Ok, so the first question is why isn't it using my env vars for the Ok no bother, at this point I can register a new account -- but then I am prompted to setup a workspace. This confuses me because it already has a workspace, but I proceed to set one up which creates weird redirect problems, so I check in the DB and there are two records now. I tweak the in various ways, delete one. I get it so I can login -- this is odd. Also should there be more than 5 database tables? I feel like there are settings and things I can configure in Fief that I can't find in the database. Other problems are after I tweak the database records I am unable to register additional users. So now I drop the tables, restart the deployment and it recreates the tables and I start over. I haven't figured out how to get past this part -- I think it was impacting the oauth providers I was trying to setup originally but in further debugging I end up breaking the registration flow by registering my user and adding the workspace, one way or another. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Hail, @matteius 👋 Welcome to Fief's kingdom! Our team will get back to you very soon to help. In the meantime, take a minute to star our repository ⭐️ Farewell! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Regarding the database, an important thing to understand is that there is a "root" one that manages workspaces and one for each workspace. In the case of PostgreSQL, we leverage schemas for this. So it looks like this: flowchart LR
DB[Root]
WS1[Workspace 1]
WS2[Workspace 2]
WSN[Workspace n]
DB --> WS1
DB --> WS2
DB --> WSN
Thus, when you start Fief server, it'll create the schema for the "root" database (in If everything goes well, if you go to When you access In a platform like Fief, authentication must happen within the context of an application. That's why you need to go through the OAuth2 flow when integrating your application. Under the hood, Fief will create a login session, so it knows where to take the user back when the user has authenticated (or registered). The admin dashboard uses this flow correctly, that's why it works when you go first through |
Beta Was this translation helpful? Give feedback.
Regarding the database, an important thing to understand is that there is a "root" one that manages workspaces and one for each workspace. In the case of PostgreSQL, we leverage schemas for this. So it looks like this:
Thus, when you start Fief server, it'll create the schema for the "root" database (in
public
schema) and the "main workspace` database (in a schema named after its workspace ID).If everything goes well, if you go to
/admin/
, you'll be taken to the login page. If you input the credentials set withFIEF_MAIN_USER_EMAIL
andF…