Esempio n. 1
0
 /// <param name="args">The <see cref="JwtServiceArgs" /> to use, default null</param>
 public JwtService(JwtServiceArgs args = null)
 {
     _args = args == null
                         ? new JwtServiceArgs()
                         : args;
     _secureSecret = _args?.SecureSecret?.ToPlainText()?.ToSecureString();
     _secureSecret = _secureSecret ?? _args.Secret?.ToSecureString();
     _args.Secret  = null;
     _args.SecureSecret?.Dispose();
     _args.SecureSecret = null;
 }
        /// <summary>
        /// Adds a new <see cref="JwtService" /> with the passed args as a Singleton to the passed <see cref="IServiceCollection" />
        /// </summary>
        /// <param name="serviceCollection">The current <see cref="IServiceCollection" /></param>
        /// <param name="args">The arguments to create the <see cref="JwtService" /> with</param>
        /// <returns>The current <see cref="IServiceCollection" /></returns>
        public static IServiceCollection AddJwtService(this IServiceCollection serviceCollection, JwtServiceArgs args)
        {
            JwtService service = new JwtService(args);

            serviceCollection.AddSingleton(service);

            return(serviceCollection);
        }
        /// <summary>
        /// Adds a new <see cref="JwtService" /> with defaults as a Singleton to the passed <see cref="IServiceCollection" />
        /// </summary>
        /// <param name="serviceCollection">The current <see cref="IServiceCollection" /></param>
        /// <returns>The current <see cref="IServiceCollection" /></returns>
        public static IServiceCollection AddJwtService(this IServiceCollection serviceCollection)
        {
            JwtServiceArgs args = new JwtServiceArgs();

            return(serviceCollection.AddJwtService(args));
        }