Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[autorules] Credentials deletion enhancements #516

Merged

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Jun 16, 2021

This addresses the following review deficiencies from #416 :

DELETE /api/v2/targets/:targetId/credentials

Maybe the response could specify if credentials were found and deleted, or if there were no credentials to be deleted? Not super important, but might be helpful.

(TODO):

When a rule for a target is running, and I delete the credentials for that target, the archiver is still able to archive recordings, despite the fact that JMX auth is required for this, and the saved JMX auth credentials have been deleted. I see that this is because in the code, the credentials are given to the PeriodicArchiver in the constructor and saved to the object, not retreived from the CredentialsManager each time it is used. This is more efficient, but I'm wondering if it makes sense from the user's point of view. If they deleted some credentials, would they expect for CJFR to not have a copy of those credentials stored anywhere, anymore? Or at least not be able to use it?

@andrewazores andrewazores requested a review from vic-ma June 16, 2021 02:57
@andrewazores andrewazores force-pushed the auto-rules-credentials-delete branch 2 times, most recently from f013fa0 to 2337f5e Compare June 16, 2021 17:40
@andrewazores andrewazores marked this pull request as ready for review June 16, 2021 19:30
@andrewazores
Copy link
Member Author

@vic-ma this is ready

If Credentials are deleted afer a rule is triggered/a PeriodicArchiver starts, the PeriodicArchiver should fail to archive from that point forward since its Credentials access has been revoked
@andrewazores andrewazores force-pushed the auto-rules-credentials-delete branch from 5fb9bd2 to 0fc4f3d Compare June 16, 2021 19:35
@andrewazores andrewazores merged commit d884cb6 into cryostatio:auto-rules Jun 17, 2021
@andrewazores andrewazores deleted the auto-rules-credentials-delete branch June 17, 2021 02:12
andrewazores added a commit that referenced this pull request Jun 17, 2021
* Respond 404 when deleting nonexistent credentials

* Retrieve Credentials from Manager on each PeriodicArchiver run

If Credentials are deleted afer a rule is triggered/a PeriodicArchiver starts, the PeriodicArchiver should fail to archive from that point forward since its Credentials access has been revoked

* Test credentials revocation during archiver run
andrewazores added a commit that referenced this pull request Jun 22, 2021
* Rebase fixes

* Rough out (very rough) automatic rules

* Add very rudimentary configuration file credentials management

* Cleanup

* Add FIXMEs

* Fix mistake, retrieve credentials by alias (for now)

* Store credentials under subdirectory of conf dir

* Move subdirectory creation into module

* Add FIXME

* Persist rules to disk

Credentials persist optionally (default: false)

* Add file open options, some FIXMEs, fix imports

* Expect and serialize single credential per file

* Expect and serialize single rule per file

* Split rule processing logic out of RuleRegistry

* Ensure RuleProcessor is created, injected, and enabled by DI root

* Extract helper method

* Implement periodic archival in rules

* Don't retry pruning already-pruned recordings

* Normalize URLs (URIs)

* Log at lower level

* Implement variable number of preserved archives

* Add maxAge/maxSize to Rule

* Encapsulate Rule fields, add Builder

* Rules sanitize own names

* Add PeriodicArchiverFactory

PeriodicArchiver provided through DI for testability/decoupling

* Cleaning

* Cleaning

* Cleaning

* Avoid hardcoded request paths

* Cleanup

* Add TODO

* Add handlers for POSTing Credentials

* Add handler for DELETEing Credentials

* Implement handlers for POSTing rules

* Fixup

* Automate add/remove demo app

* Implement GET handler for Rules

* Change credentials POST path

* Include Location header on rules creation response

* Handle Rules POST as multipart form or JSON

* Rename RulesGetHandler to RuleGetHandler

* Implement GET for all rules

* Remove unused method

* Implement handler to DELETE rules by name

* Update pom.xml for configuration directories

* Fix Spotbugs bugs

* Rename credentials POST handler to reflect targetId path param

* Add FIXME

* Fix content-type bug, apply formatting

* Fix periodic archiver recording name

* Make test script host URL configurable

Allows for testing while using -web start:dev + CORS setup, for example

* Update for multiple demo apps

* Remove unnecessary(?) handling for extra form type

* Remove 'persist' form attribute

* Apply spotless formatting

* Revert "Remove unnecessary(?) handling for extra form type"

This reverts commit 8e20fad.

* Remove TODO

* Replace rulestest.sh with AutoRulesIT.java

