In some cases, the authentication username is different from the PostgreSQL username. For instance, this can happen when using an external system for authentication, such as certificate authentication, as described in the previous recipe, or any other external or single sign-on system authentication method from http://www.postgresql.org/docs/current/static/auth-methods.html (GSSAPI, SSPI, Kerberos, Radius, or PAM). Or you may just need to enable an externally authenticated user to connect as multiple database users.
In such cases, you can specify rules to map the external username to the appropriate database role.