UserCookieAuthentifizierung in Mono 3.4.1

8

Wann immer ich die Zeile unten zu meiner Startup-Klasse hinzufüge, erhalte ich die Ausnahme unten. Dies ist eine selbst gehostete Exe, die von Mono (Ubuntu) läuft. Es funktioniert gut in Windows. Ich habe den UseCookieAuthentication-Aufruf eingeschränkt. Ich kann die Optionen ohne Probleme instanziieren. Irgendeine Idee, was hier vor sich geht? Ich habe Aspnet Identity arbeiten und EF6 / MySql.

%Vor%

Nicht behandelte Ausnahme: System.Reflection.TargetInvocationException: Vom Ziel eines Aufrufs wurde eine Ausnahme ausgelöst. --- & gt; System.TypeLoadException: Der Typ 'Microsoft.Owin.Security.DataProtection.DpapiDataProtector' konnte nicht von der Assembly 'Microsoft.Owin.Security, Version = 2.1.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35' geladen werden. bei Microsoft.Owin.Security.DataProtection.AppBuilderExtensions.CreateDataProtector (Owin.IAppBuilder, Zeichenfolge []) & lt; 0x00052 & gt; bei Microsoft.Owin.Security.Cookies.CookieAuthenticationMiddleware..ctor (Microsoft.Owin.OwinMiddleware, Owin.IAppBuilder, Microsoft.Owin.Security.Cookies.CookieAuthenticationOptions) & lt; 0x00223 & gt; at (wrapper dynamic-Methode) object.lambda_method (System.Runtime.CompilerServices.Closure, Microsoft.Owin.OwinMiddleware, Owin.IAppBuilder, Microsoft.Owin.Security.Cookies.CookieAuthenticationOptions) & lt; 0x00048 & gt; at (wrapper-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod, Objekt, Objekt [], System.Exception & amp;) & lt; 0x00067 & gt; bei System.Reflection.MonoMethod.Invoke (Objekt, System.Reflection.BindingFlags, System.Reflection.Binder, Objekt [], System.Globalization.CultureInfo) & lt; 0x000d7 & gt;