* Add RuleRegistryTest

* Add RuleProcessorTest

* Apply auto_ prefix to recordings in one place

* Remove unnecessary client-side timeout

* Minor refactor

* Add PeriodicArchiverTest

* Extract shared client credentials header logic

* Restore rulestest.sh for manual testing

* Ensure rule definitions do not partially collide

* Implement deleteRules(ServiceRef serviceRef)

* Cancel periodic archivers if associated target disappears

* Fix logger message formatting

* Enable JMX auth on test container

* Update FIXME

* Correct core version

* [autorules] Rules POST handler enhancements (#423)

* Use URL-safe Base64 encoder/decoder (#419)

* Use URL-safe Base64 encoder/decoder

Use encoder which produces, and decoder which expects, the URL-safe Base64 alphabet variant. The decoder is also tolerant of missing padding characters at the end, which the client will not send due to their illegality in the WebSocket Subprotocol header value

* Update web-client to include base64url client-side changes

* Update web-client to fix build (#424)

* Add Quarkus JVM sample app (#418)

* Throw exception if added rule collides by name

* Throw exception if integer attrs negative

Add unit tests for rules post handler

* Refactor to extract string constants to enum

Add tests for non-integer params

* Correct spotbugs findings

* Add some Rule attribute assertions and tests

* Do all attribute validation in Rule

* Correct exception message formatting

* Catch IllegalArgumentException and rethrow as ApiException 400

* Minor refactor

* Remove no-op CHANGED event handling

* Include exception reason in API response message

* Rebase fixes

* Bugfix: double async target discovery notifications

* [autorules] Rules deletion enhancements (#506)

* Update rulestest.sh to match current smoketest.sh

* Add rule deletion test step

* Refactor to not swallow IOExceptions

* Track archiver tasks by sref/rule tuple

* fixup! Update rulestest.sh to match current smoketest.sh

* Deleting Rule definition stops archival tasks using that rule

* Use direct API request paths, not injected handler method calls

* Respond 404 when deleting non-existent rule

* Add unit tests

* [autorules] Mention all missing form fields on credentials POST (#511)

* Mention all missing form fields on credentials POST

* Quote missing parameter names in error message

* Handle any blank form value, not only null

* Apply spotless formatting

* fixup! Handle any blank form value, not only null

* [autorules] Cancel periodic archivers on failure (#513)

* PeriodicArchivers notify RuleProcessor on archive failure

RuleProcessor uses this to cancel the archiver's future runs

* Add test that PeriodicArchiver notifies on failure

* Apply spotless formatting

* Minor refactor

* Add test that RuleProcessor cancels failed archivers

* Remove unnecessary assertions

* [autorules] rulestest.sh touchup (#519)

* Set USE_AUTH

* Don't delete rule definition

* [autorules] Credentials deletion enhancements (#516)

* Respond 404 when deleting nonexistent credentials

* Retrieve Credentials from Manager on each PeriodicArchiver run

If Credentials are deleted afer a rule is triggered/a PeriodicArchiver starts, the PeriodicArchiver should fail to archive from that point forward since its Credentials access has been revoked

* Test credentials revocation during archiver run

* JMXServiceURL/ServiceRef decoupling rebase fixes

* Correct log messages

* Correct exception message

* Remove rulestest.sh
andrewazores added a commit to andrewazores/cryostat that referenced this pull request Jun 24, 2021
* Rebase fixes

* Rough out (very rough) automatic rules

* Add very rudimentary configuration file credentials management

* Cleanup

* Add FIXMEs

* Fix mistake, retrieve credentials by alias (for now)

* Store credentials under subdirectory of conf dir

* Move subdirectory creation into module

* Add FIXME

* Persist rules to disk

Credentials persist optionally (default: false)

* Add file open options, some FIXMEs, fix imports

* Expect and serialize single credential per file

* Expect and serialize single rule per file

* Split rule processing logic out of RuleRegistry

* Ensure RuleProcessor is created, injected, and enabled by DI root

* Extract helper method

* Implement periodic archival in rules

* Don't retry pruning already-pruned recordings

* Normalize URLs (URIs)

* Log at lower level

* Implement variable number of preserved archives

* Add maxAge/maxSize to Rule

* Encapsulate Rule fields, add Builder

* Rules sanitize own names

* Add PeriodicArchiverFactory

PeriodicArchiver provided through DI for testability/decoupling

* Cleaning

* Cleaning

* Cleaning

* Avoid hardcoded request paths

* Cleanup

* Add TODO

* Add handlers for POSTing Credentials

* Add handler for DELETEing Credentials

* Implement handlers for POSTing rules

* Fixup

* Automate add/remove demo app

* Implement GET handler for Rules

* Change credentials POST path

* Include Location header on rules creation response

* Handle Rules POST as multipart form or JSON

* Rename RulesGetHandler to RuleGetHandler

* Implement GET for all rules

* Remove unused method

* Implement handler to DELETE rules by name

* Update pom.xml for configuration directories

* Fix Spotbugs bugs

* Rename credentials POST handler to reflect targetId path param

* Add FIXME

* Fix content-type bug, apply formatting

* Fix periodic archiver recording name

* Make test script host URL configurable

Allows for testing while using -web start:dev + CORS setup, for example

* Update for multiple demo apps

* Remove unnecessary(?) handling for extra form type

* Remove 'persist' form attribute

* Apply spotless formatting

* Revert "Remove unnecessary(?) handling for extra form type"

This reverts commit 8e20fad.

* Remove TODO

* Replace rulestest.sh with AutoRulesIT.java

* Add RuleRegistryTest

* Add RuleProcessorTest

* Apply auto_ prefix to recordings in one place

* Remove unnecessary client-side timeout

* Minor refactor

* Add PeriodicArchiverTest

* Extract shared client credentials header logic

* Restore rulestest.sh for manual testing

* Ensure rule definitions do not partially collide

* Implement deleteRules(ServiceRef serviceRef)

* Cancel periodic archivers if associated target disappears

* Fix logger message formatting

* Enable JMX auth on test container

* Update FIXME

* Correct core version

* [autorules] Rules POST handler enhancements (cryostatio#423)

* Use URL-safe Base64 encoder/decoder (cryostatio#419)

* Use URL-safe Base64 encoder/decoder

Use encoder which produces, and decoder which expects, the URL-safe Base64 alphabet variant. The decoder is also tolerant of missing padding characters at the end, which the client will not send due to their illegality in the WebSocket Subprotocol header value

* Update web-client to include base64url client-side changes

* Update web-client to fix build (cryostatio#424)

* Add Quarkus JVM sample app (cryostatio#418)

* Throw exception if added rule collides by name

* Throw exception if integer attrs negative

Add unit tests for rules post handler

* Refactor to extract string constants to enum

Add tests for non-integer params

* Correct spotbugs findings

* Add some Rule attribute assertions and tests

* Do all attribute validation in Rule

* Correct exception message formatting

* Catch IllegalArgumentException and rethrow as ApiException 400

* Minor refactor

* Remove no-op CHANGED event handling

* Include exception reason in API response message

* Rebase fixes

* Bugfix: double async target discovery notifications

* [autorules] Rules deletion enhancements (cryostatio#506)

* Update rulestest.sh to match current smoketest.sh

* Add rule deletion test step

* Refactor to not swallow IOExceptions

* Track archiver tasks by sref/rule tuple

* fixup! Update rulestest.sh to match current smoketest.sh

* Deleting Rule definition stops archival tasks using that rule

* Use direct API request paths, not injected handler method calls

* Respond 404 when deleting non-existent rule

* Add unit tests

* [autorules] Mention all missing form fields on credentials POST (cryostatio#511)

* Mention all missing form fields on credentials POST

* Quote missing parameter names in error message

* Handle any blank form value, not only null

* Apply spotless formatting

* fixup! Handle any blank form value, not only null

* [autorules] Cancel periodic archivers on failure (cryostatio#513)

* PeriodicArchivers notify RuleProcessor on archive failure

RuleProcessor uses this to cancel the archiver's future runs

* Add test that PeriodicArchiver notifies on failure

* Apply spotless formatting

* Minor refactor

* Add test that RuleProcessor cancels failed archivers

* Remove unnecessary assertions

* [autorules] rulestest.sh touchup (cryostatio#519)

* Set USE_AUTH

* Don't delete rule definition

* [autorules] Credentials deletion enhancements (cryostatio#516)

* Respond 404 when deleting nonexistent credentials

* Retrieve Credentials from Manager on each PeriodicArchiver run

If Credentials are deleted afer a rule is triggered/a PeriodicArchiver starts, the PeriodicArchiver should fail to archive from that point forward since its Credentials access has been revoked

* Test credentials revocation during archiver run

* JMXServiceURL/ServiceRef decoupling rebase fixes

* Correct log messages

* Correct exception message

* Remove rulestest.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants