7.1.4.4. 기본 사용자 및 역할 관리 절차 Enterprise Edition
이 절에서는 Neo4j Cluster의 기본 사용자 및 역할 관리하는 절차에 대해서 설명합니다.
Neo4j에서는 Cypher를 통해 내장 프로 시저를 사용하여 기본 사용자 및 역할 관리를 관리합니다. 이 절에서는 몇 가지 간단한 예제와 함께 사용자 관리를위한 모든 보안 절차 목록을 제공합니다. 제공된 예제를 실행하려면 Neo4j Browser 또는 Neo4j Cypher Shell을 사용하십시오.
이 절에서는 다음을 설명합니다.
- List all users
- List all roles
- List all roles for a user
- List all users for a role
- Create a user
- Delete a user
- Assign a role to a user
- Remove a role from a user
- Create a custom role
- Delete a custom role
- Suspend a user
- Activate a user
- Change a user’s password
- Change the current user’s password
- List roles per procedure
List all users
administrator는 모든 user에 대해서 내용을 확인이 가능합니다.
문법:
CALL dbms.security.listUsers()
결과값:
| 이름 | 타입 | 설 명 |
|---|---|---|
username |
String | 사용자의 이름입니다. |
roles |
List |
사용자에게 할당된 역할의 목록입니다. |
flags |
List |
사용자가 일시 중지되었거나 암호를 변경해야하는지 여부를 나타내는 일련의 플래그입니다. |
예외:
CALL dbms.security.listUsers()
+---------------------------------------------------------------------+
| username | roles | flags |
+---------------------------------------------------------------------+
| "neo4j" | ["admin"] | [] |
| "anne" | [] | ["password_change_required"] |
| "bill" | ["reader"] | ["is_suspended"] |
| "john" | ["architect","publisher"] | [] |
+---------------------------------------------------------------------+
4 rows
List all roles
administrator는 시스템의 각 역할에 대해 할당 된 모든 사용자를 볼 수 있습니다.
문법:
CALL dbms.security.listRoles()
결과값:
| 이름 | 타입 | 설 명 |
|---|---|---|
role |
String | 역할의 이름입니다. |
users |
List |
역할을 할당받은 모든 사용자의 사용자 이름 목록입니다. |
예외:
CALL dbms.security.listRoles()
+------------------------------+
| role | users |
+------------------------------+
| "reader" | ["bill"] |
| "architect" | [] |
| "admin" | ["neo4j"] |
| "publisher" | ["john","bob"] |
+------------------------------+
4 rows
List all roles for a user
active user는 할당 된 roles을 모두 볼 수 있습니다. administrator는 시스템의 모든 user에 대해 할당 된 모든 역할을 볼 수 있습니다.
문법:
CALL dbms.security.listRolesForUser(*username*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
username |
String | 사용자의 사용자 이름입니다. |
결과값:
| 이름 | 타입 | 설 명 |
|---|---|---|
value |
String | 요청한 사용자에게 할당 된 모든 역할을 반환합니다. |
예외:
| 현재 사용자가 관리자가 아니며 사용자 이름이 현재 사용자의 사용자 이름과 일치하지 않습니다. |
|---|
| 사용자 이름이 시스템에 없습니다. |
고려사항:
- 현재 사용자가 관리자인지 여부에 관계없이 이 절차는 현재 사용자가 자신의 역할을 보기 위해 호출 할 수 있습니다.
- 관리자가 이 절차를 호출하여 다른 사용자의 역할을 볼 수 있습니다.
reader 와 publisher을 보여줍니다.
CALL dbms.security.listRolesForUser('johnsmith')
+-------------+
| value |
+-------------+
| "reader" |
| "publisher" |
+-------------+
2 rows
List all users for a role
administrator는 roles에 대해 할당 된 모든 user를 볼 수 있습니다.
문법:
CALL dbms.security.listUsersForRole(*roleName*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
roleName |
String | 역할의 이름입니다. |
결과값:
| 이름 | 타입 | 설 명 |
|---|---|---|
value |
String | 요청 된 역할에 대해 할당 된 모든 사용자가 반환됩니다. |
예외:
| 현재 사용자는 관리자가 아닙니다. |
|---|
| 역할 이름이 시스템에 없습니다. |
publisher에 할당된 모든 사용자인 'bill'과 'anne'를 나열합니다.
CALL dbms.security.listUsersForRole('publisher')
+--------+
| value |
+--------+
| "bill" |
| "anne" |
+--------+
2 rows
Create a user
administrator는 새 user를 만들 수 있습니다. 이 작업은 사용자에게 roles을 할당하여 수행해야합니다. 설명은 여기를 참조하세요.
문법:
CALL dbms.security.createUser(*username*, *password*, *requirePasswordChange*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
username |
String | 사용자의 사용자 이름입니다. |
password |
String | 사용자의 암호입니다. |
requirePasswordChange |
Boolean | 선택값이며 기본은 true입니다. true이면 (i) 사용자는 처음 로그인시에 필수로 패스워드를 변경해야 합니다. (ii) 비밀번호를 변경하기 전까지 사용자는 다른 작업을 수행할 수 없습니다. |
예외:
| 현재사용자는 관리자가 아닙니다. |
|---|
사용자 이름은 ! 와 ~ 사이에 ASCII 문자 이외의 문자를 포함하거나 : 와 , 를 포함합니다. |
| 사용자 이름은 이미 시스템 내에서 사용 중입니다. |
| 암호는 빈 문자열입니다. |
CALL dbms.security.createUser('johnsmith', 'h6u4%kr')
Delete a user
An administrator is able to delete permanently a user from the system. It is not possible to undo this action, so, if in any doubt, consider suspending the user instead.
문법:
CALL dbms.security.deleteUser(*username*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
username |
String | This is the username of the user to be deleted. |
예외:
| The current user is not an administrator. |
|---|
| The username does not exist in the system. |
| The username matches that of the current user (i.e. deleting the current user is not permitted). |
고려사항:
- It is not necessary to remove any assigned roles from the user prior to deleting the user.
- Deleting a user will terminate with immediate effect all of the user’s sessions and roll back any running transactions.
- As it is not possible for the current user to delete themselves, there will always be at least one administrator in the system.
CALL dbms.security.deleteUser('janebrown')
Assign a role to a user
An administrator is able to assign a role to any user in the system, thus allowing the user to perform a series of actions upon the data.
문법:
CALL dbms.security.addRoleToUser(*roleName*, *username*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
roleName |
String | This is the name of the role to be assigned to the user. |
username |
String | This is the username of the user who is to be assigned the role. |
예외:
| The current user is not an administrator. |
|---|
| The username does not exist in the system. |
| The username contains characters other than alphanumeric characters and the ‘_’ character. |
| The role name does not exist in the system. |
| The role name contains characters other than alphanumeric characters and the ‘_’ character. |
고려사항:
- This is an idempotent procedure.
CALL dbms.security.addRoleToUser('publisher', 'johnsmith')
Remove a role from a user
An administrator is able to remove a role from any user in the system, thus preventing the user from performing upon the data any actions prescribed by the role.
문법:
CALL dbms.security.removeRoleFromUser(*roleName*, *username*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
roleName |
String | This is the name of the role which is to be removed from the user. |
username |
String | This is the username of the user from which the role is to be removed. |
예외:
| The current user is not an administrator. |
|---|
| The username does not exist in the system. |
| The role name does not exist in the system. |
The username is that of the current user and the role is admin. |
고려사항:
- If the username is that of the current user and the role name provided is
admin, an error will be thrown; i.e. the current user may not be demoted from being an administrator. - As it is not possible for the current user to remove the
adminrole from themselves, there will always be at least one administrator in the system. - This is an idempotent procedure.
CALL dbms.security.removeRoleFromUser('publisher', 'johnsmith')
Create a custom role
An administrator is able to create custom roles in the system.
문법:
CALL dbms.security.createRole(*roleName*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
roleName |
String | This is the name of the role to be created. |
예외:
| The current user is not an administrator. |
|---|
| The role name already exists in the system. |
| The role name is empty. |
| The role name contains characters other than alphanumeric characters and the ‘_’ character. |
The role name matches one of the native roles: reader, publisher, architect, and admin. |
CALL dbms.security.createRole('operator')
Delete a custom role
An administrator is able to delete custom roles from the system. The native roles reader, publisher, architect, and admin (see Section 7.1.4.1, “Native roles”) cannot be deleted.
문법:
CALL dbms.security.deleteRole(*roleName*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
roleName |
String | This is the name of the role to be deleted. |
예외:
| The current user is not an administrator. |
|---|
| The role name does not exist in the system. |
The role name matches one of the native roles: reader, publisher, architect, and admin. |
고려사항:
- Any role assignments will be removed.
CALL dbms.security.deleteRole('operator')
Suspend a user
An administrator is able to suspend a user from the system. The suspended user may be activated at a later stage.
문법:
CALL dbms.security.suspendUser(*username*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
username |
String | This is the username of the user to be suspended. |
예외:
| The current user is not an administrator. |
|---|
| The username does not exist in the system. |
| The username matches that of the current user (i.e. suspending the current user is not permitted). |
고려사항:
- Suspending a user will terminate with immediate effect all of the user’s sessions and roll back any running transactions.
- All of the suspended user’s attributes — assigned roles and password — will remain intact.
- A suspended user will not be able to log on to the system.
- As it is not possible for the current user to suspend themselves, there will always be at least one active administrator in the system.
- This is an idempotent procedure.
CALL dbms.security.suspendUser('billjones')
Activate a user
An administrator is able to activate a suspended user so that the user is once again able to access the data in their original capacity.
문법:
CALL dbms.security.activateUser(*username*, *requirePasswordChange*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
username |
String | This is the username of the user to be activated. |
requirePasswordChange |
Boolean | This is optional, with a default of true. If this is true, (i) the user will be forced to change their password when they next log in, and (ii) until the user has changed their password, they will be forbidden from performing any other operation. |
예외:
| The current user is not an administrator. |
|---|
| The username does not exist in the system. |
| The username matches that of the current user (i.e. activating the current user is not permitted). |
고려사항:
- This is an idempotent procedure.
CALL dbms.security.activateUser('jackgreen')
Change a user’s password
An administrator is able to change the password of any user within the system. Alternatively, the current user may change their own password.
문법:
CALL dbms.security.changeUserPassword(*username*, *newPassword*, *requirePasswordChange*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
username |
String | This is the username of the user whose password is to be changed. |
newPassword |
String | This is the new password for the user. |
requirePasswordChange |
Boolean | This is optional, with a default of true. If this is true, (i) the user will be forced to change their password when they next log in, and (ii) until the user has changed their password, they will be forbidden from performing any other operation. |
예외:
| The current user is not an administrator and the username does not match that of the current user. |
|---|
| The username does not exist in the system. |
| The password is the empty string. |
| The password is the same as the user’s previous password. |
고려사항:
- This procedure may be invoked by the current user to change their own password, irrespective of whether or not the current user is an administrator.
- This procedure may be invoked by an administrator to change another user’s password.
- In addition to changing the user’s password, this will terminate with immediate effect all of the user’s sessions and roll back any running transactions.
예제 7.13. Change a user’s password
The following example changes the password of the user with the username 'joebloggs' to 'h6u4%kr'. When the user 'joebloggs' next logs in, he will be required to change his password.
CALL dbms.security.changeUserPassword('joebloggs', 'h6u4%kr')
Change the current user’s password
Any active user is able to change their own password at any time.
문법:
CALL dbms.security.changePassword(*password*, *requirePasswordChange*)
인수:
| 이름 | 타입 | 설 명 |
|---|---|---|
password |
String | This is the new password for the current user. |
requirePasswordChange |
Boolean | This is optional, with a default of false. If this is true, (i) the current user will be forced to change their password when they next log in, and (ii) until the current user has changed their password, they will be forbidden from performing any other operation. |
예외:
| The password is the empty string. |
|---|
| The password is the same as the current user’s previous password. |
CALL dbms.security.changePassword('h6u4%kr')
List roles per procedure
Any active user is able to view all procedures in the system, including which role(s) have the privilege to execute them.
문법:
CALL dbms.procedures()
결과값:
| 이름 | 타입 | 설 명 |
|---|---|---|
name |
String | This is the name of the procedure. |
signature |
String | This is the signature of the procedure. |
description |
String | This is a description of the procedure. |
roles |
List |
This is a list of roles having the privilege to execute the procedure. |
CALL dbms.procedures()
YIELD name, signature, description, roles
WITH name, description, roles
WHERE name contains 'security'
RETURN name, description, roles
ORDER BY name
LIMIT 4
+--------------------------------------------------------------------------------------------------------------+
|name |description |roles |
+--------------------------------------------------------------------------------------------------------------+
|"dbms.security.activateUser" |"Activate a suspended user." | ["admin"] |
|"dbms.security.addRoleToUser" |"Assign a role to the user." | ["admin"] |
|"dbms.security.changePassword" |"Change the current user's password."| ["reader","editor","publisher", ... |
|"dbms.security.changeUserPassword"|"Change the given user's password." | ["admin"] |
+--------------------------------------------------------------------------------------------------------------+
4 rows