Users, Authentication, and Authorization
Oracle AI Database security differs significantly from that of MongoDB. The security model of Oracle Database API for MongoDB is described: the creation of users, their authentication, and their authorization to perform different operations.
By default, MongoDB does not enable user authentication and authorization checks. Oracle AI Database always requires authentication, and it always verifies that a connected user is authorized to perform a requested operation. A valid username and password must be provided for authentication.
Oracle Database API for MongoDB supports only the following connection-option values for authentication:
-
PLAINvalue (plain-text authentication) for optionauthMechanism. In particular, theSCRAM-SHA-*authentication methods are not supported. -
$externalvalue for optionauthSource. (This is anyway required for MongoDB whenever the authentication method isPLAIN.)
Oracle Database API for MongoDB relies on Oracle AI Database users, privileges, and roles. You cannot add or modify these users and roles using MongoDB clients or drivers. You can instead do this using SQL or Oracle Database Actions. The minimum Oracle AI Database roles required to use the API are CONNECT, RESOURCE, and SODA_APP.
A user (database schema) also needs to be enabled for use with Oracle REST Data Services (ORDS). This can be done by invoking PL/SQL procedure ORDS.enable_schema or using Oracle AI Database Actions.
For MongoDB, a “database” is a set of collections. For Oracle Database API for MongoDB, this corresponds to an Oracle AI Database schema.
Note:
Using Oracle API for MongoDB to drop a “database” does not drop the underlying database schema. Instead, it drops all collections within the schema.
An administrative user can drop a schema using SQL (for example, using Database Actions with an Autonomous Oracle AI Database).
For the API, a username must be a database schema name. The name is case-insensitive, it cannot start with a nonalphabetic character (including a numeral), and it must be provided with a secure password.
Normally, a user of the API can only perform operations within its schema (the username is the schema name). Examples of such operations include creating new collections, reading and writing documents, and creating indexes.
When an administrative user tries to insert data into a database schema (user) that does not exist, that schema is created automatically as a schema-only account, which means that it does not have a password and it cannot be logged into. The new schema is granted these privileges: SODA_APP, CREATE SESSION, CREATE TABLE, CREATE VIEW, CREATE SEQUENCE, CREATE PROCEDURE, and CREATE JOB. The schema is also given an unlimited tablespace quota, and is enabled for using Oracle REST Data Services (ORDS).
For an ordinary user of the API, a MongoDB shell command (such as use <database>) that switches from the current MongoDB database to another one is typically not supported — switching to another database schema raises an error.
However, an administrative user , which is one that has all of the following privileges, can create new users (database schemas), and can access any schema as any user: CREATE USER, ALTER USER, DROP USER.
An administrative user can do the following:
-
Use the schemas of other users.
Access to other schemas than that of the current user makes use of a proxied connection. For example, someone connected as an administrative user can perform operations in schema
other_userusing the same roles and privileges as if connected directly asother_user. -
Create new users (schemas).
For example, if an administrative user tries to create a collection in a schema
totothat does not already exist, that schema (user) is automatically created.
Oracle recommends that you do not allow production applications to make use of an administrative user. Applications should instead connect as ordinary users, with a minimum of privileges. In particular, connect an application to the database using a MongoClient that is specific to a particular schema (user).
See Also:
-
Create Users on Autonomous Database in Using Oracle Autonomous AI Database Serverless
-
Manage User Roles and Privileges on Autonomous Database in Using Oracle Autonomous AI Database Serverless
-
CREATE USER in Oracle AI Database SQL Language Reference for information about using SQL to create database schemas (also called database users)
-
GRANT in Oracle AI Database SQL Language Reference for information about using SQL to grant roles to database schemas
-
Using the Oracle Database API for MongoDB in Using Oracle Autonomous AI Database Serverless for information about using an Autonomous Database (including an Autonomous JSON Database) with Oracle Database API for MongoDB. This covers configuring the database for use with the API, including for security and connection.
-
ORDS.ENABLE_SCHEMA in Oracle REST Data Services Developer's Guide for information about enabling a database schema for ORDS