UserCookieAuthentication in Mono 3.4.1

喜你入骨 提交于 2019-12-03 03:01:16
LRFalk01

Okay this is happening because OWIN uses DpapiDataProtector by default and DPAPI is a windows API (Data Protection API) and does not work in mono. Luckily you can override the default in your cookie options. Below is an example where AesDataProtectorProvider is a custom IDataProtector that I found here: Using Oauth tickets across several services?

        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            TicketDataFormat =
                new SecureDataFormat<AuthenticationTicket>(DataSerializers.Ticket,
                    new AesDataProtectorProvider("testing"), TextEncodings.Base64)
        });

With this code my project starts in Mono again.

UPDATE:

You can also have a custom IDataProtectionProvider and have all of owin use that with this:

app.SetDataProtectionProvider(new CustomIDataProtectionProvider());
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!