private static string?GetAuthenticationType(IFtpUser user) { return(user switch { IAnonymousFtpUser _ => "anonymous", IUnixUser _ => "pam", PasswordAuthorization.UnauthenticatedUser _ => null, _ => "custom" });
private IAccountDirectories GetAnonymousDirectories(IAnonymousFtpUser ftpUser) { var rootPath = _anonymousRoot; if (_anonymousRootPerEmail) { if (string.IsNullOrEmpty(ftpUser.Email)) { _logger?.LogWarning("Anonymous root per email is configured, but got anonymous user without email. This anonymous user will see the files of all other anonymous users!"); } else { rootPath = Path.Combine(rootPath, ftpUser.Email); } } return(new GenericAccountDirectories(rootPath)); }
private IAccountDirectories GetAnonymousDirectories([NotNull] IAnonymousFtpUser ftpUser) { var rootPath = _anonymousRootDirectory; if (string.IsNullOrEmpty(rootPath)) { _logger?.LogError("Anonymous users aren't supported, because PamAccountDirectoryQueryOptions.AnonymousRootDirectory isn't set."); throw new InvalidOperationException("Anonymous users aren't supported, because PamAccountDirectoryQueryOptions.AnonymousRootDirectory isn't set."); } if (_anonymousRootPerEmail) { if (string.IsNullOrEmpty(ftpUser.Email)) { _logger?.LogWarning("Anonymous root per email is configured, but got anonymous user without email. This anonymous user will see the files of all other anonymous users!"); } else { rootPath = Path.Combine(rootPath, ftpUser.Email); } } return(new GenericAccountDirectories(rootPath)); }