Skip to content

Commit 0b1b1da

Browse files
committed
removed logger
1 parent 66dea32 commit 0b1b1da

File tree

3 files changed

+9
-64
lines changed

3 files changed

+9
-64
lines changed

server/Controllers/VaultItemController.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public async Task<ActionResult<VaultItemResponseDTO>> CreateItem(int vaultId, [F
7575
if (Request.Form.ContainsKey("visibilities"))
7676
{
7777
var visibilitiesJson = Request.Form["visibilities"].ToString();
78-
_logger.LogInformation("Received visibilities JSON for vault {VaultId}: {Json}", vaultId, visibilitiesJson);
78+
// Don't log JSON content in production to avoid exposing sensitive data
7979
if (!string.IsNullOrEmpty(visibilitiesJson))
8080
{
8181
try
@@ -87,14 +87,7 @@ public async Task<ActionResult<VaultItemResponseDTO>> CreateItem(int vaultId, [F
8787
Converters = { new JsonStringEnumConverter(namingPolicy: null) }
8888
};
8989
dto.Visibilities = JsonSerializer.Deserialize<List<ItemVisibilityDTO>>(visibilitiesJson, options);
90-
_logger.LogInformation("Deserialized {Count} visibility entries for vault {VaultId}", dto.Visibilities?.Count ?? 0, vaultId);
91-
if (dto.Visibilities != null)
92-
{
93-
foreach (var v in dto.Visibilities)
94-
{
95-
_logger.LogInformation("Visibility: VaultMemberId={VaultMemberId}, Permission={Permission}", v.VaultMemberId, v.Permission);
96-
}
97-
}
90+
// Don't log detailed visibility information in production
9891
}
9992
catch (Exception ex)
10093
{
@@ -141,7 +134,7 @@ public async Task<ActionResult<VaultItemResponseDTO>> UpdateItem(int vaultId, in
141134
if (Request.Form.ContainsKey("visibilities"))
142135
{
143136
var visibilitiesJson = Request.Form["visibilities"].ToString();
144-
_logger.LogInformation("Received visibilities JSON for update item {ItemId} in vault {VaultId}: {Json}", itemId, vaultId, visibilitiesJson);
137+
// Don't log JSON content in production to avoid exposing sensitive data
145138
if (!string.IsNullOrEmpty(visibilitiesJson))
146139
{
147140
try
@@ -153,14 +146,7 @@ public async Task<ActionResult<VaultItemResponseDTO>> UpdateItem(int vaultId, in
153146
Converters = { new JsonStringEnumConverter(namingPolicy: null) }
154147
};
155148
dto.Visibilities = JsonSerializer.Deserialize<List<ItemVisibilityDTO>>(visibilitiesJson, options);
156-
_logger.LogInformation("Deserialized {Count} visibility entries for update item {ItemId}", dto.Visibilities?.Count ?? 0, itemId);
157-
if (dto.Visibilities != null)
158-
{
159-
foreach (var v in dto.Visibilities)
160-
{
161-
_logger.LogInformation("Visibility: VaultMemberId={VaultMemberId}, Permission={Permission}", v.VaultMemberId, v.Permission);
162-
}
163-
}
149+
// Don't log detailed visibility information in production
164150
}
165151
catch (Exception ex)
166152
{

server/Services/CloudflareR2Service.cs

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,12 @@ public CloudflareR2Service(IConfiguration configuration, ILogger<CloudflareR2Ser
3838
endpoint, _bucketName
3939
);
4040

41-
_logger.LogInformation(
42-
"Access Key ID: {Preview} | Length: {Length}",
43-
accessKeyId.Length > 8 ? accessKeyId[..8] + "..." : "***", accessKeyId.Length
44-
);
41+
// Don't log access key details in production
4542

4643
// Extract Account ID from endpoint (for diagnostics only)
4744
var match = Regex.Match(endpoint, @"https://([a-f0-9]+)\.r2\.cloudflarestorage\.com");
4845
_accountId = match.Success ? match.Groups[1].Value : "unknown";
4946

50-
_logger.LogInformation("Detected R2 Account ID: {AccountId}", _accountId);
51-
5247
// Initialize MinIO client for Cloudflare R2
5348
var endpointUri = new Uri(endpoint);
5449
_minioClient = new MinioClient()
@@ -67,17 +62,13 @@ public async Task<string> UploadFileAsync(
6762
{
6863
try
6964
{
70-
_logger.LogInformation("Starting upload to R2: {ObjectKey}, Size: {Size} bytes, ContentType: {ContentType}",
71-
objectKey, file.Length, file.ContentType);
72-
7365
// Ensure bucket exists
7466
var bucketExists = await _minioClient.BucketExistsAsync(
7567
new BucketExistsArgs().WithBucket(_bucketName),
7668
cancellationToken);
7769

7870
if (!bucketExists)
7971
{
80-
_logger.LogWarning("Bucket {BucketName} does not exist, creating it...", _bucketName);
8172
await _minioClient.MakeBucketAsync(
8273
new MakeBucketArgs().WithBucket(_bucketName),
8374
cancellationToken);
@@ -94,12 +85,10 @@ await _minioClient.PutObjectAsync(
9485
.WithContentType(file.ContentType),
9586
cancellationToken);
9687

97-
_logger.LogInformation("Successfully uploaded object {Key} to R2", objectKey);
9888
return objectKey;
9989
}
10090
catch (Exception ex)
10191
{
102-
_logger.LogError(ex, "Error uploading file to R2: {ObjectKey}", objectKey);
10392
throw;
10493
}
10594
}
@@ -115,12 +104,10 @@ await _minioClient.RemoveObjectAsync(
115104
.WithBucket(_bucketName)
116105
.WithObject(objectKey),
117106
cancellationToken);
118-
_logger.LogInformation("Successfully deleted object {Key} from R2", objectKey);
119107
return true;
120108
}
121109
catch (Exception ex)
122110
{
123-
_logger.LogError(ex, "Error deleting file from R2: {ObjectKey}", objectKey);
124111
return false;
125112
}
126113
}
@@ -141,7 +128,6 @@ public async Task<string> GetPresignedUrlAsync(
141128
}
142129
catch (Exception ex)
143130
{
144-
_logger.LogError(ex, "Error generating presigned URL for R2: {ObjectKey}", objectKey);
145131
throw;
146132
}
147133
}
@@ -167,7 +153,6 @@ await _minioClient.GetObjectAsync(
167153
}
168154
catch (Exception ex)
169155
{
170-
_logger.LogError(ex, "Error getting file stream from R2: {ObjectKey}", objectKey);
171156
throw;
172157
}
173158
}
@@ -176,51 +161,26 @@ public async Task<bool> TestConnectionAsync(CancellationToken cancellationToken
176161
{
177162
try
178163
{
179-
_logger.LogInformation(
180-
"Testing R2 connection by checking bucket {Bucket}",
181-
_bucketName
182-
);
183-
184164
var exists = await _minioClient.BucketExistsAsync(
185165
new BucketExistsArgs().WithBucket(_bucketName),
186166
cancellationToken);
187167

188168
if (exists)
189169
{
190-
_logger.LogInformation("R2 connection test successful - bucket {Bucket} exists", _bucketName);
170+
_logger.LogInformation("R2 connection test successful - bucket exists");
191171
}
192172
else
193173
{
194-
_logger.LogWarning("Bucket {Bucket} does not exist, but connection is working", _bucketName);
174+
_logger.LogWarning("Bucket does not exist, but connection is working");
195175
}
196176

197177
return true;
198178
}
199179
catch (Exception ex)
200180
{
201181
_logger.LogError(
202-
ex,
203-
"R2 connection test failed | Message: {Message}",
204-
ex.Message
182+
"R2 connection test failed"
205183
);
206-
207-
if (ex.Message.Contains("InvalidAccessKeyId") || ex.Message.Contains("Access Denied") || ex.Message.Contains("403"))
208-
{
209-
_logger.LogError("═══════════════════════════════════════════════════════════");
210-
_logger.LogError("R2 AUTHENTICATION ERROR");
211-
_logger.LogError("═══════════════════════════════════════════════════════════");
212-
_logger.LogError("The Access Key ID does not exist in Cloudflare R2 records.");
213-
_logger.LogError("");
214-
_logger.LogError("TROUBLESHOOTING STEPS:");
215-
_logger.LogError("1. Verify your endpoint Account ID: {AccountId}", _accountId);
216-
_logger.LogError("2. Go to Cloudflare Dashboard → R2 → Manage R2 API Tokens");
217-
_logger.LogError("3. Check which Account ID your API token was created for");
218-
_logger.LogError("4. If different, create a NEW API token for Account ID: {AccountId}", _accountId);
219-
_logger.LogError("5. Update appsettings.Development.json with the new credentials");
220-
_logger.LogError("6. Ensure the token has 'Object Read & Write' permissions");
221-
_logger.LogError("═══════════════════════════════════════════════════════════");
222-
}
223-
224184
return false;
225185
}
226186
}

server/Services/VaultItemService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,7 @@ private async Task SetItemVisibilitiesAsync(int itemId, List<ItemVisibilityDTO>
544544
};
545545
_dbContext.VaultItemVisibilities.Add(itemVisibility);
546546
recordsAdded++;
547-
_logger.LogInformation("Added visibility record: ItemId={ItemId}, MemberId={MemberId}, Permission={Permission}",
548-
itemId, member.Id, permission);
547+
// Don't log individual visibility records in production
549548
}
550549

551550
var saved = await _dbContext.SaveChangesAsync();

0 commit comments

Comments
 (0)