Custom oauth validator options
| От | Zsolt Parragi |
|---|---|
| Тема | Custom oauth validator options |
| Дата | |
| Msg-id | CAN4CZFM3b8u5uNNNsY6XCya257u+Dofms3su9f11iMCxvCacag@mail.gmail.com обсуждение исходный текст |
| Список | pgsql-hackers |
Hello hackers, The current OAuth code allows validators to add custom validation logic, but does not allow them to introduce custom authentication-related parameters in the place where they belong: pg_hba.conf. As a workaround, both pg_oidc_validator and postgres-keycloak-oauth-validator (and likely others; these are simply the two I know of) rely on GUC variables instead. I see two issues with this: 1. Configuration for OAuth validation ends up split across two locations: issuer/scope and a few other parameters are defined in pg_hba.conf, while custom parameters must be set in postgresql.conf. 2. We have received multiple questions asking how to configure multiple OIDC servers with different parameter sets. I am not sure how common it is to use multiple OAuth providers with a single PostgreSQL instance, but the question is certainly reasonable. Given this, I would like to ask what you think about making pg_hba.conf extensible. At present, option parsing is hardcoded in parse_hba_auth_opt, and any unknown parameter triggers an error at the end of the function. I can see a few possible approaches: a. Add an OAuth-specific hook that allows injecting additional option-parsing logic into this function, as part of the existing OAuthValidatorCallbacks. This could be scoped to the validator used on the specific HBA line, even if multiple validators are loaded. b. Allow the existing startup callback to supply a list of additional valid configuration names, with the validation callback responsible for parsing and validating them. c. Add a more generic hook usable by any extension. I do not currently have concrete use cases outside OAuth, but perhaps others do. I would be interested in your thoughts on whether an improvement in this area would be useful. I also have two related questions, which might be addressed as part of the above or independently: 1. HBA options are parsed sequentially. If validator-specific options are tied to a particular validator, this implies that validator=... must appear before its parameters when multiple validators are loaded, since we cannot otherwise determine which validator is used. Is this acceptable behavior, or should options be allowed in any order? 2. If a validator introduces many options, an HBA line could become very long and hard to read. Would it make sense to allow loading the parameters for a given line from a separate file? This might already be useful today: for example, if a long issuer URL is repeated across several HBA lines, it could instead be defined once in an external file and referenced multiple times.
В списке pgsql-hackers по дате отправления: