GithubHelp home page GithubHelp logo

Comments (5)

mjrousos avatar mjrousos commented on August 11, 2024 1

I like that option. It's not that different from just setting those options in SystemWebAdapters options directly, but it seems good to have remote app stuff separated out to keep things clear. I'll update things to work this way.

from systemweb-adapters.

davidfowl avatar davidfowl commented on August 11, 2024

Also RemoteApp and ApiKey exist on both session and auth, maybe those should be consolidated?

from systemweb-adapters.

twsouthwick avatar twsouthwick commented on August 11, 2024

I believe @mjrousos is handling that as part of his auth implementation.

from systemweb-adapters.

mjrousos avatar mjrousos commented on August 11, 2024

Sort of. This is a tricky one because, on the one hand, it feels bad to set these same values multiple times but, on the other hand, it also feels weird to configure things like ApiKey and RemoteAppUrl in core SystemWebAdapter configuration when those values aren't actually needed there (they're only needed for additional optional features like session sharing or auth sharing).

The way I've handled this in the auth PR so far is that I still require both session and auth configuration to set RemoteAppUrl and ApiKey, but I have both options types derive from a common base type with these properties so users can at least have code that sets these properties shared between both auth and session configuration.

I'm still not entirely happy with the solution, though, and think I will change it to have these properties set in SystemWebAdapter options even though they aren't used there. That's still not ideal but will be more readable.

Here's what using the approach in my auth PR currently looks like:

builder.Services.AddSystemWebAdapters()
    .AddJsonSessionSerializer(options => RegisterSessionKeys(options))
    .AddRemoteAppSession(ConfigureRemoteServiceOptions)
    .AddRemoteAppAuthentication(o => ConfigureRemoteServiceOptions(o.RemoteServiceOptions));

void ConfigureRemoteServiceOptions(RemoteServiceOptions options)
{
    options.RemoteAppUrl = new(builder.Configuration["ReverseProxy:Clusters:fallbackCluster:Destinations:fallbackApp:Address"]);
    options.ApiKey = "strong-api-key";
}

If we set things in SystemWebAdapters instead, it would look like this:

builder.Services.AddSystemWebAdapters(options =>
    {
        options.RemoteApp = new(builder.Configuration["ReverseProxy:Clusters:fallbackCluster:Destinations:fallbackApp:Address"]);
        options.ApiKey = "strong-api-key";
    })
    .AddJsonSessionSerializer(options => RegisterSessionKeys(options))
    .AddRemoteAppSession()
    .AddRemoteAppAuthentication();

from systemweb-adapters.

twsouthwick avatar twsouthwick commented on August 11, 2024

What about keeping it separate, but as a general remote app:

builder.Services.AddSystemWebAdapters(options =>
    {
    })
    .AddJsonSessionSerializer(options => RegisterSessionKeys(options))
    .AddRemoteApp(options =>
   {
        options.RemoteAppUrl = new(builder.Configuration["ReverseProxy:Clusters:fallbackCluster:Destinations:fallbackApp:Address"]);
        options.ApiKey = "strong-api-key";
   })
    .AddRemoteAppSession()
    .AddRemoteAppAuthentication();

And that would get plumbed through as an IOptions<RemoteAppOptions>:

public class RemoteAppOptions
{
  public Uri RemoteAppUrl { get; set; }
  public string ApiKey { get; set; }
}

We could potentially use named options to disambiguate if people want multiple, but I don't see that as a required scenario at the moment.

from systemweb-adapters.

Related Issues (20)

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.