日期:2014-05-16  浏览次数:20678 次

E9i密码策略——密码重用规则

Oracle通过PROFILE中的PASSWORD_REUSE_TIME和PASSWORD_REUSE_MAX来确定密码是否可以重用以及密码重用的限制。

但是,经过测试,发现Oracle的ADMINISTRATOR GUIDE里面的描述是错误的,我查阅了一下METALINK,METALINK上的一篇文章虽然对这两个参数进行了比较详细的说明,但是仍然有一部分描述是错误。


PASSWORD_REUSE_TIME是重用密码的最小时间间隔,单位是天。可以给出整数或分数,如1/1440表示1分钟(出于效率的考虑,oracle不会每分钟都去进行检查,一般来说,有5分钟左右的误差,因此如果这个数小于1/144则没有多大的意义)。

PASSWORD_REUSE_MAX是重用密码前更换密码的最小次数。

这两项本身没有任何异议,关键是两项如何配合使用。可以分为3种情况进行描述:

一、PASSWORD_REUSE_MAX和PASSWORD_REUSE_TIME都为UNLIMITED

这时密码可以任意重用,没有限制

这也是DEFAULT profile的默认值。当这两项都为UNLIMITED时,认为这两个参数没有使用,因此,密码重用没有任何限制。

SQL> create profile prof_test limit password_reuse_max unlimited
? 2? password_reuse_time unlimited;

配置文件已创建

SQL> create user test identified by test profile prof_test;

用户已创建

SQL> alter user test identified by test;

用户已更改。

SQL> alter user test identified by test;

用户已更改。

二、PASSWORD_REUSE_MAX和PASSWORD_REUSE_TIME中有一个为UNLIMITED,另一个为其他值。

这个时候你的密码将永远无法重用。

看看administrator guide上是怎么说的:

Use the CREATE PROFILE statement to specify a time interval during which users cannot reuse a password. In the following statement, a profile is defined where the PASSWORD_REUSE_TIME clause specifies that the user cannot reuse the password
for 60 days.

CREATE PROFILE prof LIMIT
PASSWORD_REUSE_TIME 60
PASSWORD_REUSE_MAX UNLIMITED;


In the next statement, the PASSWORD_REUSE_MAX clause specifies that the number of password changes the user must make before the current password can be used again is three.


CREATE PROFILE prof LIMIT
PASSWORD_REUSE_MAX 3
PASSWORD_REUSE_TIME UNLIMITED;

Note: If you specify PASSWORD_REUSE_TIME or PASSWORD_REUSE_MAX, you must set the other to UNLIMITED or not specify it at all.

文档告诉我们,只使用其中一个,把另外一个设置为UNLIMITED,但是这是不正确的,这样会导致你的密码永远无法重用。

SQL> alter profile prof_test limit password_reuse_max 3;

配置文件已更改

SQL> select resource_name, limit from dba_profiles
? 2? where profile = 'PROF_TEST' and resource_type = 'PASSWORD';

RESOURCE_NAME??????????????????? LIMIT
-------------------------------- ----------------------------------------
FAILED_LOGIN_ATTEMPTS??????????? DEFAULT
PASSWORD_LIFE_TIME?????????????? DEFAULT
PASSWORD_REUSE_TIME????????????? UNLIMITED
PASSWORD_REUSE_MAX?????????????? 3
PASSWORD_VERIFY_FUNCTION???????? DEFAULT
PASSWORD_LOCK_TIME?????????????? DEFAULT
PASSWORD_GRACE_TIME????????????? DEFAULT

已选择7行。

SQL> alter user test identified by test;

用户已更改。

SQL> alter user test identified by test;
alter user test identified by test
*
ERROR 位于第 1 行:
ORA-28007: 无法重新使用口令


SQL> alter user test identified by t1;

用户已更改。

SQL> alter user test identified by t2;

用户已更改。

SQL> alter user test identified by t3;

用户已更改。

SQL> alter user test identified by test;
alter user test identified by test
*
ERROR 位于第 1 行:
ORA-28007: 无法重新使用口令

修改profile后,只对test用户的后续操作有效,第一次可以修改密码为test是因为oracle没有记录初始密码,而第二次修改就会失败,因为密码已经不能重用了。

根据文档,我们只需要修改密码三次,就可以重用,但是测试的结果确是密码无法在重用。

SQL> alter profile prof_test limit password_reuse_max unlimited;

配置文件已更改

SQL> alter user test identified by test;

用户已更改。

SQL> alter profile prof_test limit password_reuse_time 1/144;

配置文件已更改

SQL> select resource_name, limit from dba_profiles
? 2? where profile = 'PROF_TEST' and resource_type = 'PASSWORD';

RESOURCE_NAME??????????????????? LIMIT
-------------------------------- ----------------------------------------
FAILED_LOGIN_ATTEMPTS??????????? DEFAULT
PASSWORD_LIFE_TIME?????????????? DEFAULT
PASSWORD_REUSE_TIME????????????? .0069
PASSWORD_REUSE_MAX?????????????? UNLIMITED
PASSWORD_VERIFY_FUNCTION???????? DEFAULT