/// <summary>
        /// Configure authentication.
        /// </summary>
        /// <param name="builder">The FTP server builder.</param>
        /// <param name="options">The options.</param>
        /// <returns>The FTP server builder.</returns>
        public static IFtpServerBuilder ConfigureAuthentication(
            this IFtpServerBuilder builder,
            FtpOptions options)
        {
            if (options.Authentication == MembershipProviderType.Default)
            {
                return(builder.EnableAnonymousAuthentication());
            }

            if ((options.Authentication & MembershipProviderType.Custom) != 0)
            {
                builder.Services.AddSingleton <IMembershipProvider, CustomMembershipProvider>();
            }

#if NETCOREAPP
            if ((options.Authentication & MembershipProviderType.PAM) != 0)
            {
                builder = builder.EnablePamAuthentication();
            }
#endif

            if ((options.Authentication & MembershipProviderType.Anonymous) != 0)
            {
                builder = builder.EnableAnonymousAuthentication();
            }

            return(builder);
        }
Beispiel #2
0
        private static IFtpServerBuilder Configure(IFtpServerBuilder builder, TestFtpServerOptions options)
        {
            switch (options.MembershipProviderType)
            {
            case MembershipProviderType.Anonymous:
                return(builder.EnableAnonymousAuthentication());

            case MembershipProviderType.Custom:
                builder.Services.AddSingleton <IMembershipProvider, CustomMembershipProvider>();
                break;

            default:
                throw new InvalidOperationException($"Unknown membership provider {options.MembershipProviderType}");
            }

            return(builder);
        }
Beispiel #3
0
 private static IFtpServerBuilder Configure(IFtpServerBuilder builder)
 {
     return(builder.EnableAnonymousAuthentication());
 }