Local Passwords validation
This commit is contained in:
@ -5,10 +5,12 @@ namespace Yavsc.Models.Auth {
|
||||
public class Scope {
|
||||
|
||||
|
||||
[Key]
|
||||
[Key][Required]
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
[MaxLength(1024)][Required]
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
}
|
||||
|
@ -65,9 +65,9 @@ namespace Yavsc.Helpers
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static UserDirectoryInfo GetUserFiles(string userName, string subdir)
|
||||
public static UserDirectoryInfo GetUserFiles(string userId, string subdir)
|
||||
{
|
||||
UserDirectoryInfo di = new UserDirectoryInfo(UserFilesDirName, userName, subdir);
|
||||
UserDirectoryInfo di = new UserDirectoryInfo(UserFilesDirName, userId, subdir);
|
||||
return di;
|
||||
}
|
||||
public static bool IsRegularFile(string userName, string subdir)
|
||||
@ -82,7 +82,7 @@ namespace Yavsc.Helpers
|
||||
|
||||
public static char[] AlfaNum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray();
|
||||
// Only accept descent remote file names
|
||||
public static char[] ValidFileNameChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_~. %#".ToCharArray();
|
||||
public static char[] ValidFileNameChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_~. %#@".ToCharArray();
|
||||
|
||||
// Estimate signature file name format
|
||||
public static Func<string, string, long, string>
|
||||
|
@ -23,12 +23,13 @@ namespace Yavsc.ViewModels.UserFiles
|
||||
{
|
||||
|
||||
}
|
||||
public UserDirectoryInfo(string userReposPath, string username, string path)
|
||||
|
||||
public UserDirectoryInfo(string userReposPath, string userId, string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(username))
|
||||
if (string.IsNullOrWhiteSpace(userId))
|
||||
throw new NotSupportedException("No user name, no user dir.");
|
||||
UserName = username;
|
||||
var finalPath = path == null ? username : Path.Combine(username, path);
|
||||
UserName = userId;
|
||||
var finalPath = path == null ? userId : Path.Combine(userId, path);
|
||||
if (!finalPath.IsValidYavscPath())
|
||||
throw new InvalidOperationException(
|
||||
$"File name contains invalid chars ({finalPath})");
|
||||
|
Reference in New Issue
Block a user