Compare commits
No commits in common. "52ba183846acdf64bed69c2058c4084dbe0d14a5" and "327874d396db707d45fc6abdb3c69f5294ad55c8" have entirely different histories.
52ba183846
...
327874d396
|
|
@ -33,10 +33,6 @@ using ZiggyCreatures.Caching.Fusion;
|
||||||
using AlibabaCloud.SDK.Sts20150401;
|
using AlibabaCloud.SDK.Sts20150401;
|
||||||
using AlibabaCloud.SDK.Sts20150401.Models;
|
using AlibabaCloud.SDK.Sts20150401.Models;
|
||||||
using Org.BouncyCastle.Tls;
|
using Org.BouncyCastle.Tls;
|
||||||
using Amazon.SecurityToken.Model;
|
|
||||||
using Amazon.SecurityToken;
|
|
||||||
using Amazon;
|
|
||||||
using AssumeRoleRequest = Amazon.SecurityToken.Model.AssumeRoleRequest;
|
|
||||||
|
|
||||||
namespace IRaCIS.Api.Controllers
|
namespace IRaCIS.Api.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -106,10 +102,10 @@ namespace IRaCIS.Api.Controllers
|
||||||
public async Task<IResponseOutput> Login(UserLoginDTO loginUser,
|
public async Task<IResponseOutput> Login(UserLoginDTO loginUser,
|
||||||
[FromServices] IFusionCache _fusionCache,
|
[FromServices] IFusionCache _fusionCache,
|
||||||
[FromServices] IUserService _userService,
|
[FromServices] IUserService _userService,
|
||||||
[FromServices] ITokenService _tokenService,
|
[FromServices] ITokenService _tokenService,
|
||||||
[FromServices] IReadingImageTaskService readingImageTaskService,
|
[FromServices] IReadingImageTaskService readingImageTaskService,
|
||||||
[FromServices] IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig,
|
[FromServices] IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig,
|
||||||
[FromServices] IMailVerificationService _mailVerificationService)
|
[FromServices] IMailVerificationService _mailVerificationService)
|
||||||
{
|
{
|
||||||
|
|
||||||
//MFA 邮箱验证 前端传递用户Id 和MFACode
|
//MFA 邮箱验证 前端传递用户Id 和MFACode
|
||||||
|
|
@ -297,7 +293,7 @@ namespace IRaCIS.Api.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("user/GetObjectStoreToken")]
|
[HttpGet("user/GetObjectStoreToken")]
|
||||||
public async Task<IResponseOutput> GetObjectStoreTokenAsync([FromServices] IOptionsMonitor<ObjectStoreServiceOptions> options)
|
public IResponseOutput GetObjectStoreToken([FromServices] IOptionsMonitor<ObjectStoreServiceOptions> options)
|
||||||
{
|
{
|
||||||
var serviceOption = options.CurrentValue;
|
var serviceOption = options.CurrentValue;
|
||||||
|
|
||||||
|
|
@ -348,45 +344,11 @@ namespace IRaCIS.Api.Controllers
|
||||||
}
|
}
|
||||||
else if (Enum.TryParse<ObjectStoreUse>(serviceOption.ObjectStoreUse, out var parsedValue) && parsedValue == ObjectStoreUse.MinIO)
|
else if (Enum.TryParse<ObjectStoreUse>(serviceOption.ObjectStoreUse, out var parsedValue) && parsedValue == ObjectStoreUse.MinIO)
|
||||||
{
|
{
|
||||||
return ResponseOutput.Ok(new ObjectStoreDTO() { ObjectStoreUse = serviceOption.ObjectStoreUse, MinIO = serviceOption.MinIO});
|
return ResponseOutput.Ok(new ObjectStoreDTO() { ObjectStoreUse = serviceOption.ObjectStoreUse, MinIO = serviceOption.MinIO, AWS = serviceOption.AWS });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var awsOptions = serviceOption.AWS;
|
return ResponseOutput.Ok(new ObjectStoreDTO() { ObjectStoreUse = serviceOption.ObjectStoreUse, MinIO = serviceOption.MinIO, AWS = serviceOption.AWS });
|
||||||
|
|
||||||
//aws 临时凭证
|
|
||||||
// 创建 STS 客户端
|
|
||||||
var stsClient = new AmazonSecurityTokenServiceClient(awsOptions.AccessKeyId, awsOptions.SecretAccessKey);
|
|
||||||
|
|
||||||
// 使用 AssumeRole 请求临时凭证
|
|
||||||
var assumeRoleRequest = new AssumeRoleRequest
|
|
||||||
{
|
|
||||||
|
|
||||||
RoleArn = awsOptions.RoleArn, // 角色 ARN
|
|
||||||
RoleSessionName = $"session-name-{NewId.NextGuid()}",
|
|
||||||
DurationSeconds = awsOptions.DurationSeconds // 临时凭证有效期
|
|
||||||
};
|
|
||||||
|
|
||||||
var assumeRoleResponse = await stsClient.AssumeRoleAsync(assumeRoleRequest);
|
|
||||||
|
|
||||||
var credentials = assumeRoleResponse.Credentials;
|
|
||||||
|
|
||||||
var tempToken = new AWSTempToken()
|
|
||||||
{
|
|
||||||
AccessKeyId = credentials.AccessKeyId,
|
|
||||||
SecretAccessKey = credentials.SecretAccessKey,
|
|
||||||
SessionToken= credentials.SessionToken,
|
|
||||||
Expiration=credentials.Expiration,
|
|
||||||
|
|
||||||
BucketName = awsOptions.BucketName,
|
|
||||||
EndPoint = awsOptions.EndPoint,
|
|
||||||
ViewEndpoint = awsOptions.ViewEndpoint,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ResponseOutput.Ok(new ObjectStoreDTO() { ObjectStoreUse = serviceOption.ObjectStoreUse, MinIO = serviceOption.MinIO, AWS = tempToken });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@
|
||||||
<PackageReference Include="AlibabaCloud.SDK.Sts20150401" Version="1.1.4" />
|
<PackageReference Include="AlibabaCloud.SDK.Sts20150401" Version="1.1.4" />
|
||||||
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
|
||||||
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.400.13" />
|
|
||||||
<PackageReference Include="ConfigMapFileProvider" Version="2.0.1" />
|
<PackageReference Include="ConfigMapFileProvider" Version="2.0.1" />
|
||||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.14" />
|
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.14" />
|
||||||
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />
|
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,10 @@
|
||||||
"AWS": {
|
"AWS": {
|
||||||
"EndPoint": "s3.us-east-1.amazonaws.com",
|
"EndPoint": "s3.us-east-1.amazonaws.com",
|
||||||
"UseSSL": true,
|
"UseSSL": true,
|
||||||
"RoleArn": "arn:aws:iam::471112624751:role/sts_s3_upload",
|
"AccessKey": "AKIAZQ3DRSOHFPJJ6FEU",
|
||||||
"AccessKeyId": "AKIAW3MEAFJXWRCGSX5Z",
|
"SecretKey": "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",
|
||||||
"SecretAccessKey": "miais4jQGSd37A+TfBEP11AQM5u/CvotSmznJd8k",
|
"BucketName": "ei-irc-test-store",
|
||||||
"BucketName": "ei-med-s3-lili-uat-store",
|
"ViewEndpoint": "https://ei-irc-test-store.s3.amazonaws.com/"
|
||||||
"ViewEndpoint": "https://ei-med-s3-lili-uat-store.s3.amazonaws.com/",
|
|
||||||
"DurationSeconds": 7200
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,17 +30,15 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[LowerCamelCaseJson]
|
||||||
public class AWSOptions
|
public class AWSOptions
|
||||||
{
|
{
|
||||||
public string EndPoint { get; set; }
|
public string EndPoint { get; set; }
|
||||||
public bool UseSSL { get; set; }
|
public bool UseSSL { get; set; }
|
||||||
public string AccessKeyId { get; set; }
|
public string AccessKey { get; set; }
|
||||||
public string RoleArn { get; set; }
|
public string SecretKey { get; set; }
|
||||||
public string SecretAccessKey { get; set; }
|
|
||||||
public string BucketName { get; set; }
|
public string BucketName { get; set; }
|
||||||
public string ViewEndpoint { get; set; }
|
public string ViewEndpoint { get; set; }
|
||||||
public int DurationSeconds { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AliyunOSSOptions
|
public class AliyunOSSOptions
|
||||||
|
|
@ -62,7 +60,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
|
|
||||||
public int DurationSeconds { get; set; }
|
public int DurationSeconds { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,7 +86,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
|
|
||||||
public MinIOOptions MinIO { get; set; }
|
public MinIOOptions MinIO { get; set; }
|
||||||
|
|
||||||
public AWSTempToken AWS { get; set; }
|
public AWSOptions AWS { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,24 +106,14 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
public string ViewEndpoint { get; set; }
|
public string ViewEndpoint { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public string SecurityToken { get; set; }
|
public string SecurityToken { get; set; }
|
||||||
public string Expiration { get; set; }
|
public string Expiration { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[LowerCamelCaseJson]
|
|
||||||
public class AWSTempToken
|
|
||||||
{
|
|
||||||
public string SessionToken { get; set; }
|
|
||||||
public string EndPoint { get; set; }
|
|
||||||
public string AccessKeyId { get; set; }
|
|
||||||
public string SecretAccessKey { get; set; }
|
|
||||||
public string BucketName { get; set; }
|
|
||||||
public string ViewEndpoint { get; set; }
|
|
||||||
public DateTime Expiration { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ObjectStoreUse
|
public enum ObjectStoreUse
|
||||||
{
|
{
|
||||||
|
|
@ -202,7 +190,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
|
|
||||||
|
|
||||||
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
||||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var putObjectArgs = new PutObjectArgs()
|
var putObjectArgs = new PutObjectArgs()
|
||||||
|
|
@ -219,7 +207,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
|
|
||||||
|
|
||||||
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
|
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
|
||||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var putObjectArgs = new PutObjectArgs()
|
var putObjectArgs = new PutObjectArgs()
|
||||||
|
|
@ -284,7 +272,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
|
|
||||||
|
|
||||||
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
||||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var putObjectArgs = new PutObjectArgs()
|
var putObjectArgs = new PutObjectArgs()
|
||||||
|
|
@ -300,7 +288,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
|
|
||||||
|
|
||||||
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
|
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
|
||||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var putObjectArgs = new PutObjectArgs()
|
var putObjectArgs = new PutObjectArgs()
|
||||||
|
|
@ -349,7 +337,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
var minIOConfig = ObjectStoreServiceOptions.MinIO;
|
var minIOConfig = ObjectStoreServiceOptions.MinIO;
|
||||||
|
|
||||||
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
||||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var getObjectArgs = new GetObjectArgs()
|
var getObjectArgs = new GetObjectArgs()
|
||||||
|
|
@ -365,7 +353,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
var minIOConfig = ObjectStoreServiceOptions.AWS;
|
var minIOConfig = ObjectStoreServiceOptions.AWS;
|
||||||
|
|
||||||
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
|
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
|
||||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var getObjectArgs = new GetObjectArgs()
|
var getObjectArgs = new GetObjectArgs()
|
||||||
|
|
@ -421,7 +409,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
var minIOConfig = ObjectStoreServiceOptions.MinIO;
|
var minIOConfig = ObjectStoreServiceOptions.MinIO;
|
||||||
|
|
||||||
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
||||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -446,7 +434,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
var minIOConfig = ObjectStoreServiceOptions.AWS;
|
var minIOConfig = ObjectStoreServiceOptions.AWS;
|
||||||
|
|
||||||
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
|
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}")
|
||||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var args = new PresignedGetObjectArgs()
|
var args = new PresignedGetObjectArgs()
|
||||||
|
|
@ -530,7 +518,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
|
|
||||||
|
|
||||||
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
||||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey).WithSSL(minIOConfig.UseSSL)
|
.WithCredentials(minIOConfig.AccessKey, minIOConfig.SecretKey).WithSSL(minIOConfig.UseSSL)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue