Skip to content

Commit 5b440f1

Browse files
committed
Network improvements
1 parent 579e952 commit 5b440f1

File tree

5 files changed

+126
-16
lines changed

5 files changed

+126
-16
lines changed

doc/src/api_manual/oracledb.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -966,9 +966,10 @@ Each of the configuration properties is described below.
966966
authentication. See :ref:`External Authentication <extauth>` for more
967967
information.
968968

969-
In node-oracledb Thin mode, when token-based authentication is required,
970-
this property must be set to *true*. In all the other cases where this
971-
property is set to *true*, an error is thrown.
969+
In node-oracledb Thin mode, when token-based authentication or
970+
:ref:`external authentication using TLS <tlsextauth>` is required, this
971+
property must be set to *true*. In all the other cases where this property
972+
is set to *true*, an error is thrown.
972973

973974
The default value is *false*.
974975

@@ -2120,7 +2121,7 @@ Oracledb Methods
21202121

21212122
The default is *false*.
21222123

2123-
In Thin mode, when token-based authentication is required, this property must be set to *true*. In all the other cases where this property is set to *true*, an error is thrown.
2124+
In Thin mode, when token-based authentication or :ref:`external authentication using TLS <tlsextauth>` is required, this property must be set to *true*. In all the other cases where this property is set to *true*, an error is thrown.
21242125

21252126
This optional property overrides the :attr:`oracledb.externalAuth` property.
21262127

@@ -2897,7 +2898,7 @@ Oracledb Methods
28972898

28982899
If this optional property is set to *true* in Thick mode, then the connection will be established using :ref:`External Authentication <extauth>`.
28992900

2900-
In Thin mode, when token-based authentication is required, this property must be set to *true*. In all the other cases where this property is set to *true*, an error is thrown.
2901+
In Thin mode, when token-based authentication or :ref:`external authentication using TLS <tlsextauth>` is required, this property must be set to *true*. In all the other cases where this property is set to *true*, an error is thrown.
29012902

29022903
This optional property overrides the :attr:`oracledb.externalAuth` property.
29032904

doc/src/user_guide/connection_handling.rst

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,17 +1981,28 @@ Connecting Using External Authentication
19811981
External Authentication allows applications to use an external password
19821982
store (such as an `Oracle Wallet <https://www.oracle.com/pls/topic/lookup?
19831983
ctx=dblatest&id=GUID-E3E16C82-E174-4814-98D5-EADF1BCB3C37>`__),
1984-
the `Secure Socket Layer <https://www.oracle.com/pls/topic/lookup?ctx=
1985-
dblatest&id=GUID-6AD89576-526F-4D6B-A539-ADF4B840819F>`__
1986-
(SSL), or the `operating system <https://www.oracle.com/pls/topic/lookup
1987-
?ctx=dblatest&id=GUID-37BECE32-58D5-43BF-A098-97936D66968F>`__
1988-
to validate user access. One of the benefits is that database
1989-
credentials do not need to be hard coded in the application.
1984+
the `Transport Layer Security (TLS) or Secure Socket Layer (SSL)
1985+
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-6AD89576-526F-
1986+
4D6B-A539-ADF4B840819F>`__, or the `operating system <https://www.oracle.com/
1987+
pls/topic/lookup?ctx=dblatest&id=GUID-37BECE32-58D5-43BF-A098-97936D66968F>`__
1988+
to validate user access. With an external password store, your application can
1989+
use an Oracle Wallet to authenticate users. External Authentication using TLS
1990+
authenticates users with Public Key Infrastructure (PKI) certificates. With
1991+
operating system authentication, user authentication can be performed if the
1992+
user has an operating system account on their machine recognized by Oracle
1993+
Database. One of the benefits of using external authentication is that
1994+
database credentials do not need to be hard coded in the application.
19901995
19911996
.. note::
19921997
1993-
Connecting to Oracle Database using external authentication is only
1994-
supported in node-oracledb Thick mode. See :ref:`enablingthick`.
1998+
Connecting to Oracle Database using external authentication with an Oracle
1999+
Wallet, TLS, or the operating system is supported in node-oracledb Thick
2000+
mode. See :ref:`enablingthick`.
2001+
2002+
Node-oracledb Thin mode only supports external authentication with TLS.
2003+
See :ref:`tlsextauth` for more information.
2004+
2005+
**In node-oracledb Thick Mode**
19952006
19962007
To use external authentication, set the :attr:`oracledb.externalAuth` property
19972008
to *true*. This property can also be set in the ``connAttrs`` or ``poolAttrs``
@@ -2073,6 +2084,67 @@ connections exceeds ``poolMin`` and connections are idle for more than
20732084
the :attr:`oracledb.poolTimeout` seconds, then the number of
20742085
open connections does not fall below ``poolMin``.
20752086
2087+
.. _tlsextauth:
2088+
2089+
External Authentication Using TLS
2090+
---------------------------------
2091+
2092+
External authentication with Transport Layer Security (TLS) uses `Public Key
2093+
Infrastructure (PKI) certificates <https://www.oracle.com/pls/topic/lookup?ctx
2094+
=dblatest&id=GUID-6AD89576-526F-4D6B-A539-ADF4B840819F>`__ to authenticate
2095+
users. This authentication method can be used in both node-oracledb Thin and
2096+
Thick modes.
2097+
2098+
To use TLS external authentication, you must set the
2099+
:attr:`oracledb.externalAuth` property to *true*. This property can also be
2100+
set in the ``externalAuth`` parameter of the :meth:`oracledb.getConnection()`
2101+
or :meth:`oracledb.createPool()` calls. TLS external authentication can only
2102+
be done for connections that are configured to use the *TCPS* protocol.
2103+
2104+
For a standalone connection, you can use TLS authentication to authenticate
2105+
the user as shown in the example below:
2106+
2107+
.. code-block:: javascript
2108+
2109+
const config = { connectString: "tcps://localhost/orclpdb1", externalAuth: true };
2110+
const connection = await oracledb.getConnection(config);
2111+
2112+
Note that TLS external authentication will not be enabled if you are using
2113+
token-based authentication (that is, the ``accessToken`` property is set in
2114+
:meth:`oracledb.getConnection()` or :meth:`oracledb.createPool()`).
2115+
2116+
For a connection pool, you can authenticate with TLS as shown in the example
2117+
below:
2118+
2119+
.. code-block:: javascript
2120+
2121+
const config = { connectString: "tcps://localhost/orclpdb1", externalAuth: true };
2122+
const pool = await oracledb.createPool(config);
2123+
const connection = await pool.getConnection();
2124+
2125+
. . . // connection has access to the schema objects of the externally identified user
2126+
2127+
await connection.close();
2128+
2129+
In node-oracledb Thick mode, ensure that the `SQLNET.AUTHENTICATION_SERVICES
2130+
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-FFDBCCFD-87EF
2131+
-43B8-84DA-113720FCC095>`__ parameter contains *TCPS* as a value in the
2132+
:ref:`sqlnet.ora <tnsadmin>` file. Note that *TCPS* is the default value of
2133+
this parameter.
2134+
2135+
Additional server side configuration is also required to enable external
2136+
authentication using TLS:
2137+
2138+
1. Create a user corresponding to the distinguished name (DN) in the
2139+
certificate using:
2140+
2141+
.. code-block:: sql
2142+
2143+
CREATE USER user_name IDENTIFIED EXTERNALLY AS 'user DN on certificate';
2144+
2145+
2. Set the ``SSL_CLIENT_AUTHENTICATION`` parameter to *TRUE* in the server-side
2146+
:ref:`sqlnet.ora <tnsadmin>` file.
2147+
20762148
.. _tokenbasedauthentication:
20772149
20782150
Token-Based Authentication

doc/src/user_guide/troubleshooting.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,40 @@ NJS-116
170170
If your username uses the 10G password verifier, then you need to upgrade your password verifier in Oracle Database to 11G or later to use node-oracledb Thin mode. To upgrade your password verifier, see `Finding and Resetting User Passwords That Use the 10G Password Verifier <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-D7B09DFE-F55D-449A-8F8A-174D89936304>`__ for the detailed steps.
171171

172172
- Or :ref:`enable Thick mode <enablingthick>` since node-oracledb Thick mode supports password verifiers 10G and later.
173+
174+
.. _oraerr:
175+
176+
ORA Error Messages
177+
------------------
178+
179+
The error messages with the prefix ``ORA`` are generated by Oracle Database.
180+
181+
.. _ora0107:
182+
183+
ORA-0107
184+
++++++++
185+
186+
.. list-table-with-summary::
187+
:stub-columns: 1
188+
:class: wy-table-responsive
189+
:widths: 5 35
190+
:summary: The first row displays the ORA-0107 error message. The second row displays the probable cause for the ORA-0107 error. The third row displays the possible solution to resolve the ORA-0107 error.
191+
192+
* - Message
193+
- ``ORA-01017: invalid credential or not authorized; logon denied``
194+
* - Cause
195+
- An invalid credential was provided when accessing the Oracle Database or you were not authorized to access this database.
196+
* - Action
197+
- If external authentication is set to *true*, then verify the following:
198+
199+
- If :ref:`TLS Authentication <tlsextauth>` is enabled, then ensure that:
200+
201+
- A user has been created in Oracle Database corresponding to the distinguished name (DN) in the user certificate using::
202+
203+
CREATE USER user_name IDENTIFIED EXTERNALLY AS 'user DN on certificate';
204+
205+
- The parameter ``SSL_CLIENT_AUTHENTICATION`` is set to *TRUE* in the server-side :ref:`sqlnet.ora <tnsadmin>` file.
206+
207+
- If you are using :ref:`token-based authentication <tokenbasedauthentication>`, then ensure that you have provided a valid user access token.
208+
209+
Note that storing password credentials in an Oracle wallet is not supported in node-oracledb Thin mode.

lib/thin/sqlnet/networkSession.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ class NetworkSession {
301301
this.connected = true;
302302
this.cData = null;
303303
this.sndDatapkt = new Packet.DataPacket(this.sAtts.largeSDU);
304-
this.sndDatapkt.offset = this.sndDatapkt.dataPtr;
305-
this.sndDatapkt.len = this.sndDatapkt.bufLen;
306304
this.markerPkt = new Packet.MarkerPacket(this.sAtts.largeSDU);
307305
this.controlPkt = new Packet.ControlPacket();
308306
this.ntAdapter.largeSDU = this.sAtts.largeSDU;
@@ -319,6 +317,8 @@ class NetworkSession {
319317
}
320318

321319
this.sndDatapkt.createPacket(constants.NSPDADAT); //Currently only used for disconnect
320+
this.sndDatapkt.offset = this.sndDatapkt.dataPtr;
321+
this.sndDatapkt.len = this.sndDatapkt.bufLen;
322322
return (true);
323323
}
324324

lib/thin/sqlnet/sessionAtts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class SessionAtts {
8383
this.networkCompressionLevels.push('high');
8484
}
8585
}
86-
if (params.networkCompressionThreshold > 200) {
86+
if (params.networkCompressionThreshold >= 200) {
8787
this.networkCompressionThreshold = parseInt(params.networkCompressionThreshold);
8888
} else
8989
this.networkCompressionThreshold = 1024;

0 commit comments

Comments
 (0)