Commit Graph
267 Commits
Author SHA1 Message Date
8a36517126 Error handling fixes and improvements (#464)
Fixes:
* Just use the token we have if we would ideally refresh before expiration but don't have a refresh token.
* Don't hide useful OpenID Connect error details (such as self-signed cert rejected instead of just request failed). (fixes #427)
* Lagosta fixes from branch issue-379-handle-connection-issues commit 58f5ccc7 (relates to #442).

Functional improvements:
* Return or log less in some error scenarios (#419).
* Upgrade to Oso 0.11.2 to get a MUCH better error report when a ?= query in a .polar file fails, plus the Mutex around Oso is no longer needed.
* Log when OIDC discovery completes successfully.
* Be cautious, just log connection issues to the OpenID Connect provider for now, don't retry discovery.
* Use a lower timeout for the OpenID Connect HTTP client than the normal Krill HTTP client.
* Log more cause chains where available.

Code quality improvements:
* Apply review feddback: unwrap locks and crash out via panic to be consistent with the rest of Krill.
* Factor out the repeated RAII guard handling.
* Split login() out into helper methods.
* Removed TODO comment.

Testing improvements:
* Removed left-behind debug screenshot.
* Add a test to show a bug whereby access is wrongly denied if a token is pending expiration and has no refresh token. 
* Add a test to make sure Krill handles timeout of requests to the OIDC provider correctly. Also adds support for a lower timeout in test mode ala how it's done elsewhere in Krill, and more faithfully replicates the normal Krill HTTP client configuration when configuring the OIDC HTTP client. Also factored the OIDC HTTP client code out as it is getting too large to live in provider.rs.
* Extend the OpenID Connect provider not available test to show that Krill copes with the provider being unavailable and coming back to life again.
* Re-worked the test/mock relationship so that the mock no longer has hard-coded users and username based behaviour activation but rather now the test sets the desired behaviour and is thus easier to understand and more flexible.
* Extended the OpenID Connect mock so that its endpoints can be disabled and enabled during tests, and be disabled before Krill even does initial discovery.
* Use example.com based bad ACR ID token.
* Remove support for the NoResponse mock failure mode as it blocks the tiny http server thread indefinitely also preventing a test using it from exiting, and adds little no perceived benefit over the SlowResponse failure mode (which does at least stop blocking within the expected test run time).
* The mock OpenID Connect provider must be shutdown before the UI test result is asserted, otherwise the test process never terminates.
* Use the expected OpenID Connect provider timeout when in test mode.
* Extend the openid connect test to test the 'hybrid' user attributes case.
* Give the login more time to complete before expiring the access token. (#466).
* Wait for the right backend status BEFORE clicking the ROAs tab. (#465)

Other:
* OpenID Connect log message consistency tweaks.
* Sync with updated correspoinding Lagosta branch commit d2a92fe1 with latest Lagosta master merged in and a yarn build empty catch block fix.
* Sync with commit b9a2f5b3 in the corresponding PR branch in Lagosta to get a testbed REST API client fix.

Co-authored-by: Tim Bruijnzeels <tim@nlnetlabs.nl>
2021-04-13 12:13:18 +02:00
7cb5674033 Stabilize API and CLI (#330 and #360)
* Move child_request API endpoint for conststency. (#330)
* Move get RFC 8183 Publisher Request API endpoints (#330)
* Accept XML and json to add/update parent on same endpoints (#330)
* Simplify the JSON to add a child and remove unused fields. (#330)
* Update path to child_request in openapi spec.
* Update path to publisher request.
* Update api spec and documentation.
* Fix update parent API documentation and call by CLI.
* CLI stability
* Update pubd OpenAPI spec t o match changes made to the Krill API.
* Update the e2e test client code to submit only the id_cert and not the whole RFC8183 request, as required by changes made to the Krill API.

Co-authored-by: Ximon Eighteen <3304436+ximon18@users.noreply.github.com>
2021-04-12 17:24:41 +02:00
a715c82f7f Remove embedded repo/ca choices (#461)
* Remove embedded repository contact option, migrate commands and events.
* Migrate old CA init events. Test upgrade from 0.6.0.
* Migrate embedded in CA history.

Co-authored-by: Ximon Eighteen <3304436+ximon18@users.noreply.github.com>
2021-04-01 17:18:28 +02:00
Tim BruijnzeelsandGitHub 3a916cb632 Limit the number of deltas in RRDP notification.xml file. (#460) 2021-04-01 15:53:11 +02:00
Ximon EighteenandGitHub f3e8023be5 Support fine grained access per CA (resolves #437) (#443)
- Various changes to support a grey policy in between black and white approach of permitting or denying access to CAs entirely, whereby a user can have a different role in one CA than in another.
- Introduces the NoResourceType for requests not relating to a specific "resource", e.g. CA, such as LOGIN. NoResourceType maps to `nil` in Oso policy language.
- Add support for Permission constants in Polar files. Build the Permission enum using a macro.
- Added CA_ADMIN (for bulk operations) and CA_DELETE permissions.
- Support loading more than one custom auth policy file.
- Checks were missing on some API calls if the user had the necessary permission *on the relevant resources*.
- Rename the team policy as a demo to indicate that it is educational only.
- Split a role-per-ca demo out of the team policy demo.
- Extend the with_ta Cypress test to cover the role-per-ca ca demo policy (as it creates the needed data).
- Don't misrepresent an external policy file in log statements as being internal.
- Better comments describing what the tests are doing.
- Remove unused role parameter in team access demo policy.
- Add disallow() in Oso policies as a way to define deny rules.
2021-03-25 21:35:38 +01:00
23be0b5ef7 Make testbed fully configurable through config section
* Let users configure the AIA to use with TA certificates. Set 'ta_aia' in the config file. (#409)
* Use explicit configuration section for testbed, no longer rely on magic env variables.

Note: this will all be revised again if/when the Publication server and TA vs CA code is fully separated in future.

Co-authored-by: Ximon Eighteen <3304436+ximon18@users.noreply.github.com>
2021-03-22 16:53:41 +01:00
e662c1553b Change to a hybrid event sourcing model for CAs and Repository. (#426)
This allows us to keep the full history of semantically important events, while not spamming the history and avoiding excessive use of disk space. See issues #370 and #423.

This is a substantial change. Highlights follow:
* Added a developer documentation section
* No longer using events for manifest/crl generation (#370)
* No longer using events for publication deltas (#423)
* Removed pre 0.6.0 migration code - people will have to upgrade to at least 0.6.0 first
* Added migration code for 0.6.0-0.8.1 to this
* Migrate repository by doing a keyroll. (#370)
* Remove archiving code for commands (no longer applicable)

Minor other fixes:
* Use a swap file when writing (avoid corrupt json if disk is full) (#370)
* Make removing publisher content idempotent for publishers already removed.

Co-authored-by: Ximon Eighteen <3304436+ximon18@users.noreply.github.com>
Co-authored-by: Jasper den Hertog <jasper@plainspace.com>
2021-03-17 12:08:36 +01:00
Ximon Eighteen 16d578a053 Merge branch 'master' into v0.8.1-bis. 2021-03-09 10:58:06 +01:00
Ximon EighteenandGitHub a217f776af Log types passed to oso when trace is enabled (#430)
When trace level logging is enabled, log the types passed to Oso, not just the values.
2021-03-08 12:05:35 +01:00
Ximon EighteenandGitHub 248807ebc7 Fix master token access restrictions when not using the multi-user feature. (#415)
* Add a test that should (but doesn't in non-multi-user mode) panic because it tries to create a CA using the wrong master token.

* cargo fmt

* Add some comments explaining what the test does and how it works.

* FIX: Don't permit anonymous users to perform restricted actions in non-multi-user mode (this regression was introduced in the v0.8.1-bis branch, it was never released).
2021-02-10 11:21:30 +01:00
Jasper den HertogandGitHub 1cba1dba70 authenticate()/try_refresh_token() rfc-6749 style errors (#396)
Improved handling of OpenID Connect error responses when using a refresh token to obtain new tokens.
2021-02-10 10:42:43 +01:00
Ximon EighteenandGitHub bbfe9a824a Testbed mode should be more liberal in handling formatting variations in child and publisher registration XML. (#369) (#403)
Testbed mode should be more liberal in handling formatting variations in child and publisher registration XML. Synced with Lagosta commit d94470db. (#369, #403)
2021-01-29 17:11:30 +01:00
Ximon EighteenandGitHub c1ca53e13a Don't depend on private internal serde Display trait (fixes #391) 2021-01-19 16:05:05 +01:00
Ximon Eighteen 8ef1660a1f Move ActorDef constructors to ActorDef. 2021-01-12 14:48:40 +01:00
Tim Bruijnzeels 37750bab0d Be more lenient on whitespace in XML, but have better warnings for offending json. (#369) 2021-01-08 14:04:55 +01:00
Tim Bruijnzeels ece0950419 Remove HATEOS links from publisher list (make API consistent #330) 2021-01-07 09:56:26 +01:00
Ximon Eighteen 394e325b7c cargo fmt 2021-01-06 14:27:59 +01:00
Tim Bruijnzeels a1c8889b56 Remove a CA (CLI and API only) #359 2021-01-05 16:08:23 +01:00
Ximon Eighteen e0be300283 Clippy goodness. 2021-01-05 12:45:20 +01:00
Ximon Eighteen 59cd7bb364 FIX: Show internal auth errors (e.g. OpenID Connect provider invalid response) distinctly from Krill "general" errors (which might imply a problem with Krill itself which is not the case). Synced with Lagosta master commit 259958f. 2021-01-05 12:44:11 +01:00
Ximon Eighteen c436f0d0a7 Remove strange unnecessary & in const ActorDefs and consume ActorDefs to make Actors. 2021-01-05 11:15:39 +01:00
Ximon Eighteen ddde6b41d8 Add Actor module level intro rustdoc. 2021-01-05 11:01:14 +01:00
Ximon Eighteen 544c3bdde0 FIX: master token fallback fails if the primary provider cannot decode the bearer token, as we don't know if that's an internal / provider error that should be reported to the user, or is because the token is for the master token provider and so doesn't match. Try the master token provider first instead as error handling is easier this way around and failure is fast and provider delays won't slow down auth when using a master token. 2021-01-05 10:59:42 +01:00
Ximon Eighteen 1b1d7f9a5d More Clippy goodness. 2020-12-30 15:58:32 +01:00
Ximon Eighteen 8bc43d7640 rustfmt on recently modified files. 2020-12-30 15:46:08 +01:00
Ximon Eighteen 1c2ee3d336 Separate actor definitions from actor instances, use Token type for password_hash, move request/response handling into the AuthProviders plus some additional error handling. 2020-12-30 15:46:08 +01:00
Ximon Eighteen b2cf7535dd Error handling tweaks. 2020-12-30 15:46:08 +01:00
Ximon Eighteen 14013fd6ca FIX: Don't respond with auth errors (e.g. token expiration) to requests to unprotected API endpoints. 2020-12-30 15:46:07 +01:00
Tim Bruijnzeels 48edbff602 Report configured next parent exchange time (#357) 2020-12-20 14:30:16 +01:00
Tim Bruijnzeels 88f66f327a Clean up comment. 2020-12-18 11:28:05 +01:00
Tim Bruijnzeels 9d2d0eabc0 Manage Repository Server init/remove through API (#353) 2020-12-14 16:01:33 +01:00
Tim Bruijnzeels 2e15ba47cc Skip cleanup of redundant ROAs - release 0.8.2 2020-12-14 14:35:02 +01:00
Tim Bruijnzeels 0f54bf73ef Fix test environment variables. 2020-12-10 15:39:06 +01:00
Tim Bruijnzeels 4151653145 Allow localhost in test context only using cargo features rather than config. 2020-12-09 15:49:05 +01:00
Ximon Eighteen 64965517f5 Merge branch 'v0.8.1-bis' of github.com:NLnetLabs/krill into v0.8.1-bis 2020-12-09 13:30:22 +01:00
Tim Bruijnzeels 4db7721fc1 Fix clippy warnings in latests rust version. 2020-12-09 12:32:46 +01:00
Ximon Eighteen 17df0a66ec Merge branch 'v0.8.1-bis' of github.com:NLnetLabs/krill into v0.8.1-bis. 2020-12-09 11:52:35 +01:00
Tim Bruijnzeels 5efe2fa377 Separate krillpubd and krillpubc. (#338) 2020-12-09 11:31:42 +01:00
Ximon Eighteen 83770d75fb Adjust tests to match changes to Actor creation. 2020-12-09 00:41:03 +01:00
Ximon Eighteen cbd01a6b16 FIX: internal actions wrongly attributed to user none due to missing linked auth policy to evaluate the request against. Introduces a separation between actor and actor definition. Actors can now only be created via the Authorizer to ensure they have a linked auth policy. 2020-12-09 00:06:32 +01:00
Ximon Eighteen d0d53db6a7 Don't expose internal policy object locking strategy details outside the policy wrapper. 2020-12-08 09:49:13 +01:00
Ximon Eighteen 472a0e4751 Merge multi-user branch. Uses Lagosta master branch commit a7e73cba which includes multi-user support. 2020-12-07 16:55:40 +01:00
Tim Bruijnzeels 48384e3278 Simplify ResourceSet equality check. (#122) 2020-11-18 14:14:32 +01:00
Tim Bruijnzeels 63417f6a38 Merge branch 'master' into v0.8.1-bis 2020-11-18 12:35:06 +01:00
Tim Bruijnzeels b5b0b03d0f Remove lazy_static! (#349) 2020-11-17 17:15:43 +01:00
Tim Bruijnzeels 07dc36b9b9 Update versions. 2020-11-16 16:05:41 +01:00
Tim Bruijnzeels 81c737fdd8 Remove derive_more dependency #297 2020-11-11 13:39:31 +01:00
Tim Bruijnzeels b056eb1ebd Reset session if publication server needed to recover. (#339) 2020-11-09 15:46:52 +01:00
Tim Bruijnzeels 3d237a2285 Support new ROA BGP analyis statuses in text report. 2020-11-06 12:09:35 +01:00
Tim Bruijnzeels adf9b561f8 Resport which announcements are authorized/disallowed for redundant ROAs as well. 2020-11-06 11:58:45 +01:00