vault/helper
Steven Clark b7dff9777d
Allow backends to extract credentials from payloads and trigger an authentication workflow (#23924)
* wip

* Work on the tuneable allowance and some bugs

* Call handleCancellableRequest instead, which gets the audit order more correct and includes the preauth response

* Get rid of no longer needed operation

* Phew, this wasn't necessary

* Add auth error handling by the backend, and fix a bug with handleInvalidCredentials

* Cleanup req/resp naming

* Use the new form, and data

* Discovered that tokens werent really being checked because isLoginRequest returns true for the re-request into the backend, when it shouldnt

* Add a few more checks in the delegated request handler for bad inputs

 - Protect the delegated handler from bad inputs from the backend such
   as an empty accessor, a path that isn't registered as a login request
 - Add similar protections for bad auth results as we do in the normal
   login request paths. Technically not 100% needed but if somehow the
   handleCancelableRequest doesn't use the handleLoginRequest code path
   we could get into trouble in the future
 - Add delegated-auth-accessors flag to the secrets tune command and
   api-docs

* Unit tests and some small fixes

* Remove transit preauth test, rely on unit tests

* Cleanup and add a little more commentary in tests

* Fix typos, add another failure use-case which we reference a disabled auth mount

* PR Feedback

 - Use router to lookup mount instead of defining a new lookup method
 - Enforce auth table types and namespace when mount is found
 - Define a type alias for the handleInvalidCreds
 - Fix typos/grammar
 - Clean up globals in test

* Additional PR feedback

 - Add test for delegated auth handler
 - Force batch token usage
 - Add a test to validate failures if a non-batch token is used
 - Check for Data member being nil in test cases

* Update failure error message around requiring batch tokens

* Trap MFA requests

* Reword some error messages

* Add test and fixes for delegated response wrapping

* Move MFA test to dedicated mount

 - If the delegated auth tests were running in parallel, the MFA test
   case might influence the other tests, so move the MFA to a dedicated
   mount

* PR feedback: use textproto.CanonicalMIMEHeaderKey

 - Change the X-Vault-Wrap-Ttl constant to X-Vault-Wrap-TTL
   and use textproto.CanonicalMIMEHeaderKey to format it
   within the delete call.
 - This protects the code around changes of the constant typing

* PR feedback

 - Append Error to RequestDelegatedAuth
 - Force error interface impl through explicit nil var assignment on
   RequestDelegatedAuthError
 - Clean up test factory and leverage NewTestSoloCluster
 - Leverage newer maps.Clone as this is 1.16 only

---------

Co-authored-by: Scott G. Miller <smiller@hashicorp.com>
2023-11-21 14:36:49 -05:00
..
benchhelpers [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
builtinplugins Relplat 897 copywrite fixes for mutliple licenses (#23722) 2023-10-20 08:40:43 -07:00
constants [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
dhutil [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
experiments - removed secrets sync experimental flag to prepare the release on Vault ENT (#22816) 2023-09-11 07:40:50 -04:00
fairshare add stopped method to JobManager (#23950) 2023-11-07 09:15:43 -08:00
flag-kv [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
flag-slice [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
forwarding Improve Robustness of Custom Context Values Types (#23697) 2023-10-18 09:30:00 -04:00
hostutil [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
identity [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
locking [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
logging Revert "Automatically track subloggers in allLoggers (#22038)" (#23986) 2023-11-03 11:08:01 -07:00
metricsutil [VAULT-17826] Remove mount point from rollback metrics (#22400) 2023-08-21 16:55:37 +02:00
monitor [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
namespace [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
osutil [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
parseip [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
pgpkeys [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
policies [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
proxyutil [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
random [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
storagepacker [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
syncmap [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
testhelpers Allow backends to extract credentials from payloads and trigger an authentication workflow (#23924) 2023-11-21 14:36:49 -05:00
timeutil [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
useragent [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
versions [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00