authz: add QAuthZList object type for an access control list
Add a QAuthZList object type that implements the QAuthZ interface. This
built-in implementation maintains a trivial access control list with a
sequence of match rules and a final default policy. This replicates the
functionality currently provided by the qemu_acl module.
To create an instance of this object via the QMP monitor, the syntax
used would be:
{
"execute": "object-add",
"arguments": {
"qom-type": "authz-list",
"id": "authz0",
"props": {
"rules": [
{ "match": "fred", "policy": "allow", "format": "exact" },
{ "match": "bob", "policy": "allow", "format": "exact" },
{ "match": "danb", "policy": "deny", "format": "glob" },
{ "match": "dan*", "policy": "allow", "format": "exact" },
],
"policy": "deny"
}
}
}
This sets up an authorization rule that allows 'fred', 'bob' and anyone
whose name starts with 'dan', except for 'danb'. Everyone unmatched is
denied.
It is not currently possible to create this via -object, since there is
no syntax supported to specify non-scalar properties for objects. This
is likely to be addressed by later support for using JSON with -object,
or an equivalent approach.
In any case the future "authz-listfile" object can be used from the
CLI and is likely a better choice, as it allows the ACL to be refreshed
automatically on change.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-10-21 15:54:59 +02:00
|
|
|
# -*- Mode: Python -*-
|
2020-07-29 20:50:24 +02:00
|
|
|
# vim: filetype=python
|
2020-11-02 09:15:50 +01:00
|
|
|
|
|
|
|
##
|
|
|
|
# = User authorization
|
|
|
|
##
|
authz: add QAuthZList object type for an access control list
Add a QAuthZList object type that implements the QAuthZ interface. This
built-in implementation maintains a trivial access control list with a
sequence of match rules and a final default policy. This replicates the
functionality currently provided by the qemu_acl module.
To create an instance of this object via the QMP monitor, the syntax
used would be:
{
"execute": "object-add",
"arguments": {
"qom-type": "authz-list",
"id": "authz0",
"props": {
"rules": [
{ "match": "fred", "policy": "allow", "format": "exact" },
{ "match": "bob", "policy": "allow", "format": "exact" },
{ "match": "danb", "policy": "deny", "format": "glob" },
{ "match": "dan*", "policy": "allow", "format": "exact" },
],
"policy": "deny"
}
}
}
This sets up an authorization rule that allows 'fred', 'bob' and anyone
whose name starts with 'dan', except for 'danb'. Everyone unmatched is
denied.
It is not currently possible to create this via -object, since there is
no syntax supported to specify non-scalar properties for objects. This
is likely to be addressed by later support for using JSON with -object,
or an equivalent approach.
In any case the future "authz-listfile" object can be used from the
CLI and is likely a better choice, as it allows the ACL to be refreshed
automatically on change.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-10-21 15:54:59 +02:00
|
|
|
|
|
|
|
##
|
|
|
|
# @QAuthZListPolicy:
|
|
|
|
#
|
|
|
|
# The authorization policy result
|
|
|
|
#
|
|
|
|
# @deny: deny access
|
|
|
|
# @allow: allow access
|
|
|
|
#
|
|
|
|
# Since: 4.0
|
|
|
|
##
|
|
|
|
{ 'enum': 'QAuthZListPolicy',
|
|
|
|
'prefix': 'QAUTHZ_LIST_POLICY',
|
|
|
|
'data': ['deny', 'allow']}
|
|
|
|
|
|
|
|
##
|
|
|
|
# @QAuthZListFormat:
|
|
|
|
#
|
|
|
|
# The authorization policy match format
|
|
|
|
#
|
|
|
|
# @exact: an exact string match
|
|
|
|
# @glob: string with ? and * shell wildcard support
|
|
|
|
#
|
|
|
|
# Since: 4.0
|
|
|
|
##
|
|
|
|
{ 'enum': 'QAuthZListFormat',
|
|
|
|
'prefix': 'QAUTHZ_LIST_FORMAT',
|
|
|
|
'data': ['exact', 'glob']}
|
|
|
|
|
|
|
|
##
|
|
|
|
# @QAuthZListRule:
|
|
|
|
#
|
|
|
|
# A single authorization rule.
|
|
|
|
#
|
|
|
|
# @match: a string or glob to match against a user identity
|
|
|
|
# @policy: the result to return if @match evaluates to true
|
|
|
|
# @format: the format of the @match rule (default 'exact')
|
|
|
|
#
|
|
|
|
# Since: 4.0
|
|
|
|
##
|
|
|
|
{ 'struct': 'QAuthZListRule',
|
|
|
|
'data': {'match': 'str',
|
|
|
|
'policy': 'QAuthZListPolicy',
|
|
|
|
'*format': 'QAuthZListFormat'}}
|
|
|
|
|
|
|
|
##
|
2020-10-20 12:47:58 +02:00
|
|
|
# @AuthZListProperties:
|
authz: add QAuthZList object type for an access control list
Add a QAuthZList object type that implements the QAuthZ interface. This
built-in implementation maintains a trivial access control list with a
sequence of match rules and a final default policy. This replicates the
functionality currently provided by the qemu_acl module.
To create an instance of this object via the QMP monitor, the syntax
used would be:
{
"execute": "object-add",
"arguments": {
"qom-type": "authz-list",
"id": "authz0",
"props": {
"rules": [
{ "match": "fred", "policy": "allow", "format": "exact" },
{ "match": "bob", "policy": "allow", "format": "exact" },
{ "match": "danb", "policy": "deny", "format": "glob" },
{ "match": "dan*", "policy": "allow", "format": "exact" },
],
"policy": "deny"
}
}
}
This sets up an authorization rule that allows 'fred', 'bob' and anyone
whose name starts with 'dan', except for 'danb'. Everyone unmatched is
denied.
It is not currently possible to create this via -object, since there is
no syntax supported to specify non-scalar properties for objects. This
is likely to be addressed by later support for using JSON with -object,
or an equivalent approach.
In any case the future "authz-listfile" object can be used from the
CLI and is likely a better choice, as it allows the ACL to be refreshed
automatically on change.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-10-21 15:54:59 +02:00
|
|
|
#
|
2020-10-20 12:47:58 +02:00
|
|
|
# Properties for authz-list objects.
|
|
|
|
#
|
|
|
|
# @policy: Default policy to apply when no rule matches (default: deny)
|
|
|
|
#
|
|
|
|
# @rules: Authorization rules based on matching user
|
|
|
|
#
|
|
|
|
# Since: 4.0
|
|
|
|
##
|
|
|
|
{ 'struct': 'AuthZListProperties',
|
|
|
|
'data': { '*policy': 'QAuthZListPolicy',
|
|
|
|
'*rules': ['QAuthZListRule'] } }
|
|
|
|
|
|
|
|
##
|
|
|
|
# @AuthZListFileProperties:
|
|
|
|
#
|
|
|
|
# Properties for authz-listfile objects.
|
|
|
|
#
|
|
|
|
# @filename: File name to load the configuration from. The file must
|
|
|
|
# contain valid JSON for AuthZListProperties.
|
|
|
|
#
|
|
|
|
# @refresh: If true, inotify is used to monitor the file, automatically
|
|
|
|
# reloading changes. If an error occurs during reloading, all
|
|
|
|
# authorizations will fail until the file is next successfully
|
|
|
|
# loaded. (default: true if the binary was built with
|
|
|
|
# CONFIG_INOTIFY1, false otherwise)
|
|
|
|
#
|
|
|
|
# Since: 4.0
|
|
|
|
##
|
|
|
|
{ 'struct': 'AuthZListFileProperties',
|
|
|
|
'data': { 'filename': 'str',
|
|
|
|
'*refresh': 'bool' } }
|
|
|
|
|
|
|
|
##
|
|
|
|
# @AuthZPAMProperties:
|
|
|
|
#
|
|
|
|
# Properties for authz-pam objects.
|
|
|
|
#
|
|
|
|
# @service: PAM service name to use for authorization
|
|
|
|
#
|
|
|
|
# Since: 4.0
|
|
|
|
##
|
|
|
|
{ 'struct': 'AuthZPAMProperties',
|
|
|
|
'data': { 'service': 'str' } }
|
|
|
|
|
|
|
|
##
|
|
|
|
# @AuthZSimpleProperties:
|
|
|
|
#
|
|
|
|
# Properties for authz-simple objects.
|
|
|
|
#
|
|
|
|
# @identity: Identifies the allowed user. Its format depends on the network
|
|
|
|
# service that authorization object is associated with. For
|
|
|
|
# authorizing based on TLS x509 certificates, the identity must be
|
|
|
|
# the x509 distinguished name.
|
authz: add QAuthZList object type for an access control list
Add a QAuthZList object type that implements the QAuthZ interface. This
built-in implementation maintains a trivial access control list with a
sequence of match rules and a final default policy. This replicates the
functionality currently provided by the qemu_acl module.
To create an instance of this object via the QMP monitor, the syntax
used would be:
{
"execute": "object-add",
"arguments": {
"qom-type": "authz-list",
"id": "authz0",
"props": {
"rules": [
{ "match": "fred", "policy": "allow", "format": "exact" },
{ "match": "bob", "policy": "allow", "format": "exact" },
{ "match": "danb", "policy": "deny", "format": "glob" },
{ "match": "dan*", "policy": "allow", "format": "exact" },
],
"policy": "deny"
}
}
}
This sets up an authorization rule that allows 'fred', 'bob' and anyone
whose name starts with 'dan', except for 'danb'. Everyone unmatched is
denied.
It is not currently possible to create this via -object, since there is
no syntax supported to specify non-scalar properties for objects. This
is likely to be addressed by later support for using JSON with -object,
or an equivalent approach.
In any case the future "authz-listfile" object can be used from the
CLI and is likely a better choice, as it allows the ACL to be refreshed
automatically on change.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-10-21 15:54:59 +02:00
|
|
|
#
|
|
|
|
# Since: 4.0
|
|
|
|
##
|
2020-10-20 12:47:58 +02:00
|
|
|
{ 'struct': 'AuthZSimpleProperties',
|
|
|
|
'data': { 'identity': 'str' } }
|