-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add caller IP address to audit log. (#606)
Add caller IP address to audit log.
- Loading branch information
Showing
29 changed files
with
368 additions
and
364 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/Microsoft.Health.Fhir.Api/Controllers/AadSmartOnFhirClaimsExtractor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using EnsureThat; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.Primitives; | ||
using Microsoft.Health.Fhir.Core.Features.Security; | ||
|
||
namespace Microsoft.Health.Fhir.Api.Controllers | ||
{ | ||
internal class AadSmartOnFhirClaimsExtractor : IClaimsExtractor | ||
{ | ||
private const string ClientId = "client_id"; | ||
|
||
private readonly IHttpContextAccessor _httpContextAccessor; | ||
|
||
public AadSmartOnFhirClaimsExtractor(IHttpContextAccessor httpContextAccessor) | ||
{ | ||
EnsureArg.IsNotNull(httpContextAccessor, nameof(httpContextAccessor)); | ||
|
||
_httpContextAccessor = httpContextAccessor; | ||
} | ||
|
||
public IReadOnlyCollection<KeyValuePair<string, string>> Extract() | ||
{ | ||
HttpContext context = _httpContextAccessor.HttpContext; | ||
|
||
StringValues clientId = context.Request.HasFormContentType ? context.Request.Form[ClientId] : context.Request.Query[ClientId]; | ||
|
||
ReadOnlyCollection<KeyValuePair<string, string>> claims = clientId.Select(x => new KeyValuePair<string, string>(ClientId, x)).ToList().AsReadOnly(); | ||
return claims; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Microsoft.Health.Fhir.Api/Controllers/AadSmartOnFhirProxyAuditLoggingFilterAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using Microsoft.Health.Fhir.Api.Features.Audit; | ||
|
||
namespace Microsoft.Health.Fhir.Api.Controllers | ||
{ | ||
[AttributeUsage(AttributeTargets.Class)] | ||
internal class AadSmartOnFhirProxyAuditLoggingFilterAttribute : AuditLoggingFilterAttribute | ||
{ | ||
public AadSmartOnFhirProxyAuditLoggingFilterAttribute( | ||
AadSmartOnFhirClaimsExtractor claimsExtractor, | ||
IAuditHelper auditHelper) | ||
: base(claimsExtractor, auditHelper) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.