Commit Graph

367 Commits

Author SHA1 Message Date
Thomas Lamprecht
d29d2d4a11 realm: add default-sync-options to config
This allows us to have a convenient way to set the desired default
sync options, and thus not forcing users to pass always all options
when they want to trigger a sync.

We still die when an option is neither specified in the domains
(realm) config nor as API/CLI parameter.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-21 16:21:57 +01:00
Thomas Lamprecht
415179b03a api: realm sync: move out group and user update to separate methods
keep the api call way smaller and clearer

On moving out some minor adaptions where made, e.g., we do not print
"remove user X" if we know that we'd add it again, but just print a
single "update user X" for that. Same for groups.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-21 16:21:57 +01:00
Thomas Lamprecht
6a2138e4d6 api: realm sync: use auth-realm-sync as worker id
we may potentially also sync something else over this in the future,
for example PAM users from a specific group, so use a more general
	name.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-21 16:11:48 +01:00
Thomas Lamprecht
cf109814a8 api: realm sync: cleanup code and refactor
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-21 16:11:48 +01:00
Dominik Csapak
5654260eab do not modify ACLs/Groups for missing users
instead of dropping ACLs and group membership for missing users,
simply warn and leave it in the config

for users that get removed via the api this happens explicitely

this is to prevent that a 'faulty' ldapsync removes users temporarily
and with it all acls that the admin created

we still have a 'purge' flag for the sync where ACLs get removed
explicitly for users removed from ldap

also adapt the tests

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-21 16:05:38 +01:00
Dominik Csapak
673d2bf267 api: domains: add user/group sync API enpoint
this api call syncs the users and groups from LDAP/AD to the
user.cfg

it also implements a 'full' mode where we first delete all
users/groups from the config and sync them again

the parameter 'enable' controls if newly synced users are 'enabled'
(if no sync parameter handles that)
the parameter 'purge' controls if ACLs get removed for users/groups
that do not exists anymore after

also add this command to pveum

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-21 16:05:15 +01:00
Dominik Csapak
e65b53c6a9 Auth/AD: make PVE::Auth::AD a subclass of PVE::Auth::LDAP
this makes it much easier to reuse the sync code from LDAP in AD.
The 'authenticate_user' sub is still the same, but we now
can still use the get_users and get_groups functionality of LDAP

in the case of AD, the user_attr is optional in the config
(would have been a breaking change) but we set it
to default to 'sAMAccountName'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-21 15:44:46 +01:00
Dominik Csapak
2c6e956e0a Auth/LDAP: add get_{users, groups} subs for syncing
this adds the subs which actually query the LDAP for users/groups
and returns the value in format which makes it easy to insert
in our parsed user.cfg

when we find a user/groupname which cannot be in our config,
we warn the verification error

for groups, we append "-$realm" to the groupname, to lower the chance of
accidental overwriting of existing groups (this will be documented
in the api call since it technically does not prevent overwriting, just
makes it more unlikely)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-21 15:44:46 +01:00
Dominik Csapak
eba326d2df Auth/LDAP: add necessary options for syncing
for syncing users/groups from ldap, we need some more options
so that the users can adapt it to their LDAP setup, which are very
different accross systems.

