5
0
mirror of git://git.proxmox.com/git/pve-access-control.git synced 2025-01-20 14:03:43 +03:00

638 Commits

Author SHA1 Message Date
Alexandre Derumier
b920d59c7a api2: AccessControl: add sdn permissions.modify
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2020-06-15 15:35:03 +02:00
Thomas Lamprecht
a1281512d0 comput coarse UI permissions: also check SDN ones
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-06-09 11:43:51 +02:00
Thomas Lamprecht
e6624f504b bump version to 6.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-08 17:47:50 +02:00
Dominik Csapak
de8c5e6ceb LDAP: skip anonymous bind when clientcert/key is given
It seems that servers associate the client-cert/key with an account, so
doing an explicit anonymous bind then 'logs out' the already verified
user, limiting the search results in some cases

before refactoring to PVE::LDAP, we did not do '$ldap->bind' at all when
there was no bind_dn, but it is not really clear if Net::LDAP does this
automatically when searching (other libraries do this), so leave the
anonymous bind (for compatibility with PMG) but skip it when a client
certificate and key is given.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-05-08 13:35:18 +02:00
Thomas Lamprecht
eeabad5a13 ldap_delete_credentials: don't complain if already deleted
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-08 09:38:34 +02:00
Tim Marx
30dd4869b5 whitespace cleanup
Signed-off-by: Tim Marx <t.marx@proxmox.com>
2020-05-06 16:41:43 +02:00
Thomas Lamprecht
618d112b74 pveum: add 'tfa delete' subcommand for deleting user-TFA
Allows a user to straight forward delete TFS over CLI, easier as
telling them to edit some config files, and the API is already there.

Short circuit most params of that API call to undef, as they do not
make sense to expose.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-03 16:40:05 +02:00
Thomas Lamprecht
8f4a522f4f bump version to 6.0-7
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-25 19:35:20 +02:00
Thomas Lamprecht
417309d71c domains: dry-run: adapt log messages and improve variable name
keep variable names aligned with the params the relate to, "write"
was quite ambiguous too (write what?)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-25 19:06:24 +02:00
Thomas Lamprecht
6c42a1034b parse_sync_opts: code cleanup
avoid confusion between fmt default and cfg default

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-25 18:54:46 +02:00
Dominik Csapak
38691d98c8 domain sync: add 'dry-run' parameter
this can be used to test the resulting config before actually changing
anything

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-25 18:31:35 +02:00
Dominik Csapak
72a9742b94 auth ldap/ad: introduce connection 'mode'
instead of having only a 'secure' flag which switches between
ldap/ldaps we now have a mode which also contains 'ldap+starttls'

our connection code in PVE::LDAP can handle this already (used in pmg)
so that is no problem

if we want to really remove the 'secure' flag, e.g. in 7.0
we'd either have to rewrite the config or have it as an error
in a pve6to7 script

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-25 18:31:35 +02:00
Dominik Csapak
055c54b5a2 domain sync: make options actually required
we want the api options to be optional, but only as long as there are
default values set in the realm config

since they are all marked as optional (else they would be required in
the api) this check did not work as intended

instead, set the result to the value of:
* the parameter
* the set default in the config
* the api default
in this order

if it is undef after this, raise a parameter exception

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-25 18:31:35 +02:00
Dominik Csapak
782b702dbb auth ldap/ad: make password a parameter for the api
Allows us to add it in the gui, until now the admin needed to create
the file themself.

Mirrored after credential handling from CIFS and PBS in their
pve-storage plugins

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
[Thomas: don't differ from storage one unnecessarily, keep comments
 and behavior]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-18 18:48:28 +02:00
Thomas Lamprecht
89338e4d9c api/domain: add on add/update/delete hooks
Almost 1:1 taken from pve-storage ones

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-18 18:48:05 +02:00
Thomas Lamprecht
77bfb48e0d token create: return also full token id for convenience
makes creating a client for this slightly nicer, as it doesn't needs
to be as state full.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-15 20:41:39 +02:00
Thomas Lamprecht
067d625ab2 buildsys: fix getting the build commit
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-15 20:04:54 +02:00
Thomas Lamprecht
856c101e97 token: avoid undef warning if no tokens are configured
Initially the config may not even exist, and so the first token
create would give one then a ugly warning like:
> Use of uninitialized value $raw in split at ..

Handle that case, empty config (where we get '') was fine already, so
explicitly check for definedness, not truthiness.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-15 17:14:01 +02:00
Dominik Csapak
0ae051a4d6 auth ad: add sync-defaults-options
this was missing for AD realms

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-06 13:52:55 +02:00
Thomas Lamprecht
8d400e7ece d/control: bump versioned to libpve-common-perl
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-21 16:51:06 +01:00
Thomas Lamprecht
b49abe2d25 split and sort some module use
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-21 16:21:57 +01:00
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