In the Oracle mode of OceanBase Database, for users who have multiple failed login attempts, the system will lock the users to prevent malicious password attacks, thereby improving database security.
The Oracle mode of OceanBase Database uses a profile to lock a user.
Applicability
This topic applies only to the Oracle mode of OceanBase Database. OceanBase Database Community Edition only supports MySQL mode. For more information about login failure processing in MySQL mode, see Login failure processing.
Concepts
Profile is a means of limiting the resources available for a database user. In the Oracle mode of OceanBase Database, the profile is used to control a user's login verification policy. By using a user's profile file, it is possible to lock the user.
The profile file provides two parameters to lock the user after multiple consecutive login failures:
failed_login_attempts: the number of consecutive failed login attempts.password_lock_time: the lock duration, in days.
The lock and unlock policies are as follows:
- Lock policy: When there are repeated failed login attempts due to an incorrect password, if the failure threshold is reached, the user will be locked.
- Unlock policy: If a logged-on user is locked, the system will check the lock duration when the user attempts to log in again. If the lock duration has expired, the system will unlock the user and the user will attempt to log in again. If the lock duration has not expired, the system will return an error. You can also use SQL statements to unlock the user.
Procedure
The administrator can create a profile and apply it to a user. Then, login failures of the user will be handled based on the profile. The procedure includes the following two steps:
Create a profile.
You can create a profile and specify the number of consecutive login failures and the corresponding lockout duration by using the
CREATE PROFILEstatement.The SQL syntax is as follows:
CREATE PROFILE "profile_name" LIMIT { FAILED_LOGIN_ATTEMPTS | PASSWORD_LOCK_TIME | PASSWORD_LIFE_TIME | PASSWORD_GRACE_TIME } { integer | UNLIMITED | DEFAULT };The syntax is described as follows:
To execute this statement, you must have the
CREATE PROFILEprivilege.FAILED_LOGIN_ATTEMPTSspecifies the number of consecutive login failures that triggers user lockout.If this parameter is not specified, the setting in the
DEFAULTprofile is used. The value of this parameter in theDEFAULTprofile isUNLIMITED, which indicates that the number of consecutive login failures is not limited.PASSWORD_LOCK_TIMEspecifies the number of days for which the user will be locked after the number of consecutive login failures reaches the threshold.If this parameter is not specified, the setting in the
DEFAULTprofile is used. The value of this parameter in theDEFAULTprofile isUNLIMITED, which indicates that the number of days for which the user will be locked is not limited.PASSWORD_LIFE_TIMEspecifies the number of days during which the same password can be used for authentication.If this parameter is not specified, the setting in the
DEFAULTprofile is used. The value of this parameter in theDEFAULTprofile isUNLIMITED, which indicates that the number of days during which the same password can be used for authentication is not limited.PASSWORD_GRACE_TIMEspecifies the number of days of the grace period during which the user is still allowed to log in after a warning is issued upon the expiration of the password lifetime.If this parameter is not specified, the setting in the
DEFAULTprofile is used. The value of this parameter in theDEFAULTprofile isUNLIMITED, which indicates that the number of days during which the user login is valid after the password lifetime expires is not limited.integer | UNLIMITED | DEFAULTspecifies the value range of a parameter.integerindicates that the value of the parameter is an integer.UNLIMITEDindicates that the value of the parameter is not restricted.DEFAULTindicates that the setting in theDEFAULTprofile is used.
For more information about the
CREATE PROFILEstatement, see CREATE PROFILE.Apply the profile to a user.
There are two scenarios:
When creating a user, you can directly specify the profile file that has already been created.
The SQL syntax is as follows:
obclient> CREATE USER user_name IDENTIFIED BY password PROFILE {"profile_name" | default};By default, if you do not specify a profile when you create a user, the
DEFAULTprofile is used. You can query theDBA_PROFILESview for the settings of theDEFAULTprofile.For more information about the
CREATE USERstatement, see CREATE USER.If the user has already been created, you can apply an existing profile file to the user by modifying their profile.
The SQL syntax is as follows:
obclient> ALTER USER user_name PROFILE {"profile_name" | default};For more information about the
ALTER USERstatement, see ALTER USER.
Examples
Log in to an Oracle tenant of a cluster as the
SYSuser.obclient -usys@oracle -h127.1 -P2881 - P*******Create a profile and set up a policy for consecutive failed logons.
Create a profile named
userprof1and configure a policy to lock the user for one day upon five consecutive login failures.obclient> CREATE PROFILE "userprof1" LIMIT FAILED_LOGIN_ATTEMPTS 5 PASSWORD_LOCK_TIME 1;Check whether the setting was successful.
obclient> SELECT * FROM DBA_PROFILES; +-----------+--------------------------+---------------+-------------+ | PROFILE | RESOURCE_NAME | RESOURCE_TYPE | LIMIT | +-----------+--------------------------+---------------+-------------+ | DEFAULT | FAILED_LOGIN_ATTEMPTS | PASSWORD | UNLIMITED | | DEFAULT | PASSWORD_GRACE_TIME | PASSWORD | UNLIMITED | | DEFAULT | PASSWORD_LIFE_TIME | PASSWORD | UNLIMITED | | DEFAULT | PASSWORD_LOCK_TIME | PASSWORD | 86400000000 | | DEFAULT | PASSWORD_VERIFY_FUNCTION | PASSWORD | NULL | | userprof1 | FAILED_LOGIN_ATTEMPTS | PASSWORD | 5 | | userprof1 | PASSWORD_GRACE_TIME | PASSWORD | DEFAULT | | userprof1 | PASSWORD_LIFE_TIME | PASSWORD | DEFAULT | | userprof1 | PASSWORD_LOCK_TIME | PASSWORD | 86400000000 | | userprof1 | PASSWORD_VERIFY_FUNCTION | PASSWORD | DEFAULT | +-----------+--------------------------+---------------+-------------+ 10 rows in setCreate a user and specify a profile.
obclient> CREATE USER secuser IDENTIFIED BY ****** PROFILE "userprof1"; obclient> GRANT all privileges ON *.* to secuser;Verify the configuration result.
If five consecutive incorrect passwords are entered, the user will be locked for one day.
$ obclient -h127.1 -P2881 -usecuser@oracle -p*******; obclient: [Warning] Using a password on the command line interface can be insecure. ERROR 5039 (01007): User lockedLog in to the
systenant as therootuser to view the login failure information.obclient> SELECT * FROM information_schema.CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS; +-------------+-----------------+ | USERHOST | FAILED_ATTEMPTS | +-------------+-----------------+ | 'test'@'%' | 5 | +-------------+-----------------+ 1 row in set (0.005 sec)Unlock the user.
Notice
If you log in as the administrator, you can directly lock and unlock users. If you log in as a regular user, you must have the global
ALTER USERprivilege to lock and unlock users. For more information about how to view and grant user privileges, see View user privileges and Grant direct privileges.obclient> ALTER USER secuser ACCOUNT UNLOCK;
Modify the login failure processing policy
You can execute the ALTER PROFILE statement to modify an existing profile.
For more information about the ALTER PROFILE statement, see ALTER PROFILE.
Notice
You cannot unlock a user by executing the ALTER PROFILE statement to modify the FAILED_LOGIN_ATTEMPTS parameter. The changes made by using the ALTER PROFILE statement in a profile affect only the users in subsequent sessions and do not affect the user in the current session.