Difference between revisions of "User Management"
Line 1: | Line 1: | ||
This article is part of the [[Advanced User's Guide]]. | This article is part of the [[Advanced User's Guide]]. | ||
The user management defines which permissions are required | The user management defines which permissions are required | ||
− | by a user to perform a | + | by a user to perform a database command or XQuery expression. |
− | Permissions are | + | Permissions are mostly relevant in the client/server architecture, as the |
+ | [[Standalone Mode]] and the [[GUI]] is run with admin permissions. | ||
+ | There are a few exceptions such as the [[XQuery Module#xquery:eval|xquery:eval]] function: | ||
+ | its execution scope can also be limited by specifying a permission. | ||
+ | |||
+ | With {{Version|8.0}}, the user management has been reworked: | ||
+ | |||
+ | * Permissions can be manually edited, as they are now stored as XML. | ||
+ | * The permission file has been moved from the home directory to the database directory. It was renamed from {{Code|.basexperm}} to {{Code|users.xml}}. | ||
+ | * Local permissions are now defined for database glob patterns. Both local and global permissions are stored in the same file. | ||
+ | * A new [[User Module]] was introduced to allow user management via XQuery. | ||
+ | |||
+ | ==Rules== | ||
In the permission hierarchy below, the existing permissions are illustrated. | In the permission hierarchy below, the existing permissions are illustrated. | ||
A higher permission includes all lower permissions. | A higher permission includes all lower permissions. | ||
− | For example, all users who have the <code> | + | For example, all users who have the <code>write</code> permission assigned |
− | will also be able to execute commands requiring <code> | + | will also be able to execute commands requiring <code>read</code> permission. |
− | |||
− | |||
− | + | Local permissions are applied to databases. They have a higher precedence | |
− | and | + | and override global permissions. |
[[File:perms.png|none|thumb|403px|Permissions hierarchy]] | [[File:perms.png|none|thumb|403px|Permissions hierarchy]] | ||
− | User names must follow the | + | User names must follow the [[Valid Names|valid names constraints]], and the database patterns must follow the [[Commands#Glob_Syntax|Glob Syntax]]. |
==Commands== | ==Commands== | ||
− | Admin permissions are | + | Admin permissions are required to execute all of the following commands: |
− | + | ||
− | ''' | + | '''Create user 'test' (password will be entered on command line). By default, the user will have no permissions ('none'): |
<code>> CREATE USER test</code> | <code>> CREATE USER test</code> | ||
− | '''Change user 'test' | + | '''Change password of user 'test' to '71x343sd#': |
− | <code>> ALTER | + | <code>> ALTER PASSWORD test 71x343sd#</code> |
− | + | '''Grant local write permissions to user 'test': ''' | |
− | |||
− | |||
− | + | <code>> GRANT write ON unit* TO test</code> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | <code>> GRANT write ON | ||
Note: Local permissions overwrite global permissions. | Note: Local permissions overwrite global permissions. | ||
− | As a consequence, the 'test' user will only be allowed to | + | As a consequence, the 'test' user will only be allowed to access (i.e., read and write) |
− | access (i.e., read and write) the ' | + | database starting with the letters 'unit'. If no local permissions are set, |
− | If no local permissions are set, the global rights are | + | the global rights are inherited. |
− | inherited. | ||
− | ''' | + | '''Show global permissions:''' |
<code>> SHOW USERS</code> | <code>> SHOW USERS</code> | ||
− | ''' | + | '''Show detailed information about user 'test' via XQuery:''' |
− | <code>> | + | <code>> XQUERY user:list-details()[@name = 'test']</code> |
− | ''' | + | '''Drop of user 'test' via XQuery:''' |
− | <code>> | + | <code>> XQUERY user:drop('test')</code> |
[[Category:Server]] | [[Category:Server]] | ||
[[Category:Internals]] | [[Category:Internals]] | ||
+ | |||
+ | =Changelog= | ||
+ | |||
+ | Revised in Version 8.0. |
Revision as of 01:08, 11 December 2014
This article is part of the Advanced User's Guide. The user management defines which permissions are required by a user to perform a database command or XQuery expression.
Permissions are mostly relevant in the client/server architecture, as the Standalone Mode and the GUI is run with admin permissions. There are a few exceptions such as the xquery:eval function: its execution scope can also be limited by specifying a permission.
With Version 8.0, the user management has been reworked:
- Permissions can be manually edited, as they are now stored as XML.
- The permission file has been moved from the home directory to the database directory. It was renamed from
.basexperm
tousers.xml
. - Local permissions are now defined for database glob patterns. Both local and global permissions are stored in the same file.
- A new User Module was introduced to allow user management via XQuery.
Rules
In the permission hierarchy below, the existing permissions are illustrated.
A higher permission includes all lower permissions.
For example, all users who have the write
permission assigned
will also be able to execute commands requiring read
permission.
Local permissions are applied to databases. They have a higher precedence and override global permissions.
User names must follow the valid names constraints, and the database patterns must follow the Glob Syntax.
Commands
Admin permissions are required to execute all of the following commands:
Create user 'test' (password will be entered on command line). By default, the user will have no permissions ('none'):
> CREATE USER test
Change password of user 'test' to '71x343sd#':
> ALTER PASSWORD test 71x343sd#
Grant local write permissions to user 'test':
> GRANT write ON unit* TO test
Note: Local permissions overwrite global permissions. As a consequence, the 'test' user will only be allowed to access (i.e., read and write) database starting with the letters 'unit'. If no local permissions are set, the global rights are inherited.
Show global permissions:
> SHOW USERS
Show detailed information about user 'test' via XQuery:
> XQUERY user:list-details()[@name = 'test']
Drop of user 'test' via XQuery:
> XQUERY user:drop('test')
Changelog
Revised in Version 8.0.