added python variant of s3cmd
This commit is contained in:
parent
0f7daea8ea
commit
083c412177
|
@ -27,4 +27,18 @@
|
||||||
<ProjectReference Include="../../Lib/Utils/Utils.csproj" />
|
<ProjectReference Include="../../Lib/Utils/Utils.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Resources" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="Resources\s3cmd.py">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -59,7 +59,8 @@ public class Controller
|
||||||
|
|
||||||
if (user is null || !caller.HasAccessTo(user))
|
if (user is null || !caller.HasAccessTo(user))
|
||||||
return _Unauthorized;
|
return _Unauthorized;
|
||||||
|
|
||||||
|
user.Password = "";
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,9 +201,9 @@ public class Controller
|
||||||
{
|
{
|
||||||
var session = GetSession();
|
var session = GetSession();
|
||||||
|
|
||||||
return session.Update(updatedUser)
|
if (!session.Update(updatedUser)) return _Unauthorized;
|
||||||
? updatedUser
|
updatedUser.Password = "";
|
||||||
: _Unauthorized;
|
return updatedUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,32 @@ public static class InstallationMethods
|
||||||
//secret 55MAqyO_FqUmh7O64VIO0egq50ERn_WIAWuc2QC44QU
|
//secret 55MAqyO_FqUmh7O64VIO0egq50ERn_WIAWuc2QC44QU
|
||||||
const String apiKey = "EXO44d2979c8e570eae81ead564";
|
const String apiKey = "EXO44d2979c8e570eae81ead564";
|
||||||
const String salt = "3e5b3069-214a-43ee-8d85-57d72000c19d";
|
const String salt = "3e5b3069-214a-43ee-8d85-57d72000c19d";
|
||||||
|
if (Environment.OSVersion.Platform != PlatformID.Unix)
|
||||||
|
{
|
||||||
|
var cmd = Cli
|
||||||
|
.Wrap("s3cmd")
|
||||||
|
.WithArguments(new[]
|
||||||
|
{
|
||||||
|
"signurl", $"s3://{installation.Id}-{salt}", validity.TotalSeconds.ToString(), "--access_key",
|
||||||
|
apiKey
|
||||||
|
});
|
||||||
|
|
||||||
|
var x = await cmd.ExecuteBufferedAsync();
|
||||||
|
installation.S3Url = x.StandardOutput.Replace("\n", "").Replace(" ", "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var cmd = Cli
|
||||||
|
.Wrap("python3")
|
||||||
|
.WithArguments(new[]
|
||||||
|
{
|
||||||
|
"Resources/s3cmd.py", "signurl", $"s3://{installation.Id}-{salt}", validity.TotalSeconds.ToString(), "--access_key",
|
||||||
|
apiKey
|
||||||
|
});
|
||||||
|
var x = await cmd.ExecuteBufferedAsync();
|
||||||
|
installation.S3Url = x.StandardOutput.Replace("\n", "").Replace(" ", "");
|
||||||
|
}
|
||||||
|
|
||||||
var cmd = Cli
|
|
||||||
.Wrap("s3cmd")
|
|
||||||
.WithArguments(new[] { "signurl",$"s3://{installation.Id}-{salt}", validity.TotalSeconds.ToString(), "--access_key", apiKey});
|
|
||||||
|
|
||||||
var x = await cmd.ExecuteBufferedAsync();
|
|
||||||
installation.S3Url = x.StandardOutput.Replace("\n", "").Replace(" ", "");
|
|
||||||
|
|
||||||
Console.WriteLine(installation.S3Url);
|
Console.WriteLine(installation.S3Url);
|
||||||
|
|
||||||
Db.Update(installation);
|
Db.Update(installation);
|
||||||
|
|
|
@ -95,7 +95,7 @@ public static class SessionMethods
|
||||||
&& editedUser is not null
|
&& editedUser is not null
|
||||||
&& sessionUser.HasWriteAccess
|
&& sessionUser.HasWriteAccess
|
||||||
&& sessionUser.HasAccessTo(editedUser)
|
&& sessionUser.HasAccessTo(editedUser)
|
||||||
&& (editedUser.IsRelativeRoot() || sessionUser.HasAccessTo(editedUser.Parent())) // TODO: triple check this
|
//&& (editedUser.IsRelativeRoot() || sessionUser.HasAccessTo(editedUser.Parent())) // TODO: triple check this
|
||||||
&& Db.Update(editedUser);
|
&& Db.Update(editedUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,9 @@ public static class UserMethods
|
||||||
{
|
{
|
||||||
if (other is null)
|
if (other is null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (other.Id == user.Id)
|
||||||
|
return true;
|
||||||
|
|
||||||
return other
|
return other
|
||||||
.Ancestors()
|
.Ancestors()
|
||||||
|
|
|
@ -40,7 +40,10 @@ public static partial class Db
|
||||||
public static Boolean Update(User user)
|
public static Boolean Update(User user)
|
||||||
{
|
{
|
||||||
var originalUser = GetUserById(user.Id);
|
var originalUser = GetUserById(user.Id);
|
||||||
|
|
||||||
|
//Todo change password backend
|
||||||
|
user.Password = originalUser.Password;
|
||||||
|
|
||||||
return originalUser is not null
|
return originalUser is not null
|
||||||
&& user.Id == originalUser.Id // these columns must not be modified!
|
&& user.Id == originalUser.Id // these columns must not be modified!
|
||||||
&& user.ParentId == originalUser.ParentId
|
&& user.ParentId == originalUser.ParentId
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue