daml/triggers/service
Andreas Herrmann 8bceeb13de
Handle token expiry in trigger service (#8037)
* Enable adjustable clock in trigger service tests

changelog_begin
changelog_end

* Test user side token expiry

* Test service side token refresh

* Use AccessToken wrapper in TriggerRunnerImpl

* Store refresh token in trigger DB

* add refresh token to trigger runner config

* TriggerTokenExpired message to server

* TriggerTokenRefresh message to server

* refresh trigger token and update db

* Restart trigger with fresh token

* Test second token expiry

* Refresh token on running trigger

changelog_begin
* [Triggers] UNAUTHENTICATED errors will now terminate the trigger.
  These errors are no longer available for handling in the trigger DAML
  code. Instead, they are forwarded to the trigger service for handling,
  e.g. access token refresh.
changelog_end

* todo note

* Move triggerRunnerName and getRunner into object

* Factor out token refresh

* Factor out getActiveContracts

* factor out create command

* Add logging to token refresh

* Handle token expiry in TriggerRunner

TriggerRunnerImpl throws a dedicated exception when it fails on an
expired access token (any unauthenticated error to be precise).
The TriggerRunner supervisor reacts to this child failure by
requesting a token refresh and restart on the trigger server and
stopping itself.
The trigger server requests a new access and refresh token on the auth
middleware and restarts the trigger.

This works around an issue with actor supervisors in akka-actor-typed.
A stop supervisor wrapped within a restart supervisor will not cause a
stop as expected. Instead, the restart supervisor will trigger as well
and restart the actor. The work around uses a custom behavior
interceptor to emulate the appropriate stop supervisors as closely as
possible. We cannot properly emulate ChildFailed signals this way, so
we use dedicated messages intead.

* throw --> Future.failedo

* getOrFail helper

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-12-02 16:17:45 +00:00
..
auth Handle token expiry in trigger service (#8037) 2020-12-02 16:17:45 +00:00
release Rename targets (#5950) 2020-05-12 16:00:15 -04:00
src Handle token expiry in trigger service (#8037) 2020-12-02 16:17:45 +00:00
test-model Fix protobuf decoding in trigger service (#7967) 2020-11-16 12:16:03 +01:00
authentication.md Handle authorization failure in the auth middleware and trigger service (#7920) 2020-11-10 09:27:21 +00:00
BUILD.bazel Handle token expiry in trigger service (#8037) 2020-12-02 16:17:45 +00:00
daml-platform.sh Split sandbox code into separate packages (#6695) 2020-07-17 17:06:06 +02:00
hash-migrations.sh Check trigger dao migrations digests (#7908) 2020-11-06 09:20:32 +00:00