Skip to content

Commit

Permalink
fix: HasFormContentType (#1275)
Browse files Browse the repository at this point in the history
* feat: Supports PasswordType

* refactor: Unified processing of third-party user claims

* fix: HasFormContentType

* refactor: ClaimType ImpersonatorUserId
  • Loading branch information
wzh425 authored Apr 10, 2024
1 parent 6519c5b commit ebead70
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public async Task GetProfileDataAsync(ProfileDataRequestContext context)
var request = _httpContextAccessor.HttpContext?.Request;
if (request != null)
{
var scheme = request.Form["scheme"];
if (!string.IsNullOrEmpty(scheme))
if (request.HasFormContentType && request.Form.TryGetValue("scheme", out var scheme))
{
var authUser = await _authClient.UserService.GetThirdPartyUserByUserIdAsync(new GetThirdPartyUserByUserIdModel
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class ImpersonationGrantValidator : IExtensionGrantValidator
IAuthClient _authClient;
public string GrantType { get; } = BuildingBlocks.Authentication.OpenIdConnect.Models.Constans.GrantType.IMPERSONATION;

const string IMPERSONATOR_USER_ID = "http://Lonsid.org/identity/claims/impersonatorUserId";
const string IMPERSONATOR_USER_ID = "https://masastack.com/security/identity/claims/impersonatorUserId";

public ImpersonationGrantValidator(IAuthClient authClient)
{
Expand Down Expand Up @@ -55,6 +55,6 @@ public async Task ValidateAsync(ExtensionGrantValidationContext context)
claims.Add(new Claim(IMPERSONATOR_USER_ID, cacheItem.ImpersonatorUserId.ToString()));
}

context.Result = new GrantValidationResult(cacheItem.TargetUserId.ToString(), "impersonation");
context.Result = new GrantValidationResult(cacheItem.TargetUserId.ToString(), "impersonation", claims);
}
}

0 comments on commit ebead70

Please sign in to comment.