New Buckets now have cors
This commit is contained in:
parent
6c71b77482
commit
9a2990f750
|
@ -6,7 +6,9 @@ using System.Net;
|
|||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Text.Json.Nodes;
|
||||
using Amazon.S3.Model;
|
||||
using InnovEnergy.App.Backend.Database;
|
||||
using InnovEnergy.Lib.Utils;
|
||||
|
||||
namespace InnovEnergy.App.Backend.DataTypes.Methods;
|
||||
|
||||
|
@ -245,8 +247,14 @@ public static class ExoCmd
|
|||
|
||||
public static async Task<Boolean> CreateBucket(this Installation installation)
|
||||
{
|
||||
var cors = new CORSConfiguration();
|
||||
cors.Rules.Add(new CORSRule());
|
||||
cors.Rules[0].AllowedHeaders = new List<string> { "*" };
|
||||
cors.Rules[0].AllowedOrigins = new List<string> { "*" };
|
||||
cors.Rules[0].AllowedMethods = new List<string> { "Get", "Head" };
|
||||
var s3Region = new S3Region($"https://{installation.S3Region}.{installation.S3Provider}", S3Creds!);
|
||||
return await s3Region.PutBucket(installation.BucketName()) != null;
|
||||
var a = await s3Region.PutBucket(installation.BucketName());
|
||||
return a != null && await a.PutCors(cors);
|
||||
}
|
||||
|
||||
public static async Task<Boolean> SendConfig(this Installation installation, String config)
|
||||
|
|
|
@ -102,7 +102,8 @@ public static class SessionMethods
|
|||
&& installation.SetOrderNumbers()
|
||||
&& Db.Create(new InstallationAccess { UserId = user.Id, InstallationId = installation.Id })
|
||||
&& await installation.CreateBucket()
|
||||
&& await installation.RenewS3Credentials(); // generation of access _after_ generation of
|
||||
&& await installation.RenewS3Credentials();
|
||||
// generation of access _after_ generation of
|
||||
// bucket to prevent "zombie" access-rights.
|
||||
// This might ** us over if the creation of access rights fails,
|
||||
// as bucket-names are unique and bound to the installation id... -K
|
||||
|
|
Loading…
Reference in New Issue