--- Ende der inneren Ausnahme-Stack-Spur ---   bei System.Reflection.MonoMethod.Invoke (System.Object-Objekt, BindingFlags-InvokeAttr, System.Reflection.Binder-Binder, System.Object [] -Parameter, System.Globalization.CultureInfo-Kultur) [0x00000] in: 0   bei System.Reflection.MethodBase.Invoke (System.Object-Objekt, System.Object [] -Parameter) [0x00000] in: 0   bei System.Delegate.DynamicInvokeImpl (System.Object [] args) [0x00000] in: 0   bei System.MulticastDelegate.DynamicInvokeImpl (System.Object [] args) [0x00000] in: 0   bei System.Delegate.DynamicInvoke (System.Object [] args) [0x00000] in: 0   bei Microsoft.Owin.Builder.AppBuilder.BuildInternal (System.Type-Signatur) [0x00000] in: 0   bei Microsoft.Owin.Builder.AppBuilder.Build (System.Type returnType) [0x00000] in: 0   Bei Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create (IAppBuilder-Builder) [0x00000] in: 0   bei Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer (Microsoft.Owin.Hosting.Engine.StartContext-Kontext) [0x00000] in: 0   bei Microsoft.Owin.Hosting.Engine.HostingEngine.Start (Microsoft.Owin.Hosting.Engine.StartContext-Kontext) [0x00000] in: 0   bei Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start (Optionen von Microsoft.Owin.Hosting.StartOptions) [0x00000] in: 0   unter Microsoft.Owin.Hosting.Starter.HostingStarter.Start (Microsoft.Owin.Hosting.StartOptions-Optionen) [0x00000] in: 0   bei Microsoft.Owin.Hosting.WebApp.StartImplementation (IServiceProvider-Dienste, Microsoft.Owin.Hosting.StartOptions-Optionen) [0x00000] in: 0   unter Microsoft.Owin.Hosting.WebApp.Start (Microsoft.Owin.Hosting.StartOptions-Optionen) [0x00000] in: 0   unter Microsoft.Owin.Hosting.WebApp.Start [Start] (Optionen von Microsoft.Owin.Hosting.StartOptions) [0x00000] in: 0   bei Microsoft.Owin.Hosting.WebApp.Start [Start] (System.String-URL) [0x00000] in: 0   bei HelloWorldNancy.Program.Main (System.String [] args) [0x00000] in: 0 [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Vom Ziel eines Aufrufs wurde eine Ausnahme ausgelöst. --- & gt; System.TypeLoadException: Der Typ 'Microsoft.Owin.Security.DataProtection.DpapiDataProtector' konnte nicht von der Assembly 'Microsoft.Owin.Security, Version = 2.1.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35' geladen werden. bei Microsoft.Owin.Security.DataProtection.AppBuilderExtensions.CreateDataProtector (Owin.IAppBuilder, Zeichenfolge []) & lt; 0x00052 & gt; bei Microsoft.Owin.Security.Cookies.CookieAuthenticationMiddleware..ctor (Microsoft.Owin.OwinMiddleware, Owin.IAppBuilder, Microsoft.Owin.Security.Cookies.CookieAuthenticationOptions) & lt; 0x00223 & gt; at (wrapper dynamic-Methode) object.lambda_method (System.Runtime.CompilerServices.Closure, Microsoft.Owin.OwinMiddleware, Owin.IAppBuilder, Microsoft.Owin.Security.Cookies.CookieAuthenticationOptions) & lt; 0x00048 & gt; at (wrapper-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod, Objekt, Objekt [], System.Exception & amp;) & lt; 0x00067 & gt; bei System.Reflection.MonoMethod.Invoke (Objekt, System.Reflection.BindingFlags, System.Reflection.Binder, Objekt [], System.Globalization.CultureInfo) & lt; 0x000d7 & gt;

--- Ende der inneren Ausnahme-Stack-Spur ---   bei System.Reflection.MonoMethod.Invoke (System.Object-Objekt, BindingFlags-InvokeAttr, System.Reflection.Binder-Binder, System.Object [] -Parameter, System.Globalization.CultureInfo-Kultur) [0x00000] in: 0   bei System.Reflection.MethodBase.Invoke (System.Object-Objekt, System.Object [] -Parameter) [0x00000] in: 0   bei System.Delegate.DynamicInvokeImpl (System.Object [] args) [0x00000] in: 0   bei System.MulticastDelegate.DynamicInvokeImpl (System.Object [] args) [0x00000] in: 0   bei System.Delegate.DynamicInvoke (System.Object [] args) [0x00000] in: 0   bei Microsoft.Owin.Builder.AppBuilder.BuildInternal (System.Type-Signatur) [0x00000] in: 0   bei Microsoft.Owin.Builder.AppBuilder.Build (System.Type returnType) [0x00000] in: 0   Bei Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create (IAppBuilder-Builder) [0x00000] in: 0   bei Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer (Microsoft.Owin.Hosting.Engine.StartContext-Kontext) [0x00000] in: 0   bei Microsoft.Owin.Hosting.Engine.HostingEngine.Start (Microsoft.Owin.Hosting.Engine.StartContext-Kontext) [0x00000] in: 0   bei Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start (Optionen von Microsoft.Owin.Hosting.StartOptions) [0x00000] in: 0   unter Microsoft.Owin.Hosting.Starter.HostingStarter.Start (Microsoft.Owin.Hosting.StartOptions-Optionen) [0x00000] in: 0   bei Microsoft.Owin.Hosting.WebApp.StartImplementation (IServiceProvider-Dienste, Microsoft.Owin.Hosting.StartOptions-Optionen) [0x00000] in: 0   unter Microsoft.Owin.Hosting.WebApp.Start (Microsoft.Owin.Hosting.StartOptions-Optionen) [0x00000] in: 0   unter Microsoft.Owin.Hosting.WebApp.Start [Start] (Optionen von Microsoft.Owin.Hosting.StartOptions) [0x00000] in: 0   bei Microsoft.Owin.Hosting.WebApp.Start [Start] (System.String-URL) [0x00000] in: 0   bei HelloWorldNancy.Program.Main (System.String [] args) [0x00000] in: 0

    
LRFalk01 30.05.2014, 00:21
quelle

1 Antwort

14

Okay, das passiert, weil OWIN DpapiDataProtector standardmäßig verwendet und DPAPI eine Windows-API (Data Protection API) ist und nicht in Mono funktioniert. Zum Glück können Sie den Standard in Ihren Cookie-Optionen überschreiben. Im Folgenden sehen Sie ein Beispiel, in dem AesDataProtectorProvider ein benutzerdefinierter IDataProtector ist, den ich hier gefunden habe: Verwenden von Oauth-Tickets über mehrere Dienstleistungen?

%Vor%

Mit diesem Code startet mein Projekt erneut in Mono.

UPDATE:

Sie können auch einen benutzerdefinierten IDataProtectionProvider haben und alle damit verwenden:

%Vor%     
LRFalk01 30.05.2014, 03:05
quelle

Tags und Links