Skip to content

fix(Oracle): passwordless authentication issues with Oracle wallet#3370

Open
KiranMohan wants to merge 7 commits into
googleapis:mainfrom
KiranMohan:oracle_wallet_auth_issue
Open

fix(Oracle): passwordless authentication issues with Oracle wallet#3370
KiranMohan wants to merge 7 commits into
googleapis:mainfrom
KiranMohan:oracle_wallet_auth_issue

Conversation

@KiranMohan

@KiranMohan KiranMohan commented Jun 5, 2026

Copy link
Copy Markdown

Description

This PR fixes issues in OracleDB integration - support for passwordless Oracle Wallet / SEPS (Secure External Password Store) connections, resolves a critical TNS_ADMIN environment variable lifecycle issue, and fixes a positional parameter mismatch bug in the prebuilt list_tables query.

Summary of Changes

  1. Passwordless Wallet Support & OCI Driver Improvement (fix(sources/oracle)):
    • TNS_ADMIN Lifecycle Bug: Previously, TNS_ADMIN was temporarily set in the environment and immediately reverted via a defer block when initOracleConnection returned. Because Go's database/sql opens connections lazily, physical connection attempts (e.g. PingContext or queries) executed after the environment variable was unset/reverted, causing connection failure (ORA-12154).
    • Solution: Eliminated thread-unsafe process-wide environment variable manipulation. When useOCI is enabled, the tnsAdmin path is now passed directly to the godror driver in the connection string via the configDir parameter.
    • Validation Update: Updated the validation logic in [oracle.go](file: internal/sources/oracle/oracle.go) to make the user and password fields optional when a wallet configuration (tnsAdmin or walletLocation) is provided.
  2. Positional Parameter Count Mismatch Fix (fix(oracle)):
    • Bug: The prebuilt list_tables query referenced the positional parameter :1 twice, causing the driver to expect 2 arguments. When executing the tool, it failed with sql: expected 2 arguments, got 1.
    • Solution: Refactored the query in [oracledb.yaml](file: internal/prebuiltconfigs/tools/oracledb.yaml) to reference :1 only once using the NVL(:1, t.table_name) pattern.
  3. Prebuilt Configs & Documentation Updates (feat(prebuilt/oracledb)):
    • Exposed all connection properties (tnsAlias, tnsAdmin, walletLocation, user, password, useOCI) to environment variables in [oracledb.yaml] for Passwordless Wallet Support (file: internal/prebuiltconfigs/tools/oracledb.yaml).
    • complete example for configuring passwordless Oracle Wallet authentication (SEPS/External Auth) in [oracle.md](file: docs/en/integrations/oracle/prebuilt-configs/oracle.md).

PR Checklist

Thank you for opening a Pull Request! Before submitting your PR, there are a
few things you can do to make sure it goes smoothly:

  • Make sure you reviewed
    CONTRIBUTING.md
  • Make sure to open an issue as a
    bug/issue
    before writing your code! That way we can discuss the change, evaluate
    designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

🛠️ Fixes # 3389

@KiranMohan KiranMohan requested a review from a team as a code owner June 5, 2026 13:52
@google-cla

google-cla Bot commented Jun 5, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for passwordless Oracle database connections (using Oracle Wallet/SEPS) and TNS configurations by making the database username and password optional under certain conditions, updating the connection string generation, and passing TNS_ADMIN as configDir for the OCI driver. The reviewer pointed out that passwordless authentication is only supported by the OCI-based driver (godror) and not the pure Go driver (go-ora). Consequently, the reviewer recommended restricting the validation logic to only allow passwordless connections when useOCI is enabled with tnsAdmin, and suggested corresponding updates to the tests and documentation.

Comment thread internal/sources/oracle/oracle.go Outdated
Comment thread internal/sources/oracle/oracle_test.go Outdated
Comment thread docs/en/integrations/oracle/source.md Outdated
Comment thread docs/en/integrations/oracle/prebuilt-configs/oracle.md Outdated
…N issue

This commit:
- Relaxes validation to make 'user' and 'password' optional when a wallet (tnsAdmin or walletLocation) is configured.
- Resolves the lazy initialization TNS_ADMIN lookup bug by passing configDir to the godror connection string rather than mutating the global environment variables.
- Updates unit tests to verify passwordless configurations and updates documentation accordingly.
This commit:
- Maps 'tnsAlias' and 'tnsAdmin' to 'ORACLE_TNS_ALIAS' and 'ORACLE_TNS_ADMIN' environment variables in the prebuilt configuration.
- Adds fallback colons to ORACLE_CONNECTION_STRING, ORACLE_USERNAME, and ORACLE_PASSWORD variables.
- Documents the new variables and adds configuration examples for both standard and passwordless wallet usage.
@KiranMohan KiranMohan force-pushed the oracle_wallet_auth_issue branch from a01e141 to f39f3d5 Compare June 5, 2026 13:59
@KiranMohan KiranMohan changed the title Oracle wallet auth issue fix(Oracle): passwordless authentication issues with Oracle wallet Jun 6, 2026
@KiranMohan

Copy link
Copy Markdown
Author

@duwenxin99
this is my first time submitting a fix here. Please let me know if any other changes or input required from me.

@Yuan325 Yuan325 added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Jun 22, 2026
@duwenxin99 duwenxin99 linked an issue Jun 22, 2026 that may be closed by this pull request
2 tasks
@duwenxin99

Copy link
Copy Markdown
Contributor

/gcbrun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p2 Moderately-important priority. Fix may not be included in next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Oracle DB: issues with passwordless authentication + Oracle wallet

3 participants