Commit graph

46 commits

Author SHA1 Message Date
jeanluc
f2121e5ade
Rewrite vault core, issue AppRoles to minions (#62684)
* Rewrite vault core, orchestrate AppRoles for minions

This commit represents a fundamental rewrite in how Salt interacts with
Vault. The master should still be compatible with minions running the
old code. There should be no breaking changes to public interfaces and
the old configuration format should still apply.

Core:
- Issue AppRoles to minions
- Manage entities with templatable metadata for minions
- Use inbuilt Salt cache
- Separate config cache from token cache
- Cache: introduce connection-scope vs global scope

Utility module:
- Support being imported (__utils__ deprecation)
- Raise exceptions on queries to simplify response handling
- Add classes to wrap complexity, especially regarding KV v2
- Lay some groundwork for renewing tokens

Execution module:
- Add patch_secret
- Add version support to delete_secret
- Allow returning listed keys only in list_secret
- Add policy_[fetch/write/delete] and policies_list
- Add query for arbitrary API queries

State module:
- Make use of execution module
- Change output format

Docs:
- Update for new configuration format
- Correct examples
- Add configuration examples
- Add required policies

* Fix linting for rewritten vault integration

* Add pytest unit tests for utils.vault, fix found issues

* Fix old vault runner tests

* Rewrite vault sdb tests, migrate to pytests

* Adapt vault ext_pillar tests

* Adapt vault execution module tests, migrate to pytests

* Add more vault execution module unit tests

* Support python <3.7 (vault util), time-independent tests

* Add/migrate vault runner unit tests (pytest)

* Add vault state module pytests

* Fix tests lint

* Refactor Vault container fixture, move to session scope

* Fix for existing vault execution/sdb module integration tests

* Improve existing vault runner integration tests

* Fix vault test support, add list policies

* Add more functional execution module tests, fix deprecated warning

* Refactor vault pytest support

* Add integration tests, improve/fix caching/issue_params

* Improve caching behavior, fix tests

* Always use session cache as well
* Also flush session cache when requested
* Make KV metadata caching behavior configurable
* Update tests to account for changes from prev commit

* Allow to autodiscover platform default CA bundle

* Remove runner approle param overrides

There is no simple way to ensure they are kept.

* Add clear_cache runner function

* Also manage token metadata for issued secret IDs

* Cleanup tests

* Cleanup code, pylint logging suggestions

* Do not always invalidate config when verify=default

* Ensure concatted metadata lists are sorted

* Add changelog (partly)

* Work with legacy peer_run configuration as well

* Consume a token use regardless of status code

* Correct verify semantics

* Refine token uses handling, add changelog/tests for old issues

* Add changelog for main features

* Add test for issue 58580

* Fix vault docs

* Provide all old make_request functionality, add tests

* Allow token use override, add docstrings to query funcs

* Simplify config_location merge

* Cleanup

* Fix make_request warning

* Attempt to fix memory issues during CI test run

* Increase documented version

* Improve lease handling

* Refine lease ttl handling/add token lifecycle management

* Fix docs build

* Adapt formatting

* assert what you get against what you expect
* drop empty parentheses after wrapper
* use `is` to compare against strictly boolean vars

* Fix issue param overrides

* during pillar rendering, they were always reset by the master (for
  AppRoles)
* overrides were only respected for some settings (AppRoles)
* old config syntax was using the old syntax internally (tech debt)

* Introduce session-scoped cache

* Tokens with a single use left are unrenewable

* Allow override of flushing of cached leases during lookup

* Refactor cache classes, save lease data

* Rename session token cache key

* Add lease management utility

* Fix runner integration tests

after renaming the token cache key

* Do not overwrite data of cached leases after renewal

* Pass token_lifecycle to minions

* Do not fail syncing multiple approles/entities with pillar templates

* Ensure config cache expiration can be disabled

* Rename changelog files (.md)

* Declare vaultpolicylexer as parallel read safe

* Correct meta[data] payload key

For tokens it is `meta`, but for secret IDs, `metadata`.

* Reuse TCP connection

* Refactor utils module

* Ensure client is recreated after clearing cache

* Always use unwrap_client config as expected server

This should fix the test failure in the runner integration test
TestAppRoleIssuance::test_server_switch_does_not_break_minion_auth

* Ensure client is recreated after clearing cache 2

* Simulate patch for KV v1 or missing `patch` capability

* Add `patch` option to Vault SDB driver

* Reduce lease validity when revocation fails

* Extract AppRole/Identity API from runner into utils

* Revoke tokens, fire events, improve cache/exception handling

* Tokens (and therefore associated leases) are revoked when cleared by default
* It's possible to disable clearing cache when a perfectly valid token
  is available, but a PermissionDeniedError is encountered.
* UnwrapExceptions always cause an event to be fired
* It's possible to enable sending of events when
    a) cache is cleared
    b) a lease is requested from cache, but it is/will be invalid
