使用PASSWORD_VERIFY_FUNCTION設定使用者密碼複雜度
依據PASSWORD_VERIFY_FUNCTION可以設定oracle使用者的密碼複雜度,比如密碼長度>=10,必須包含字母/數字等
首先需要建立一個密碼驗證的function,然後設定profile的PASSWORD_VERIFY_FUNCTION即可
SQL> select TEXT from dba_source where NAME='VERIFY_JUSTIN_USER';
TEXT
------------------------------------------------------------------------------------------------------------------------------------
FUNCTION verify_JUSTIN_user ( username VARCHAR2,
password VARCHAR2,
old_password varchar2 )
RETURN boolean
IS
passwordMinLength INTEGER;
passwordLength INTEGER;
differ INTEGER;
differMinLength INTEGER;
isDigit BOOLEAN;
isChar BOOLEAN;
isPunct BOOLEAN;
digitArray VARCHAR2(20);
punctArray VARCHAR2(25);
charArray VARCHAR2(52);
BEGIN
digitArray := '0123456789';
charArray := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
punctArray := '!"#$%&()``*+,-/:;<=>?_';
passwordMinLength := 10;
differMinLength := 2;--HAD-1
passwordLength := LENGTH(password);
isDigit := FALSE;
isChar := FALSE;
isPunct := FALSE;
-- +------------------------------------------------+
-- | Check if the password is same as the username |
-- +------------------------------------------------+
IF NLS_LOWER(password) = NLS_LOWER(username) THEN
raise_application_error( -20001, 'Password same as or similar to user' );
END IF;
-- +-------------------------------------------------+
-- | Check that password is more than [x] characters |
-- | in length. |
-- +-------------------------------------------------+
IF (LENGTH(password) < passwordMinLength) THEN
raise_application_error( -20002, 'Password must be greater than '
||
passwordMinLength
||
' characters.' );
END IF;
-- +----------------------------------------------------+
-- | Check if the password is too simple. A dictionary |
-- | of words may be maintained and a check may be made |
-- | so as not to allow the words that are too simple |
-- | for the password. |
-- +----------------------------------------------------+
IF NLS_LOWER(password) IN ( 'welcome'
, 'database'
, 'account'
, 'user'
, 'password'
, 'oracle'
, 'computer'
, 'abcd') THEN
raise_application_error(-20003, 'Password too simple');
END IF;
-- +-----------------------------------------------------+
-- | Check if the password contains at least one letter, |
-- | one digit and one punctuation mark. |
-- +-----------------------------------------------------+
-- +-----------------------------------------------------+
-- | (1.) Check for the digit |
-- +-----------------------------------------------------+
FOR i IN 1..10 LOOP
FOR j IN 1..passwordLength LOOP
IF SUBSTR(password,j,1) = SUBSTR(digitArray,i,1) THEN
isDigit := TRUE;
GOTO findchar;
END IF;
END LOOP;
END LOOP;
IF isDigit = FALSE THEN
raise_application_error(-20004, 'Password should contain at least '
||
' one digit,'
||
' one character and'
||
' one punctuation');
END IF;
-- +-----------------------------------------------------+
-- | (2.) Check for the character |
-- +-----------------------------------------------------+
<<findchar>>
FOR i IN 1..LENGTH(charArray) LOOP
FOR j IN 1..passwordLength LOOP
IF SUBSTR(password,j,1) = SUBSTR(charArray,i,1) THEN
isChar := TRUE;
GOTO findpunct;
END IF;
END LOOP;
END LOOP;
IF isChar = FALSE THEN
raise_application_error(-20004, 'Password should contain at least '
||
' one digit,'
||
' one character and'
||
' one punctuation');
END IF;
-- +-----------------------------------------------------+
-- | (3.) Check for the punctuation |
-- +-----------------------------------------------------+
<<findpunct>>
FOR i IN 1..LENGTH(punctArray) LOOP
FOR j IN 1..passwordLength LOOP
IF SUBSTR(password,j,1) = SUBSTR(punctArray,i,1) THEN
isPunct := TRUE;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF isPunct = FALSE THEN
raise_application_error(-20004, 'Password should contain at least '
||
' one digit,'
||
' one character and'
||
' one punctuation');
END IF;
<<endsearch>>
-- +-----------------------------------------------------+
-- | Check that the new password is not null. |
-- +-----------------------------------------------------+
IF old_password = '' THEN
raise_application_error(-20005, 'Old password is null');
END IF;
-- +-----------------------------------------------------+
-- | Check if the password differs from the previous |
-- | password by at least [x] letters. |
-- +-----------------------------------------------------+
differ := ABS(LENGTH(old_password) - LENGTH(password));
IF differ < differMinLength THEN
IF LENGTH(password) < LENGTH(old_password) THEN
passwordLength := LENGTH(password);
ELSE
passwordLength := LENGTH(old_password);
END IF;
FOR i IN 1..passwordLength LOOP
IF SUBSTR(password,i,1) != SUBSTR(old_password,i,1) THEN
differ := differ + 1;
END IF;
END LOOP;
IF differ < differMinLength THEN
raise_application_error(-20006, 'Password should differ by at least '
||
differMinLength
||
' characters.');
END IF;
END IF;
-- +-----------------------------------------------------+
-- | Well, looks like we passed all of the requirements. |
-- | Simple return 'true'. |
-- +-----------------------------------------------------+
RETURN(true);
END;
188 rows selected.
SQL> select * from dba_profiles;
PROFILE RESOURCE_NAME RESOURCE LIMIT
------------------------------ -------------------------------- -------- ----------------------------------------
JUSTIN_PROFILE PASSWORD_VERIFY_FUNCTION PASSWORD VERIFY_JUSTIN_USER
此後建立user可以指定該profile,密碼若驗證無法透過澤使用者建立會失敗
SQL> create user sagda identified by"asd245(" profile JUSTIN_PROFILE;
create user sagda identified by"asd245(" profile JUSTIN_PROFILE
*
ERROR at line 1:
ORA-28003: password verification for the specified password failed
ORA-20002: Password must be greater than 10 characters.
SQL> create user sagda identified by"asd245234155" profile JUSTIN_PROFILE;
create user sagda identified by"asd245234155" profile JUSTIN_PROFILE
*
ERROR at line 1:
ORA-28003: password verification for the specified password failed
ORA-20004: Password should contain at least one digit, one character and one punctuation
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29067253/viewspace-2128580/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 密碼複雜度設定函式密碼複雜度函式
- Linux 如何設定密碼複雜度?Linux密碼複雜度
- Oracle EBS 資料庫密碼複雜度設定Oracle資料庫密碼複雜度
- Profile設定高標準密碼複雜度的方法密碼複雜度
- 分享Profile設定高標準密碼複雜度的方法密碼複雜度
- 11gR2 Database使用者密碼複雜度驗證Database密碼複雜度
- 不要再強迫我設定複雜密碼密碼
- GitLab 中文版如何設定密碼長度、複雜度以及過期時間?Gitlab密碼複雜度
- MySQL 5.7 初始密碼和密碼複雜度問題MySql密碼複雜度
- Linux 生成複雜密碼並且檢查密碼強度Linux密碼
- Linux 使用者和密碼設定Linux密碼
- 【PROFILE】Oracle11g密碼複雜度說明Oracle密碼複雜度
- 如何在 Linux 生成複雜密碼並且檢查密碼強度Linux密碼
- 密碼的複雜化密碼
- 淺析程式碼圈複雜度及認知複雜度複雜度
- Javascript校驗密碼複雜度的正規表示式JavaScript密碼複雜度
- oracle使用者密碼有效期設定Oracle密碼
- linux建立使用者並設定密碼Linux密碼
- root使用者下設定N重密碼密碼
- 複雜密碼生成工具apg密碼
- Go Web 程式設計--使用 bcrpyt 雜湊使用者密碼GoWeb程式設計密碼
- linux建立使用者、設定密碼、修改使用者、刪除使用者Linux密碼
- linux新增使用者並設定密碼以及刪除使用者Linux密碼
- 時間複雜度跟空間複雜度時間複雜度
- 時間複雜度和空間複雜度時間複雜度
- 時間複雜度與空間複雜度時間複雜度
- oracle使用者密碼設定的特殊字元問題Oracle密碼字元
- MySQL5.7 使用者設定密碼解決方法MySql密碼
- 降低程式碼的圈複雜度——複雜程式碼的解決之道複雜度
- Linux建立使用者、設定密碼、修改使用者、刪除使用者命令Linux密碼
- Java 程式碼本地設定Hadoop使用者名稱密碼JavaHadoop密碼
- 用程式碼複雜度分析風險複雜度
- ruby指令碼,隨機生成複雜密碼指令碼隨機密碼
- 軟體設計的複雜度複雜度
- Linux設定口令複雜度和口令定期更換策略Linux複雜度
- 複雜度分析複雜度
- 預設使用者和密碼密碼
- 設定Oracle的使用者密碼不區分大小寫Oracle密碼