https://cerbos.dev logo
#help
Title
# help
p

Paul Werner

05/05/2023, 7:06 AM
using mysql socket failes within google cloud run. 1: is this dsn allowed? / are socket connections are supported by cerbos "${DATABASE_USER}:${DATABASE_PASSWORD}@tcp(localhost:3307)/${DATABASE_NAME}?socket=${DATABASE_SOCKET}" 2: i had to escape the socket-path as %2Fcloudsql%2F<sql-connection-name> instead of /cloudsql/<sql-connection-name> Is this the right escape-method? what should be used here? i also tried $2F and //
c

Charith (Cerbos)

05/05/2023, 7:49 AM
Yeah, it's a URL so special characters like
/
have to be percent encoded
p

Paul Werner

05/05/2023, 7:51 AM
instead of the app-engine custom cloud sql port 3307 the default port 3306 is used. i changes that, but still get: cerbos: error: failed to create store: failed to connect to database: dial tcp 127.0.0.13306 connect: connection refused
current dsn is: ${DATABASE_USER}:${DATABASE_PASSWORD}@tcp(localhost:3306)/${DATABASE_NAME}?socket=%2Fcloudsql%2Fprojectregioninstance
c

Charith (Cerbos)

05/05/2023, 7:55 AM
According to https://cloud.google.com/sql/docs/mysql/connect-run#go, the URL to connect with a socket is:
${DATABASE_USER}:${DATABASE_PASSWORD}@unix(${DATABASE_SOCKET})/${DATABASE_NAME}
p

Paul Werner

05/05/2023, 7:57 AM
that worked, ver much thank you
may create a section within the documentation for that? I guess for google cloud users this could be a huge benefit 🙂
c

Charith (Cerbos)

05/05/2023, 8:03 AM
Will add an example of connecting with a Unix socket 🙂
p

Paul Werner

05/05/2023, 8:15 AM
do i have to create the database definition myself? the database is after use still empty and I get the following error while quering the admin api: could not get policy ids
c

Charith (Cerbos)

05/05/2023, 8:17 AM
Yes, you have to create the schema yourself. Otherwise Cerbos would have to run with admin privileges, which is not good for security.
p

Paul Werner

05/05/2023, 8:19 AM
maybe a console hint => the schema does not exists => create it manualy, which link to the docs could help here for future setups 🙂 hope noone feels bothered by my suggestions😅
but I guess, you may reconsidder this aproach for future updates it could be necessary to rely on database-migrations f.ex. by prisma or an other library to implement changes in feature versions
c

Charith (Cerbos)

05/05/2023, 8:28 AM
The documentation does say that you have to create the schema manually 🙂 We do have an open task to detect and warn about the schema not being there.
p

Paul Werner

05/05/2023, 8:29 AM
perfect. thank you for your time
8 Views