* A VaultAuthException does not immediately lead to clearing
  the connection cache
* get_authd_client and others: multiple small enhancements and fixes

* Allow updating cached config w/o closing session

* Homogenize funcs, update docs, cleanup

* Minor internal fixes

`is_valid_for` is present on all lease-like objects, while `is_valid`
specifically should account for more, e.g. the number of uses.

The Vault API does not return 404 when a lookup fails.

* Add release note

* Address review remarks

* Fix release notes

* Remove loading minion_mods from factory

* Address other review remarks

* Add inline specification of trusted CA root cert

* Small QoL additions

* Fix lint

* Fix lint for Python >=3.8 support

* Add missing fixes

* Fix unit tests

In some cases, the `spec` calls were failing because the underlying
object was already patched

---------

Co-authored-by: Thomas Phipps <tphipps@vmware.com>
2023-12-15 21:42:08 -07:00
Pedro Algarvio
442cadbd37 Remove code and references to the disabled Sphinx extension shorturls
It has been disabled since 2018.3.4

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2023-02-28 07:40:38 +00:00
Pedro Algarvio
c4beeb8fb9 Fix doc builds
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2023-02-18 17:38:23 +00:00
Pedro Algarvio
a3b5e63a78 Mark the saltdomain Sphinx extension as safe for parallelization.
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2023-02-18 17:38:23 +00:00
Pedro Algarvio
4d49013247 Update to isort 5.10.1
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2022-08-01 12:49:16 -06:00
Pedro Algarvio
f2a783643d Update to latest `pyupgrade` hook. Stop skipping it on CI.
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2022-01-26 15:18:32 -08:00
Bryce Larson
d6b809ec88 change docs.saltstack.com to docs.saltproject.io everywhere 2021-09-09 15:30:03 -07:00
Pedro Algarvio
76e50885b0 Fix strings 2021-08-06 13:09:47 -07:00
Pedro Algarvio
6abb43d2df Upgrade to black 21.7b0 2021-08-06 13:09:47 -07:00
Shubhendra Singh Chauhan
a112a2479c
Fix: code quality issues (#59385)
* Fixed code quality issues using DeepSource

* Removed redundant call

* Removed unnecessary import alias

* Removed unused imports

* Removed duplicate elements during set declaration

* Delete .deepsource.toml

* Update vmctl.py

* Update vmctl.py

* Update vmctl.py
2021-02-16 12:51:45 -05:00
Blacken Salt
0b2a5613b3
Blacken salt 2020-04-03 13:05:41 -05:00
Pedro Algarvio
14bde12b9d
Fill in the configurable branch at build time 2019-10-25 18:28:53 +01:00
Daniel Wozniak
9ac2604d40
Merge pull request #54555 from garethgreenaway/2019_2_1_port_52948
[master] Porting #52948 to master
2019-10-03 15:26:51 -07:00
Gareth J. Greenaway
a0718b36e5
Porting PR #52752 to 2019.2.1 2019-09-18 16:49:11 -07:00
Gareth J. Greenaway
f7b8984b4e
Porting PR #52948 to 2019.2.1 2019-09-18 16:46:53 -07:00
Erik Johnson
c34690e509
Don't import obsolete Directive class from Sphinx
Directive was apparently removed from Sphinx and made part of docutils.
For some reason, in this saltdomain extension, we were importing both
from docutils and sphinx. This worked well enough while Directive was
still only deprecated, but it appears to recently have been removed,
meaning that it now just causes an ImportError.

This commit removes the redundant import.
2018-11-12 14:54:38 -06:00
Erik Johnson
93ee5ee2b0
Fix all Sphinx warnings
Well, all but one, which we expect to see
2018-05-31 15:28:25 -05:00
Erik Johnson
6d7803ece0
Fix docs build on Sphinx 1.7+
Sphinx 1.7 got rid of sphinx.utils.compat. This commit allows the builds
to work both on both older and newer Sphinx.
2018-05-03 13:31:34 -05:00
Mircea Ulinic
fd28d3385c Adding Jinja cross ref 2017-06-19 09:49:45 +00:00
Mircea Ulinic
240178d241 Add conf_proxy cross reference 2017-03-28 18:24:02 +03:00
Mike Place
fdbf01d5ad Remove docs mocks for msgpack and psutils
Also make docs build py3 compat
2016-08-24 22:55:11 +09:00
Felix Dreissig
0869680435 Fix custom Sphinx formatter for aliased functions
Regression of @99bcf20: Since Sphinx 1.2.1 (commit
sphinx-doc/sphinx@574a796), sphinx.ext.autosummary overwrites custom-set
documenters.
This is not a particularly elegant solution, but none of the events from
sphinx.ext.autodoc allows editing a function's name. Subclassing other
autodoc classes also appears to be quite challenging.
2015-03-29 01:08:26 +01:00
Seth House
d4f64e8d5d Disable the 'routing table' index from the httpdomain
While very cool and quite handy, it doesn't make sense for how we use
netapi modules in Salt.
2014-06-19 13:13:09 -06:00
Seth House
7b6544c660 Added httpdomain from Sphinx-contrib 2014-06-18 22:14:17 -06:00
Pedro Algarvio
4d7ca91424 Remove unnecessary ©️ and :license: from file headers 2014-05-26 19:26:15 +01:00
Joseph Hall
84efdcff1c Merge pull request #13024 from richierichrawr/develop
Update copyright
2014-05-25 06:30:26 -06:00
richierichrawr
ff27a48f3a Update copyright
2013-2014
2014-05-25 02:40:41 -04:00
richierichrawr
d4be297d2e Update copyright
Expired year
2014-05-24 22:40:10 -04:00
Seth House
3515804fe6 Added directive for Salt events 2014-04-29 21:43:12 -06:00
Seth House
bcb66f160f Add Sphinx extension to generate an index for short-URLs 2014-04-15 18:01:31 -06:00
Seth House
35d4b67fca Output warning if file cannot be found 2013-12-23 06:42:04 -07:00
Seth House
9f7fab6df0 Moved LiterateCoding directives into Salt domain 2013-12-23 06:02:12 -07:00
Seth House
7be2045a63 Subclass to specifically handle documenting SLS files 2013-12-23 06:02:12 -07:00
Seth House
ddb438c711 Move helper functions into the class to allow future customization 2013-12-23 06:02:12 -07:00
Seth House
034f35b93f Extended Sphinx domain with formula directives and roles 2013-12-23 06:02:12 -07:00
Seth House
427bb75510 Wrap the literate-coding elements in a container
Needed for the necessary left-right styling.
2013-12-23 06:02:11 -07:00
Seth House
5f8df81d37 Added first stab at a literate-code style documentation directive 2013-12-23 06:02:11 -07:00
Seth House
cb8ed95992 Moved custom conf cross-references into Salt domain file 2013-12-13 22:45:48 -07:00
Seth House
c0f74f95aa Added minor Salt Sphinx domain 2013-12-13 22:45:48 -07:00
Seth House
d158fbefd4 Changed conf-log to conf_log to match the other conf_* roles
@s0undt3ch Hope you don't mind.
2013-12-13 17:34:59 -07:00
Seth House
48f79b1508 Recombinated the combobulator
Shh! No one tell @thatch45 that these have been in the repo for 2.5 years.
2013-12-13 17:34:59 -07:00
Mathieu Le Marec - Pasquet
5f46962e80 pep8 fixes 2013-12-04 00:25:50 +00:00
Pedro Algarvio
99bcf207d0 Properly render aliased salt function names. Fixes #7885. 2013-10-16 22:52:56 +01:00
Seth House
93834f5b4c Stole the youtube directive from sphinx-contrib 2013-09-17 17:56:56 -06:00
Pedro Algarvio
0cdfabf24c Allow the conf-log role to link to the logging documentation. 2013-08-30 19:32:40 +00:00
Seth House
20f18681bd Added initial Sphinx documentation
This commit moves the existing wiki pages on Github into rST with only
minor edits, formatting, and hyperlinking.
2011-05-27 06:27:42 +08:00