Authentication and permissions
pgredis enforces permissions inside the pg_redis C dispatcher on every command. Even if a client bypasses the Go gateway and calls redis.command(...) directly over SQL, the C extension verifies the active PostgreSQL role capabilities or Redis ACL session before touching redis._keyspace or any typed value table.
Authentication modes
The gateway -auth-mode flag selects how Redis clients authenticate:
| Mode | Flag | Client AUTH syntax | Identity enforced by pg_redis |
|---|---|---|---|
| PostgreSQL role mode | -auth-mode native (default) | AUTH <pg_role> <password> or AUTH <password> (uses -default-user) | PostgreSQL login role and SQL EXECUTE grants on capability functions |
| Redis ACL mode | -auth-mode redis-acl | AUTH <acl_user> <password> or AUTH <password> (for default) | Redis ACL user row in redis._acl_user accessed via a bound PostgreSQL service role |
Before authentication succeeds on a connection that requires AUTH, the gateway restricts incoming command headers to at most 10 arguments and 16,384 bytes per bulk argument so unauthenticated callers cannot allocate large buffers.
PostgreSQL role permissions
In native mode, CREATE EXTENSION pg_redis revokes public access from all internal redis._* tables and functions. Database administrators grant access by granting USAGE ON SCHEMA redis, EXECUTE on entry functions, and EXECUTE on three empty capability marker functions checked by the C dispatcher:
redis._read()— required for read-only commands (GET,HGETALL,LRANGE,XRANGE,SUBSCRIBE,WAIT)redis._write()— required for data-modifying commands (SET,DEL,LPUSH,XADD,PUBLISH,EXECwith writes)redis._admin()— required for administrative commands (FLUSHDB,FLUSHALL,CONFIG,SLOWLOG,ACL,DEBUG,MONITOR,MIGRATE)
For a read-only role, omit redis._write() from the GRANT EXECUTE list. For an operational administrator role, add redis._admin().
Redis ACL mode
When -auth-mode redis-acl is enabled, the gateway connects to PostgreSQL using a single dedicated service role, and client sessions authenticate against rules stored in redis._acl_user.
Create and bind the PostgreSQL service role
Create a login role with read, write, and admin dispatch grants, then bind its
regroleidentity inredis._acl_serviceas an extension administrator:Once bound in
redis._acl_service,redis_servicecannot execute commands without an activeredis._acl_sessiontoken.Configure ACL users and passwords
Manage users over SQL or from an admin Redis connection:
Supported
ACLsubcommands includeSETUSER,DELUSER,GETUSER,LIST,USERS,WHOAMI,CAT,GENPASS,DRYRUN,LOG,LOAD, andSAVE(LOADandSAVEreport that no externalaclfileis configured because ACLs persist in PostgreSQL WAL).Start the gateway in
redis-aclmodeDo not place credentials in
-pg; pass-acl-service-userand-acl-service-password-file(orPGREDIS_ACL_SERVICE_PASSWORD):
CONFIG SET requirepass updates the password of the default ACL user in redis._acl_config (never a PostgreSQL LOGIN role). CONFIG SET acl-pubsub-default controls the default Pub/Sub channel policy (resetchannels by default, or allchannels) for newly created ACL users and RESET. redis._acl_user, redis._acl_config, and redis._acl_service are registered with pg_extension_config_dump, so pg_dump and pg_restore preserve ACL users and service role bindings across clusters.
Transport and tenant isolation
- Remote TLS enforcement: Listening on any non-loopback address (
0.0.0.0,::, or a LAN IP) requires-tls-certand-tls-key(minimum TLS 1.2). Starting without TLS on a non-loopback address fails immediately. - Database link security: Never embed a password in the
-pgendpoint URL. When PostgreSQL runs on a separate host, configuresslmode=verify-fullin the-pgconnection string. - Tenant isolation: All 16 logical Redis databases (
SELECT 0throughSELECT 15) share the sameredis._keyspacetable, Pub/Sub event queue, andMONITORring within one PostgreSQL database. Isolate untrusted tenants in separate PostgreSQL databases with separatepgredisgateway instances.
