locked
Change OWIN Storage to Redis RRS feed

  • Question

  • Hello there,

    I am developing a web service application with .NET Framework 4.5 / Web API 2 and I am using OWIN for authentication and authorization.

    So, for this application we need a load balancer solution then we set up that as you know after that users' tokens are not working properly. Because if a user take token from server A then can't use it on server B.

    Because of it, I need use Redis with Redis every application's OWIN will save authentication to redis

    I used https://github.com/ziyasal/Owin.Security.RedisTokenProviders this package, but it does not help. I guess I am missing a point.

    Thank you.

    EDIT

    Here is the my Configuration Method on Startup.cs

    public void Configuration(IAppBuilder appBuilder)
            {
                HttpConfiguration httpConfiguration = new HttpConfiguration();
                httpConfiguration.DependencyResolver = new NinjectResolver(NinjectWebCommon.CreateKernel());
    
                ConfigureOAuth(appBuilder);
    
                WebApiConfig.Register(httpConfiguration);
                appBuilder.UseWebApi(httpConfiguration);
            }

    and my Server Option in same class

    OAuthAuthorizationServerOptions oAuthAuthorizationServerOptions = new OAuthAuthorizationServerOptions()
                {
                    TokenEndpointPath = new Microsoft.Owin.PathString("/signin"),
                    AccessTokenExpireTimeSpan = TimeSpan.FromHours(1),
                    AllowInsecureHttp = true,
                    Provider = new SimpleAuthorizationServerProvider(),
                    RefreshTokenProvider = new RedisRefreshTokenProvider(new ProviderConfiguration
                    {
                        ConnectionString = "12.0.0.145:6379",
                        Db = 0,
                        ExpiresUtc = DateTime.UtcNow.AddMinutes(5),
                        AbortOnConnectFail = true
                    })
                };


    Friday, March 22, 2019 10:30 AM

All replies

  • Hi umutgur,

    Thank you for posting here.

    Since your question is more related to Web form, you could post a new thread in WCF, ASMX and other Web Services forum for suitable support.

    The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, April 3, 2019 9:19 AM