Commit Graph
3 Commits
Author SHA1 Message Date
Tim Bruijnzeels 9458adc821 Cargo fmt before release 0.9.0-rc3 (#528) 2021-05-20 15:56:27 +02:00
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
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