visualrecode / cocoon Goto Github PK
View Code? Open in Web Editor NEWAn implementation of the Strangler Fig pattern for ASP.NET Core
License: Apache License 2.0
An implementation of the Strangler Fig pattern for ASP.NET Core
License: Apache License 2.0
Trying out Cocoon with a Blazor Server using NET 6 with
<PackageReference Include="ReCode.Cocoon.Proxy" Version="1.0.15-beta1" />
<PackageReference Include="ReCode.Cocoon.Proxy.BlazorServer" Version="1.0.15-beta1" />
This is pointing at a plain AspNet Webforms site. Getting the error:
2021-11-11T12:27:23.1887908+00:00 0HMD51QDOHLGG:00000001 [ERR] Failed to deserialize ReCode.Cocoon.Proxy.Authentication.MessagePrincipal value. (d55bba89)
MessagePack.MessagePackSerializationException: Failed to deserialize ReCode.Cocoon.Proxy.Authentication.MessagePrincipal value.
---> MessagePack.MessagePackSerializationException: Unexpected msgpack code 239 (negative fixint) encountered.
at MessagePack.MessagePackReader.ThrowInvalidCode(Byte code)
at MessagePack.MessagePackReader.ReadArrayHeader()
at MessagePack.Formatters.ReCode_Cocoon_Proxy_Authentication_MessagePrincipalFormatter1.Deserialize(MessagePackReader& reader, MessagePackSerializerOptions options)
at MessagePack.MessagePackSerializer.Deserialize[T](MessagePackReader& reader, MessagePackSerializerOptions options)
--- End of inner exception stack trace ---
at MessagePack.MessagePackSerializer.Deserialize[T](MessagePackReader& reader, MessagePackSerializerOptions options)
at MessagePack.MessagePackSerializer.DeserializeFromSequenceAndRewindStreamIfPossible[T](Stream streamToRewind, MessagePackSerializerOptions options, ReadOnlySequence`1 sequence, CancellationToken cancellationToken)
at MessagePack.MessagePackSerializer.DeserializeAsync[T](Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken)
at ReCode.Cocoon.Proxy.Authentication.CocoonAuthenticationClient.DeserializePrincipal(Stream stream)
at ReCode.Cocoon.Proxy.Authentication.CocoonAuthenticationClient.AuthenticateAsync(HttpRequest request)
This is followed by
2021-11-11T12:27:23.1941785+00:00 0HMD51QDOHLGG:00000001 [INF] "Cocoon" was not authenticated. Failure message: "Failed to deserialize ReCode.Cocoon.Proxy.Authentication.MessagePrincipal value." (48071232)
Running on Windows 10, and the Blazor Server app is using Kestrel. I tried using IIS Express for the Blazor app but it does not run, so not sure what the issue is.
We have a legacy WebForms app and Blazor Server front-end using Cocoon successfully for a year. It's hosted on our own servers at present and its working perfectly.
I'm trying to port the same code to be hosted on Azure. I've set up two App Services running in the same service plan (both as Windows hosts). One is running the WebForm app (on .NET Framework 4.8) and the other running Blazor (on .NET 6).
Both apps are up and running independently, but if I try to access a Cocoon page from the Blazor app, it returns a 400 error.
This is the case even if I try to request a static resource, e.g. /img/Test.jpg
. This exists on the WebForm app, but it fails and returns a 400 error. From the Blazor site log (below) I can see that it Initially tries to request the /facadeauth
route on the target, even though it's accessing a static file, which returns a 401 error. I can query the URL on the webform site, e.g. https://webform-site-url/img/Test.jpg
and it works.
2023-03-09 16:45:27.314 +00:00 [INF] Executing endpoint '/{**catch-all}'
2023-03-09 16:45:27.314 +00:00 [INF] Proxying to https://webform-site-url/img/Test.jpg HTTP/2 RequestVersionOrLower no-streaming
2023-03-09 16:45:27.328 +00:00 [INF] Request starting HTTP/1.1 GET https://blazor-site-url/img/Test.jpg - -
2023-03-09 16:45:27.329 +00:00 [INF] Start processing HTTP request GET "https://webform-site-url/facadeauth"
2023-03-09 16:45:27.330 +00:00 [INF] Sending HTTP request GET "https://webform-site-url/facadeauth"
2023-03-09 16:45:27.334 +00:00 [INF] Received HTTP response headers after 3.1655ms - 401
2023-03-09 16:45:27.335 +00:00 [INF] End processing HTTP request after 5.6275ms - 401
2023-03-09 16:45:27.336 +00:00 [INF] Executing endpoint '/{**catch-all}'
2023-03-09 16:45:27.336 +00:00 [INF] Proxying to https://webform-site-url/img/DefaultLogo.jpg HTTP/2 RequestVersionOrLower no-streaming
2023-03-09 16:45:27.345 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.346 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.347 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 18.8249ms
2023-03-09 16:45:27.348 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.349 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.350 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 43.3374ms
2023-03-09 16:45:27.351 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.351 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.352 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 74.3990ms
2023-03-09 16:45:27.354 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.364 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.365 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 112.8046ms
2023-03-09 16:45:27.366 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.366 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.372 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 152.5473ms
2023-03-09 16:45:27.374 +00:00 [INF] Received HTTP/1.1 response 400.
2023-03-09 16:45:27.375 +00:00 [INF] Executed endpoint '/{**catch-all}'
2023-03-09 16:45:27.380 +00:00 [INF] Request finished HTTP/1.1 GET https://blazor-site-url/img/DefaultLogo.jpg - - - 400 0 - 189.8787ms
2023-03-09 16:45:27.381 +00:00 [INF] Received HTTP/1.1 response 400.
Any ideas??
I updated a pull request #27 to update the YARP library to version 1.0.1 (to include security fix). The GitHub Action to build the PR is failing when trying to execute a VS2019 build:
https://github.com/VisualReCode/Cocoon/runs/6097402981?check_suite_focus=true#step:8:1
Blazor supports components with multiple @page
directives (see docs).
The BlazorRouteDiscovery
class only supports a single RouteAttribute
and thus throws an exception if more than one is defined.
Hello!
loving this package so far, i'm trying to rewrite a legacy webforms app using blazor server.
However i'm having some problems when deploying the apps.
The legacy app is deployed as a subsite, so for example: https://legacyapp.domain.com/subsite
in the appsettings.json of the blazor app i've correctly set the urls using https://legacyapp.domain.com/subsite as destinationPrefix.
In this situation the proxy doesn't seem to work, i get correctly redirected to https://legacyapp.domain.com/subsite when opening the blazor app, but after authenticating i'm not redirected back to the blazor app, whereas while debugging locally everything works as expected.
I'm guessing is has to do with the legacy app being deployed as a subsite but i'm actually not sure.
Where i get redirected for authentication the return url is https://legacyapp.domain.com/subsite/Account/Login?redirecturl=~/ which obviously cannot work... i tried manually setting the redirect url to the url of the deployed blazor app but that doesn't work too, after auth i'm redirected to the legacy app.
How should i approach this situation?
Many thanks
Hello!
I am currently testing this library to allow an incremental migration of a BIG Webforms application (>160 pages) to Blazor server.
First tests seem to run apparently fine however some pages take a very good while to load in the web forms app (we're talking about 2-5 minutes just to load) which causes YARP to fail miserably.
Here is a Pastebin for all intents and purposes: https://pastebin.com/cHHkbv9m
Now the question is, how should I go about appropriately handling the timeout value using this Library?
I think I've found a nasty security-related bug. What's the best way to disclose this without publicly posting it?
Hello!
I'm trying to rewrite a legacy webforms app using Blazor server.
However, I'm having some problems with proxy routing.
Let's imagine ComponentBase class implementation such as this one:
public class CancellableComponent : ComponentBase, IDisposable
{
internal CancellationTokenSource _cts = new();
public void Dispose()
{
_cts.Cancel();
_cts.Dispose();
}
}
and the component that is implementing it
@page "/Settings"
@implements CancellableComponent
...
Then routing is strange, when I hit URL (for example https://localhost:5001/Settings
) directly, it is not routed to Blazor page, but to the original webforms page. But when I click on its tab in the menu (Blazor part) it is routed correctly. Of course, when I remove @implements CancellableComponent
from Blazor page, routing is correct in any circumstances.
How should I approach this situation, is there any chance of implementing my custom component base and having correct routing?
Many thanks
Enjoying the stream - many thanks!
Wanted to know if you'd like contributions and suggestions or if you want to do it all on-stream
Running with Blazor Server on .NET 6, if a user is not logged on we get this exception in the Blazor app's log:
[17:23:30 ERR] Failed to deserialize ReCode.Cocoon.Proxy.Authentication.MessagePrincipal value.
MessagePack.MessagePackSerializationException: Failed to deserialize ReCode.Cocoon.Proxy.Authentication.MessagePrincipal value.
---> MessagePack.MessagePackSerializationException: Unexpected msgpack code 13 (positive fixint) encountered.
at MessagePack.MessagePackReader.ThrowInvalidCode(Byte code)
at MessagePack.MessagePackReader.ReadArrayHeader()
at MessagePack.Formatters.ReCode_Cocoon_Proxy_Authentication_MessagePrincipalFormatter1.Deserialize(MessagePackReader& reader, MessagePackSerializerOptions options)
at MessagePack.MessagePackSerializer.Deserialize[T](MessagePackReader& reader, MessagePackSerializerOptions options)
--- End of inner exception stack trace ---
at MessagePack.MessagePackSerializer.Deserialize[T](MessagePackReader& reader, MessagePackSerializerOptions options)
at MessagePack.MessagePackSerializer.DeserializeFromSequenceAndRewindStreamIfPossible[T](Stream streamToRewind, MessagePackSerializerOptions options, ReadOnlySequence`1 sequence, CancellationToken cancellationToken)
at MessagePack.MessagePackSerializer.DeserializeAsync[T](Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken)
at ReCode.Cocoon.Proxy.Authentication.CocoonAuthenticationClient.DeserializePrincipal(Stream stream)
at ReCode.Cocoon.Proxy.Authentication.CocoonAuthenticationClient.AuthenticateAsync(HttpRequest request)
[17:23:30 INF] Cocoon was not authenticated. Failure message: Failed to deserialize ReCode.Cocoon.Proxy.Authentication.MessagePrincipal value.
Looking at the code in CocoonAuthenticationClient,cs
, it logs the response and status code, which we see in the Blazor log just before the exception:
[17:23:29 INF] Start processing HTTP request GET http://localhost:9343/facadeauth
[17:23:29 INF] Sending HTTP request GET http://localhost:9343/facadeauth
[17:23:30 INF] Received HTTP response headers after 474.8694ms - 200
[17:23:30 INF] End processing HTTP request after 478.5473ms - 200
Note the 200
response code.
Looking at AuthApiHandler.cs
in Cocoon.Legacy it should return a 401
if not logged in, however that does not seem to be happening.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.