`
chxw00
  • 浏览: 25813 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

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
PASSWORD_LOCK_TIME               DEFAULT
PASSWORD_GRACE_TIME              DEFAULT

已选择7行。

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


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


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


17:07:40 SQL> set time off
SQL>

修改PASSWORD_REUSE_TIME为1/144,也就是说大概10分钟的时间,考虑的oracle的误差,我们在10分钟和20分钟后分别进行测试。结果发现密码仍然无法重用。

三、PASSWORD_REUSE_MAX和PASSWORD_REUSE_TIME都不为UNLIMITED。

这时只需满足任意一个条件就可以重用密码

Metalink上的文章在这里描述有误,密码重用不需要同时满足两个条件,只要满足一个既可。

SQL> alter profile prof_test limit password_reuse_time unlimited;

配置文件已更改

SQL> alter user test identified by test;

用户已更改。

SQL> alter profile prof_test limit
  2  password_reuse_max 3 password_reuse_time 1/144;

配置文件已更改

SQL> set time on
17:11:30 SQL> alter user test identified by test;

用户已更改。

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


17:11:56 SQL> alter user test identified by t1;

用户已更改。

17:12:06 SQL> alter user test identified by t2;

用户已更改。

17:12:12 SQL> alter user test identified by t3;

用户已更改。

17:12:19 SQL> alter user test identified by test;

用户已更改。

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


17:13:55 SQL>
17:14:00 SQL>
17:32:14 SQL> alter user test identified by test;

用户已更改。

17:32:21 SQL>

第一次重用test密码才过了1分钟左右,而在第二次重用test密码之前并没有使用过其他密码。可见,只需满足PASSWORD_REUSE_MAX和PASSWORD_REUSE_TIME中的任意一个条件就可以。

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics