Oracle 18c新特性:Schema-Only 帳號提升應用管理安全性

在 Oracle 18c 中,一個特殊類型的帳號被引入到數據庫當中,這特特性被稱爲 Schema-Only 帳號,這個帳號通過 NO AUTHENTICATION 語句建立,沒有密碼,也就不允許直接登錄,所以這種帳號類型是 純模式類型

帳號不能直接登錄也就具備了天然的安全受益:

可以強制通過應用(Application)來訪問數據; 保護對象安全,例如阻止可能的誤刪除(DROP)操作;

Schema-Only賬戶具有一些限制:

不能被授予系統管理權限,如(SYSDBA、SYSASM)等; 不能通過DB Link訪問; 只支持DB實例,不支持ASM實例;

針對這個特性,DBA_USERS 視圖增加了一個新的字段 AUTHENTICATION_TYPE 用於標識帳號屬性,當創建Schema-Only 帳號時顯示爲 NONE否則會顯示 PASSWORD。

下面讓我們通過簡單的測試來看看這個新特性,首先在一個 PDB 上創建 NO AUTHENTICATION 的帳號,用戶名是 enmotech:

SQL> connect / as sysdba Connected. SQL> select name from v$pdbs; NAME --------------------------------------- PDB$SEED ORCLPDB1 SQL> alter pluggable database ORCLPDB1 open; Pluggable database altered. SQL> alter session set container=ORCLPDB1; Session altered. SQL> create user enmotech NO AUTHENTICATION; User created. SQL> grant create session,create any table,create any view to enmotech; Grant succeeded. SQL> exec print_table('select username,password,password_versions,account_status,authentication_type from dba_users where username=''ENMOTECH'''); USERNAME : ENMOTECH PASSWORD : PASSWORD_VERSIONS : ACCOUNT_STATUS : OPEN AUTHENTICATION_TYPE : NONE -----------------

這個帳號沒有口令,自然就無法直接登錄,我們可以通過用戶代理來訪問這個用戶,代理是很早的一個數據庫功能,現在有了新的作用。

我們在 ORCLPDB1 創建一個新的用戶 yhem,這個用戶僅有 create session 權限;

SQL> create user yhem identified by enmotech; User created. SQL> grant create session to yhem; Grant succeeded.

授予用戶 yhem 代理權限,通過該用戶可以連接到 enmotech 這個受限用戶,以下示範中 bethune 是我建立的一個 TNS 連接串名:

SQL> alter user enmotech grant connect through yhem; User altered. SQL> connect yhem[enmotech]/enmotech@bethune Connected. SQL> show user USER is "ENMOTECH" SQL> create table acoug (id number,name varchar2(200)); Table created. SQL> drop table acoug; Table dropped.

基本上,這就是新特性的基本展示,最核心的功能,是可以將 Schema-Only 用戶的對象增刪數據權限授予應用用戶,就防範了模式用戶直接訪問可能帶來的種種風險。

驗證一下,純模式用戶不能被授予 SYSDBA 權限,其角色切換也很簡單,授予密碼就解除了 NO AUTHENTICATION 狀態,回收SYSDBA權限纔可以重新NO AUTHENTICATION 。

SQL> grant sysdba to enmotech; grant sysdba to enmotech * ERROR at line 1: ORA-40366: Administrative privilege cannot be granted to this user. SQL> alter user enmotech identified by eygle; User altered. SQL> grant sysdba to enmotech; Grant succeeded. SQL> alter user enmotech no authentication; alter user enmotech no authentication * ERROR at line 1: ORA-40367: An Administrative user cannot be altered to have no authentication type. SQL> revoke sysdba from enmotech; Revoke succeeded. SQL> alter user enmotech no authentication; User altered.

當然也可以在 CDB 中創建 COMMON 用戶,指定其爲 NO AUTHENTICATION :

SQL> connect / as sysdba Connected. SQL> create user c##enmo no authentication; User created. SQL> set serveroutput on SQL> exec print_table('select con_id,username,authentication_type from cdb_users where username=''C##ENMO'''); CON_ID : 1 USERNAME : C##ENMO AUTHENTICATION_TYPE : NONE ----------------- CON_ID : 3 USERNAME : C##ENMO AUTHENTICATION_TYPE : NONE -----------------

至於這個小特性在實踐中是否能發揮作用,大家可以留言表達一下各自的觀點。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章