Authorization
Authorization configuration provided for users who can connect to ShardingSphere-Proxy. Users can be granted different authorities.
Background
ShardingSphere-Proxy uses the global rule, Authority Rule (identified as !AUTHORITY), to configure user and authorization information.
Thanks to ShardingSphere’s pluggable architecture, Proxy provides two levels of authority providers, namely:
ALL_PERMITTED
: grant all authorities by default without authentication.DATABASE_PERMITTED
: grant users the authority to specify a logical database, mapped throughuser-database-mappings
.
The administrator can choose which authority provider to use as needed when configuring the Authority Rule.
Parameter
rules:
- !AUTHORITY
users:
- # Specify the username, authorized host, and password for logging in to the compute node. Format: <username>@<hostname>:<password>. When the hostname is % or an empty string, it indicates that the authorized host is not limited.
provider:
type: # The authority provider type for storage node. The default value is ALL_PERMITTED.
Sample
ALL_PERMITTED
rules:
- !AUTHORITY
users:
- root@localhost:root
- my_user@:pwd
provider:
type: ALL_PERMITTED
The above configuration indicates:
- The user
root
can connect to Proxy only through localhost, and the password isroot
. - The user
my_user
can connect to Proxy through any host, and the password ispwd
. - The
provider
type isALL_PERMITTED
, which indicates that users are granted all authorities by default without authentication.
DATABASE_PERMITTED
rules:
- !AUTHORITY
users:
- root@localhost:root
- my_user@:pwd
provider:
type: DATABASE_PERMITTED
props:
user-database-mappings: root@localhost=sharding_db, root@localhost=test_db, my_user@=sharding_db
The above configuration indicates:
- The
provider
type isDATABASE_PERMITTED
, which indicates that users are granted database-level authority and configuration is needed. - The user
root
can connect to Proxy only through localhost and can accesssharding_db
andtest_db
. - The user
my_user
can connect to Proxy through any host and can accesssharding_db
.
Related References
Please refer to Authority Provider for specific implementation of authority provider.
当前内容版权归 ShardingSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ShardingSphere .