sensible defaults are documented

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-21 15:44:22 +01:00
Thomas Lamprecht
c63e26c84e d/control: bump versioned dependency to pve-common
to ensure we've the new LDAP module available

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-07 19:53:07 +01:00
Dominik Csapak
30aad01788 Auth/LDAP: refactor out 'connect_and_bind'
we will use this not only for authentication but also for
getting users/groups from LDAP

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-07 19:50:22 +01:00
Dominik Csapak
f3c87f9b4e API2/Domains.pm: document 'type' return value
this way it gets printed with 'pveum realm list'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-07 19:50:22 +01:00
Dominik Csapak
32449f358e API2/Domains.pm: fix whitespace errors
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-07 19:50:22 +01:00
Dominik Csapak
f28a69a018 add realm commands to pveum
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-07 19:50:22 +01:00
Dominik Csapak
d9e93d2eca use PVE::LDAP module instead of useing Net::LDAP directly
for things like connecting/binding/etc.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-07 19:50:22 +01:00
Dominik Csapak
deb63acf3f fix #2575: die when trying to edit built-in roles
instead of silently ignoring the change

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-01-31 20:34:06 +01:00
Thomas Lamprecht
23059f3572 bump version to 6.0-6
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-01-29 21:21:59 +01:00
Thomas Lamprecht
cb97d469e9 d/control: bump versioned dependency on pve-common
for new allowtoken property in schema

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-01-29 21:21:59 +01:00
Thomas Lamprecht
82110d64f4 d/control: change homepage link to https
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-01-29 21:21:59 +01:00
Fabian Grünbichler
21f523a5c1 user.cfg: skip inexisting roles when parsing ACLs
we do the same for missing users, groups and tokens, and just like
groups, roles with an empty privilege set are explicitly allowed so
pre-generating placeholders is possible.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:59 +01:00
Fabian Grünbichler
66d1b61528 pveum: add permissions sub-commands
for user and token commands, and some pretty-printing for regular text
output, since the returned nested hash/dict is not very readable.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:59 +01:00
Thomas Lamprecht
ccaecac13f pveum token: rename 'update' subcommand to 'modify' for consistency
While the 1:1 mapping from API call names is not bad it was now the
unique "PUT" (modify) command having a different name here. Avoid
that for consistency.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-01-29 21:21:59 +01:00
Fabian Grünbichler
084c149a48 pveum: add 'pveum user token add/update/remove/list'
mapping 1-to-1 to the respective API paths

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:59 +01:00
Fabian Grünbichler
9449fe2138 tests: unify config file naming
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:58 +01:00
Fabian Grünbichler
891f7afa92 test: add token-related tests
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:58 +01:00
Fabian Grünbichler
c3fa8a3634 API: add 'permissions' API endpoint
and related helper, to dump permissions + propagate info for
- a specific, given path
- generic top-level + user.cfg-referenced paths, including pools

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:58 +01:00
Fabian Grünbichler
7e8bcaa754 roles()/permissions(): also return propagate flag
this information is already available, but not exposed. we need it for
dumping an effective permission tree of a given user/token.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:58 +01:00
Fabian Grünbichler
4937239091 api: disallow some paths for API tokens
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:58 +01:00
Fabian Grünbichler
e915e9e454 API token: implement permission checks
non-privsep tokens will always return the roles/permissions of their
associated users. privsep tokens will return unfiltered roles, but
filtered permissions.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:58 +01:00
Fabian Grünbichler
6b5736d572 API: include API tokens in ACL API endpoints
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:58 +01:00
Thomas Lamprecht
72c4589c33 api/users: mark tokens and groups as optional in return schema
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-01-29 21:21:58 +01:00
Fabian Grünbichler
3a4ed52781 API: add group and token info to user index
otherwise we need 1+N API calls to retrieve the full user+token picture

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 10:05:15 +01:00
Thomas Lamprecht
b974bdc09e api: document default of token expiration date
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-01-29 10:02:52 +01:00
Fabian Grünbichler
4e4c8d4069 API: add API token API endpoints
and integration for user API endpoints.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 09:35:44 +01:00
Thomas Lamprecht
77eaf7c6c8 d/control: bump versioned dependencies on pve-cluster
to ensure we've got the verify_token method available and the
token.cfg observed.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-01-28 21:10:45 +01:00
Fabian Grünbichler
35c3ca0fc8 API token: add verification method
which checks that the user and token exist and are not expired, and then
generates the string to be matched with the pmxcfs-stored token shadow
config file.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-28 20:59:49 +01:00
Fabian Grünbichler
3a540a697f API token: add (shadow) TokenConfig
with the format:

<full token ID> <token value/UUID>

it is just used for token value generation/deletion via the User API,
token value verification will happen over pmxcfs/ipcc.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-28 20:59:45 +01:00
Fabian Grünbichler
571e9d062e API token: add check_token_exist API helper
the helper is modeled after the corresponding user method.

the 'tokenid' option goes into PVE::AccessControl, since we need it in
multiple API modules.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-28 20:59:40 +01:00
Fabian Grünbichler
28e3dc05e2 API token: add REs, helpers, parsing + writing
token definitions/references in user.cfg always use the full form of the
token id, consisting of:

USER@REALM!TOKENID

token definitions are represented by their own lines prefixed with
'token', which need to come after the corresponding user definition, but
before any ACLs referencing them.

parsed representation in a user config hash is inside a new 'tokens'
element of the corresponding user object, using the unique-per-user
token id as key.

only token metadata is stored inside user.cfg / accessible via the
parsed user config hash. the actual token values will be stored
root-readable only in a separate (shadow) file.

'comment' and 'expire' have the same semantics as for users.

'privsep' determines whether an API token gets the full privileges of
the corresponding user, or just the intersection of privileges of the
corresponding user and those of the API token itself.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-28 20:59:36 +01:00
Fabian Grünbichler
4833388177 API: add group members to group index
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-28 20:56:55 +01:00
Fabian Grünbichler
7d1739ad60 test: add parser/writer tests
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-27 18:34:01 +01:00
Fabian Grünbichler
1516bfa0a6 fix typo
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-27 18:33:50 +01:00
Fabian Grünbichler
964e7e865f test: run at build time
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-27 18:33:38 +01:00
Fabian Grünbichler
9a12a08ce9 refactor acl transformation code
pull it into helper sub, since we need this one more time for token ACL
members.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-14 12:28:46 +01:00
Fabian Grünbichler
8e23f97156 auth: pull username REs into variables
for reusage in API token ID format/verification

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-14 12:28:13 +01:00
Fabian Grünbichler
a31f1d85f9 rpcenv: drop unused roles()
it was useful for test-cases to verify the behaviour when pools where
introduced, but it is not used anywhere else in the code base and those
tests can also just check on permission-level.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-14 12:24:04 +01:00
Thomas Lamprecht
3443faca75 grammar fix: s/does not exists/does not exist/g
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-12-13 12:01:22 +01:00
Thomas Lamprecht
3dd692e9cb bump version to 6.0-5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-26 17:56:42 +01:00
Alexandre Derumier
406726718e add SDN.Allocate && SDN.Audit privileges
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2019-11-26 16:49:47 +01:00
Fabian Grünbichler
9efcb56129 access-control: remove check_permissions/permission
they have been handled by PVE::RPCEnvironment for quite some time
already, and the versions there are the complete ones that should be
actually used.

manager switched over their last use not long ago, in 6.0-9, so
record a Breaks to that version.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-11-23 18:12:50 +01:00