Git Product home page Git Product logo

Comments (6)

markrendle avatar markrendle commented on September 17, 2024

Hi. Have you installed the Recode.Cocoon.Legacy package into the WebForms app?

from cocoon.

conficient avatar conficient commented on September 17, 2024

Yes I have got Recode.Cocoon.Legacy in the WebForm app..

I've removed the Cocoon NUGET packages from the Blazor app, copied in the current projects (ReCode.Cocoon.Proxy and ReCode.Cocoon.Proxy.BlazorServer) from the repo and linked by project references to the Blazor app.

I found that updating the MessagePack version to 2.3.85 cured the problem. I'll leave the issue open for now until I've got the auth working on the Blazor side.

from cocoon.

conficient avatar conficient commented on September 17, 2024

Thanks for the help so far Mark.

So I have the Blazor Server app working and routes on the WebForm app are being returned correctly. If the user logged into the WebForm app, it shows the correct WebForm content for the authorised user. I've reverted to Blazor Server for .NET 5 for the present to try to get it working.

I've created an <AuthorizeView> on my Index.razor page but it always shows <NotAuthorized> content, suggesting the Blazor authentication isn't recognising the WebForms auth.

The WebForm app is old-school so has the .ASPXAUTH cookie - I set this value in appsettings.json (as below)

    "Authentication": {
      "BackendApiUrl": "https://localhost:44300/facadeauth",
      "LoginUrl": "/Login?ReturnUrl={{ReturnUrl}}",
      "Cookies": [
        ".ASPXAUTH" /* was AuthCookie*/
      ]
    },

The Startup.cs file has the relevant setup code:

            // services.AddCocoonSession();
            services.AddCocoonCookies();

            services.AddAuthentication(CocoonAuthenticationDefaults.Scheme).AddCocoon();

            // add custom Cocoon auth
            services.AddScoped<AuthenticationStateProvider, CustomAuthenticationStateProvider>();
            services.AddCocoonProxy(configuration);

            // lines omitted... 
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapBlazorHub();
                endpoints.MapCocoonProxy();
                endpoints.MapFallbackToPage("/_Host");
            });

The app doesn't use sessions so this is commented out.

I can see the .ASPXAUTH cookie in the requests via Blazor so it's being passed in. Any suggestions?

from cocoon.

conficient avatar conficient commented on September 17, 2024

I've just realised the CustomAuthenticationStateProvider is probably a placeholder class, have copied over the CocoonAuthStateProvider from the WASM project. I can get WingTip toys sample with BlazorServerCocoon correctly seeing the authentication state now.

I note WingTip is using the .AspNet.ApplicationCookie cookie.. does this mean older apps using .ASPXAUTH cookies won't work?

from cocoon.

conficient avatar conficient commented on September 17, 2024

Understanding level now increased over the last few days..

The legacy app I'm looking to port is still using ASP.NET Membership for authentication.. hence the .ASPXAUTH cookie. So first I need to upgrade this to ASP.NET Identity before it will work correctly with Cocoon. It's a heavily customised Membership implementation so taking a while for me to do this!

I did get a test Web to work with Blazor Server on .NET 6, so it's hopefully once I have upgraded to ASP.NET Identity, I can try a new Cocoon implementation on it.

On a side note, this project would be good to showcase on the ASP.NET Community Standup - it's a great solution for users who have large WebForm apps and cannot go down the big-bang rewrite path. My app has 380 .aspx pages, of which at least 126 need to be upgraded and 97 need evaluation!

from cocoon.

conficient avatar conficient commented on September 17, 2024

Update: finally finished converting my WebForms to use Identity, and Coccon working !

from cocoon.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.