prathmesh 1
08/27/2024, 2:16 PM{"log.level":"info","@timestamp":"2024-08-27T14:12:29.172Z","log.logger":"cerbos.server","message":"maxprocs: Updating GOMAXPROCS=1: using minimum allowed GOMAXPROCS"}
{"log.level":"info","@timestamp":"2024-08-27T14:12:29.173Z","log.logger":"cerbos.server","message":"Loading configuration from /config/config.yaml"}
{"log.level":"info","@timestamp":"2024-08-27T14:12:29.173Z","log.logger":"cerbos.server","message":"maxprocs: Resetting GOMAXPROCS to 2"}
{"log.level":"error","@timestamp":"2024-08-27T14:12:29.173Z","log.logger":"cerbos.server","message":"Failed to load configuration","error":"failed to load config: couldn't decode merged YAML: yaml: line 14: could not find expected ':'"}
cerbos: error: failed to load config: couldn't decode merged YAML: yaml: line 14: could not find expected ':'
Charith (Cerbos)
prathmesh 1
08/28/2024, 11:06 AMapiVersion: v1
kind: ConfigMap
metadata:
name: cerbos-config
data:
config.yaml: |
storage:
driver: "postgres"
postgres:
url: "postgres://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@host:5432/postgres?sslmode=allow&search_path=cerbos"
server:
httpListenAddr: "[::]:3592"
adminAPI:
enabled: true
adminCredentials:
username: ${CERBOS_USERNAME}
passwordHash: ${CERBOS_PASSOWRD_HASH}
oguzhan
could not find expected ':'
error occurs when there is a missing :
after a key such as:
a: a
b: b
c # missing :
Also, how does your k8s deployment look?prathmesh 1
08/28/2024, 11:35 AMusername: ${CERBOS_USERNAME}
passwordHash: ${CERBOS_PASSOWRD_HASH}
above value is added in secrets and fetching values through deployment container env'sprathmesh 1
08/28/2024, 11:46 AMoguzhan
CERBOS_PASSOWRD_HASH
. It should be CERBOS_PASSWORD_HASH
. I think this might not be the actual issue, though. I wanted to point it out just in case.
2. Do you think one of the environment variables could include a whitespace
or a new line character perhaps. Is it possible for you to check what is provided as a value for the CERBOS_PASSWORD_HASH
?prathmesh 1
08/28/2024, 11:54 AMprathmesh 1
08/28/2024, 11:55 AMprathmesh 1
08/28/2024, 11:55 AMoguzhan
CERBOS_PASSOWRD_HASH
to something like this just to be safe:
JDJ5JDEwJGNsLmU3enF5djNaTDRiUXAvOTVhTS5LWmMzWXVXN3FSRlF3UnM5aEVSckZ3ZFhxVEUuTG1hCgo
(this is cerbosAdmin
)prathmesh 1
08/28/2024, 12:03 PMprathmesh 1
08/28/2024, 12:21 PMoguzhan
prathmesh 1
08/28/2024, 12:22 PMecho -n 'JDJ5JDEwJGNsLmU3enF5djNaTDRiUXAvOTVhTS5LWmMzWXVXN3FSRlF3UnM5aEVSckZ3ZFhxVEUuTG1hCgo' | base64 --decode
$2y$10$cl.e7zqyv3ZL4bQp/95aM.KZc3YuW7qRFQwRs9hERrFwdXqTE.Lma
base64: invalid input
oguzhan
JDJ5JDEwJGNsLmU3enF5djNaTDRiUXAvOTVhTS5LWmMzWXVXN3FSRlF3UnM5aEVSckZ3ZFhxVEUuTG1hCgo
should indeed result in
$2y$10$cl.e7zqyv3ZL4bQp/95aM.KZc3YuW7qRFQwRs9hERrFwdXqTE.Lma
as your terminal output suggests.
I don’t know why it says base64: invalid input
.
It works for me:
> echo -n "JDJ5JDEwJGNsLmU3enF5djNaTDRiUXAvOTVhTS5LWmMzWXVXN3FSRlF3UnM5aEVSckZ3ZFhxVEUuTG1hCgo" | base64 -d
$2y$10$cl.e7zqyv3ZL4bQp/95aM.KZc3YuW7qRFQwRs9hERrFwdXqTE.Lma
oguzhan
prathmesh 1
08/28/2024, 1:16 PMecho -n "JDJ5JDEwJGNsLmU3enF5djNaTDRiUXAvOTVhTS5LWmMzWXVXN3FSRlF3UnM5aEVSckZ3ZFhxVEUuTG1hCgo" | base64 -d
$2y$10$cl.e7zqyv3ZL4bQp/95aM.KZc3YuW7qRFQwRs9hERrFwdXqTE.Lma
base64: invalid input
Charith (Cerbos)
base64
requires padded inputs. You can ignore that error. In fact, you don't need to decode base64 at all because Cerbos is expecting a base64-encoded value for the passwordHash
field. You can just create your secret with something like kubectl create secret generic cerbos-admin-credentials --from-literal=CERBOS_PASSWORD_HASH=JDJ5JDEwJGNsLmU3enF5djNaTDRiUXAvOTVhTS5LWmMzWXVXN3FSRlF3UnM5aEVSckZ3ZFhxVEUuTG1hCgo
.prathmesh 1
08/28/2024, 1:29 PMk apply -f secret.yaml -n prod-cerbos-namespace
The request is invalid: patch: Invalid value: "map[data:map[passwordHash:JDJ5JDEwJGNsLmU3enF5djNaTDRiUXAvOTVhTS5LWmMzWXVXN3FSRlF3UnM5aEVSckZ3ZFhxVEUuTG1hCgo username:cHJvZGNlcmJvc2NhcnMyNEFkbWlu] metadata:map[annotations:map[kubectl.kubernetes.io/last-applied-configuration:{\"apiVersion\":\"v1\",\"data\":{\"passwordHash\":\"JDJ5JDEwJGNsLmU3enF5djNaTDRiUXAvOTVhTS5LWmMzWXVXN3FSRlF3UnM5aEVSckZ3ZFhxVEUuTG1hCgo\",\"postgresPassword\":\"RXB6dmJXUWhXZAo=\",\"postgresUser\":\"cHJvZGZXIK\",\"username\":\"cHJvZGNlcmJvc2NhcnMyNEFkbWlu\"},\"kind\":\"Secret\",\"metadata\":{\"annotations\":{},\"name\":\"cerbos-secret\",\"namespace\":\"prod-cerbos-namespace\"},\"type\":\"Opaque\"}\n]]]": error decoding from json: illegal base64 data at input byte 80
Charith (Cerbos)
stringData
or data
?prathmesh 1
08/28/2024, 1:34 PMCharith (Cerbos)
stringData
prathmesh 1
08/28/2024, 1:53 PMstringData
is working.
Some other issue are there I will check.