if i log in to my browser, other users will open the site with logged in

Posted 3 years ago by xicoJosue
Edited 3 years ago
0

Good Day,

I have a huge problem in my project:

 

if i login in my site in my browser and after that other users open the site, they will open it already logged/authenticated wth my account

if you open the same site there on your computer as me, the site does not ask you for authentication, it opens you on your computer with my data already authenticated with my login.

//Startup code:


    public class Startup
    {
        private bool UsoMocks { get; set; }

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();

            services.AddServerSideBlazor()
                .AddCircuitOptions(options =>
                {
                    options.DetailedErrors = true;
                });

            services.AddAuthorization();

            services.AddHttpContextAccessor();//https://stackoverflow.com/questions/59469742/get-user-agent-and-ip-in-blazor-server-side-app

            services.AddScoped<CustomAuthStateProvider>();
            services.AddScoped<AuthenticationStateProvider>(provider => provider.GetRequiredService<CustomAuthStateProvider>());
            services.AddScoped<CustomAuthNavigationHandler>();

            if (UsoMocks)
            { }

            //*** https://www.fabiosilvalima.com/appsettings-read-config-aspnetcore/
            services.AddConfiguration<MySettingsConfiguration>(Configuration, "MySettings");

            //*** https://github.com/Blazored/SessionStorage
            services.AddBlazoredSessionStorage();

            services.AddMemoryCache(); //In-Memory Caching in ASP.NET Core --> codewithmukesh.com/blog/in-memory-caching-in-aspnet-core/

            Uri urlApiArtic = new Uri(Configuration.GetSection("MySettings").GetValue<string>("UrlAPIArtic"));


            //services.AddSingleton(new HttpClient { BaseAddress = urlApiArtic });
            //Code I got from internet to register httpclient service
            if (!services.Any(x => x.ServiceType == typeof(HttpClient)))
            {
                // Setup HttpClient for server side in a client side compatible fashion
                services.AddScoped(_ => new HttpClient { BaseAddress = urlApiArtic });
            }

            services.AddTransient<IAutenticacaoService, AutenticacaoServiceApi>();
            services.AddTransient<IDadosPessoaisService, DadosPessoaisServiceApi>();
            services.AddTransient<IEnvioPasswordInicialService, EnvioPasswordInicialServiceApi>();
            services.AddScoped<ITabelasGeraisService, TabelasGeraisServiceApi>();



            //*** Background services with workers
            services.AddHostedService<ArticBackgroundService>();
            services.AddScoped<IWorker, ArticWorker>();
            //***


            services.AddTransient<AutenticacaoViewModel>();
            services.AddTransient<RecuperacaoPasswordViewModel>();
            services.AddTransient<AlteracaoPasswordViewModel>();
            services.AddTransient<DadosPessoaisViewModel>();
            services.AddTransient<AlteracaoEmailViewModel>();

        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            app.UseStaticFiles(); // For the wwwroot folder

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");
                endpoints.MapHub<ChatHub>(ChatHub.HubUrl);/// /***https://docs.microsoft.com/pt-pt/azure/azure-signalr/signalr-tutorial-build-blazor-server-chat-app
            });

            Definicoes.EstamosEmDesenvolvimento = env.IsDevelopment();
            Definicoes.CaminhoDefault = env.WebRootPath;
        }
    }

Can someone help me?

Thank you for your attention

  • 0

    .Can someone help me with the above question?

    Posted 3 years ago by xicoJosue Edited 3 years ago
Someone is typing...

Post a Reply

You must be logged in to add a new post.
Number of online users: 0
An error has occurred. This application may no longer respond until reloaded. Reload 🗙