public JWTAuthenticationMiddleware(IDeserializerStrategy deserializer, ISerializerStrategy serializer, ITokenRegistry tokenRegistry) { if (deserializer == null) { throw new ArgumentNullException(nameof(deserializer)); } if (serializer == null) { throw new ArgumentNullException(nameof(serializer)); } if (tokenRegistry == null) { throw new ArgumentNullException(nameof(tokenRegistry)); } deserializerStrategy = deserializer; serializerStrategy = serializer; tokenRegistryService = tokenRegistry; }
/// <summary> /// Registers the Middlewares required for authentication. /// </summary> /// <typeparam name="TMiddlewareRegistryType"></typeparam> /// <param name="middlewarRegistry"></param> /// <param name="serializer"></param> /// <param name="deserializer"></param> /// <param name="tokenRegister"></param> /// <returns>Registy to fluently chain on.</returns> public static TMiddlewareRegistryType RegisterAuthenticationMiddleware <TMiddlewareRegistryType>(this TMiddlewareRegistryType middlewarRegistry, ISerializerStrategy serializer, IDeserializerStrategy deserializer, ITokenRegistry tokenRegister) where TMiddlewareRegistryType : IMiddlewareRegistry { //Register the middlewares middlewarRegistry.Register(new JWTAuthenticationMiddleware(deserializer, serializer, tokenRegister)); //return for fluent chaining return(middlewarRegistry); }