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
至於這個小特性在實踐中是否能發揮作用,大家可以留言表達一下各自的觀點。
原文釋出時間為:2018-11-8 本文作者:蓋國強
本文來自雲棲社群合作伙伴“資料和雲 ”,瞭解相關資訊可以關注“資料和雲”。