Giter Site home page Giter Site logo

Comments (4)

martincostello avatar martincostello commented on May 31, 2024

Have you also added the appropriate middlewares (and in the right order) like in the sample application?

public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
});

from aspnet.security.openid.providers.

kevinchalet avatar kevinchalet commented on May 31, 2024

Closing, as I believe your issue was caused by a missing middleware (typically, app.UseAuthentication()).

from aspnet.security.openid.providers.

kamilk91 avatar kamilk91 commented on May 31, 2024

Hi, i have to re-open issue.

Now i have Kestrel Server, fully configured with your tips. Problem is (propably) that im using Nginx reverse proxy, and it begins again:

image

My configuration:
Startup:

readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";


        private void CheckSameSite(HttpContext httpContext, CookieOptions options)
        {
            if (options.SameSite == SameSiteMode.None)
            {
                var userAgent = httpContext.Request.Headers["User-Agent"].ToString();

                options.SameSite = (SameSiteMode)(-1);

            }
        }

        public void ConfigureServices(IServiceCollection services)
        {

            //services.AddGrpc();
            services.AddAuthentication(options =>
            {
                options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            })
            .AddCookie(options =>
            {
                options.LoginPath = "/login";
                options.LogoutPath = "/signout";
            })

            .AddOpenId("Orange", "Orange", options =>
            {
                options.Authority = new Uri("https://openid.orange.fr/");
                options.CallbackPath = "/signin-orange";
            })

            .AddOpenId("StackExchange", "StackExchange", options =>
            {
                options.Authority = new Uri("https://openid.stackexchange.com/");
                options.CallbackPath = "/signin-stackexchange";
            })

            .AddOpenId("Intuit", "Intuit", options =>
            {
                options.CallbackPath = "/signin-intuit";
                options.Configuration = new OpenIdAuthenticationConfiguration
                {
                    AuthenticationEndpoint = "https://openid.intuit.com/OpenId/Provider"
                };
            })

            .AddSteam();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
            services.AddLogging();

            services.AddCors(options =>
            {
                options.AddPolicy(MyAllowSpecificOrigins,
                builder =>
                {
                    builder.WithOrigins("*")
                    .AllowAnyHeader()
                    .AllowAnyOrigin()
                    .AllowAnyMethod();
                });
            });

            services.Configure<CookiePolicyOptions>(options =>
            {
                options.MinimumSameSitePolicy = (SameSiteMode)(-1);
                options.OnAppendCookie = cookieContext =>
                    CheckSameSite(cookieContext.Context, cookieContext.CookieOptions);
                options.OnDeleteCookie = cookieContext =>
                    CheckSameSite(cookieContext.Context, cookieContext.CookieOptions);
            });


        }
        public void Configure(IApplicationBuilder app, ILoggerFactory logger)
        {

            logger.CreateLogger("Logging");



            app.UseStaticFiles();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapDefaultControllerRoute();

            });
            app.Use((context, next) =>
            {
                context.Response.Headers.Add("Access-control-allow-headers", "Content-Type, Accept, X-Requested-With, method");
                context.Response.Headers.Add("Access-control-allow-methods", "GET, POST, DELETE, PUT, OPTIONS, HEAD");
                context.Response.Headers.Add("Access-control-allow-origin", "*");
                context.Response.Headers.Add("Access-control-allow-credentials", "true");
                return next.Invoke();
            });
            app.UseCors(option => option.WithHeaders("accept", "content-type", "origin"));
            app.UseCookiePolicy();
            app.UseCors(MyAllowSpecificOrigins);
            app.UseHsts();
            app.UseHttpsRedirection();
        }


    }

Program.cs

var host = new WebHostBuilder()
                .UseKestrel()
                .UseUrls($"{env_config.KestrelURL}")
                .UseStartup<Startup>()
                .ConfigureLogging(l =>
               {
                   l.ClearProviders();
                   l.AddConsole();
               })
                .Build();

If user is Logged into steam redirection after taking SteamId works fine, but if user has to provide password, or confirm "Continue as xxxx" app redirecting him to 127.0.0.1:50000.

NGinx listening to 50000 on localhost, and proxing it to subdomain "secure.example.com".

from aspnet.security.openid.providers.

martincostello avatar martincostello commented on May 31, 2024

Have you configured nginx and/or Kestrel appropriately to forward on the host header and to be a trusted proxy for headers like x-forwarded-for and x-forwarded-proto?

from aspnet.security.openid.providers.

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.