Repository navigation
Conversation
805be09 to
b7f2d08
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1530 +/- ##
=======================================
+ Coverage 69.2% 70.2% +1.0%
=======================================
Files 308 313 +5
Lines 8890 9023 +133
Branches 1151 1163 +12
=======================================
+ Hits 6157 6340 +183
+ Misses 2382 2340 -42
+ Partials 351 343 -8
🚀 New features to boost your workflow:
|
DavidNemeth
left a comment
There was a problem hiding this comment.
I found one small thing worth fixing before merge.
The token is issued in Configure, but it only gets revoked when a Stopped event arrives. If the module fails to start after that point (the runner's Start throws), the loader never emits Stopped, so the token stays valid even though the module never ran. I checked this with the real ModuleLoader and ModuleTokenRevocationService: after a failed start, TryValidate(token) still returns true. Revoking the token in a catch around the start should cover it.
Also, heads-up: this conflicts with #1531 in MessageRouterServer.cs, so whichever of the two merges second will need a rebase.
b7f2d08 to
548d1a4
Compare
@DavidNemeth I fixed |
aedf2a8 to
d0a86a3
Compare
4ecf732 to
8038c68
Compare
8038c68 to
a5865ea
Compare
Issue tokens per module instance and add message router client identity
Summary
App.MessageRouterAccessToken, markedTODO: Assign a unique token for each module). Each module instance now gets its own random 256-bit token, issued by a newModuleTokenStorewhen the module is configured. The web and native module configurators request the token for the instance and inject it into the page or the environment variables. Re-issuing for the same instance returns the same token.IClientAuthenticatorabstraction andMessageRouterServerBuilder.UseClientAuthenticator(...).MessageRouterServercalls it on connect and stores the resultingClaimsPrincipalon the client, so identity is available for later authorization. The shell'sModuleTokenClientAuthenticatormaps a token to claims:composeui:identity-type(moduleorhost),composeui:module-instance-idandcomposeui:module-id.IAccessTokenValidatoris unchanged, and clients are only authenticated when an authenticator is registered.ModuleTokenRevocationServicerevokes a module instance's token when the module stops. It subscribes in the constructor so no lifetime event is missed. Token comparison usesCryptographicOperations.FixedTimeEqualsand checks every entry, so timing doesn't reveal which token matched.Behavior changes
App.MessageRouterAccessTokenis removed. It wasinternal, and the shell was its only consumer.MessageRouterStartupActionnow requires anIModuleTokenStore, and the module configurators have an internal constructor that takes one.Test plan
dotnet testfor the message router server tests (MessageRouterServer.Tests.cs: authenticator is invoked, the principal is stored, authentication failures reject the connection)dotnet testfor the new shell tests:ModuleTokenStore,ModuleTokenClientAuthenticator,ModuleTokenRevocationService,ModuleMessageRouterConfiguratorsandGlobalAccessToken