parse all available .access in the path

This commit is contained in:
2020-10-11 01:45:45 +01:00
parent 2c6b010d46
commit c6183ccafb
2 changed files with 13 additions and 7 deletions

View File

@ -57,11 +57,15 @@ namespace Yavsc.Services
_logger.LogInformation("Serving file to owner."); _logger.LogInformation("Serving file to owner.");
return FileAccessRight.Read | FileAccessRight.Write; return FileAccessRight.Read | FileAccessRight.Write;
} }
var aclfi = new FileInfo(Path.Combine(Environment.CurrentDirectory, fileDir, aclfileName));
// TODO default user scoped file access policy
if (!aclfi.Exists) return FileAccessRight.Read;
ruleSetParser.Reset(); ruleSetParser.Reset();
ruleSetParser.ParseFile(aclfi.FullName); for (int dirlevel = parts.Length - 1; dirlevel>0; dirlevel--)
{
var aclfi = new FileInfo(Path.Combine(Environment.CurrentDirectory, fileDir, aclfileName));
if (!aclfi.Exists) continue;
ruleSetParser.ParseFile(aclfi.FullName);
}
// TODO default user scoped file access policy
if (ruleSetParser.Rules.Allow(user.GetUserName())) if (ruleSetParser.Rules.Allow(user.GetUserName()))
return FileAccessRight.Read; return FileAccessRight.Read;

View File

@ -105,9 +105,11 @@ namespace Yavsc
var claims = new List<Claim>( var claims = new List<Claim>(
context.Scope.Select(x => new Claim("urn:oauth:scope", x)) context.Scope.Select(x => new Claim("urn:oauth:scope", x))
); )
claims.Add(new Claim(ClaimTypes.NameIdentifier, user.Id)); {
claims.Add(new Claim(ClaimTypes.Email, user.Email)); new Claim(ClaimTypes.NameIdentifier, user.Id),
new Claim(ClaimTypes.Email, user.Email)
};
claims.AddRange((await _usermanager.GetRolesAsync(user)).Select( claims.AddRange((await _usermanager.GetRolesAsync(user)).Select(
r => new Claim(ClaimTypes.Role, r) r => new Claim(ClaimTypes.Role, r)
)); ));