From 19391ee724ca84ad0231783f9aaab174a4b29ea2 Mon Sep 17 00:00:00 2001 From: wzh425 Date: Tue, 12 Mar 2024 16:46:20 +0800 Subject: [PATCH 1/5] feat: Add GetThirdPartyUserByUserIdAsync --- Directory.Build.props | 3 +-- ...a.BuildingBlocks.StackSdks.Auth.Contracts.csproj | 1 + .../Model/GetThirdPartyUserByUserIdModel.cs | 13 +++++++++++++ .../Model/UserModel.cs | 2 ++ .../Masa.BuildingBlocks.StackSdks.Auth.csproj | 1 + .../Service/IUserService.cs | 2 ++ .../Masa.Contrib.StackSdks.Auth.csproj | 1 + .../Service/UserService.cs | 6 ++++++ 8 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/GetThirdPartyUserByUserIdModel.cs diff --git a/Directory.Build.props b/Directory.Build.props index c6dc5b2d4..f89faa557 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,9 +1,8 @@ - net6.0;net7.0;net8.0 + net6.0;net7.0; 6.0.0 7.0.0 - 8.0.0 0.13.1 2.2.3 16.9.4 diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj index d6a42c431..9be2cb378 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj @@ -3,6 +3,7 @@ enable enable + 1.0.1-preview.12 diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/GetThirdPartyUserByUserIdModel.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/GetThirdPartyUserByUserIdModel.cs new file mode 100644 index 000000000..90d1de901 --- /dev/null +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/GetThirdPartyUserByUserIdModel.cs @@ -0,0 +1,13 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.StackSdks.Auth.Contracts.Model; + +public class GetThirdPartyUserByUserIdModel : IEnvironmentModel +{ + public string Scheme { get; set; } + + public Guid UserId { get; set; } + + public string Environment { get; set; } +} diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/UserModel.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/UserModel.cs index 7b63367f7..6523e2661 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/UserModel.cs +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/UserModel.cs @@ -50,6 +50,8 @@ public class UserModel public string RealDisplayName => StaffDisplayName.IsNullOrEmpty() ? DisplayName : StaffDisplayName; + public Dictionary ClaimData { get; set; } = new(); + public UserModel() { Avatar = ""; diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj index d79733893..1a8160f8b 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj @@ -3,6 +3,7 @@ enable enable + 1.0.1-preview.12 diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs index 1723137ce..f8076f72b 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs @@ -29,6 +29,8 @@ public interface IUserService Task GetThirdPartyUserAsync(GetThirdPartyUserModel model); + Task GetThirdPartyUserByUserIdAsync(GetThirdPartyUserByUserIdModel model); + Task UpsertAsync(UpsertUserModel user); Task ValidateAccountAsync(ValidateAccountModel validateAccountModel); diff --git a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj index a81ee8aee..09613b554 100644 --- a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj +++ b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj @@ -3,6 +3,7 @@ enable enable + 1.0.1-preview.12 diff --git a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs index ad11b3a62..c5fe703c1 100644 --- a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs +++ b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs @@ -273,6 +273,12 @@ public async Task AddThirdPartyUserAsync(AddThirdPartyUserModel user, return await _caller.GetAsync(requestUri, model); } + public async Task GetThirdPartyUserByUserIdAsync(GetThirdPartyUserByUserIdModel model) + { + var requestUri = $"api/thirdPartyUser/GetByUserId"; + return await _caller.GetAsync(requestUri, model); + } + public async Task SetCurrentTeamAsync(Guid teamId) { var userId = _userContext.GetUserId(); From 548458dcb03e910cf4caec4cb4117509ce702463 Mon Sep 17 00:00:00 2001 From: wzh425 Date: Wed, 13 Mar 2024 15:16:04 +0800 Subject: [PATCH 2/5] feat: add grantType --- .../Constans/GrantType.cs | 6 ++++++ .../Constans/GrantTypes.cs | 6 ++++++ ...locks.Authentication.OpenIdConnect.Models.csproj | 1 + ...a.BuildingBlocks.StackSdks.Auth.Contracts.csproj | 2 +- .../Model/ImpersonateModel.cs | 9 +++++++++ .../Model/ImpersonationUserModel.cs | 13 +++++++++++++ .../Masa.BuildingBlocks.StackSdks.Auth.csproj | 2 +- .../Service/IUserService.cs | 4 ++++ .../Masa.Contrib.StackSdks.Auth.csproj | 2 +- .../Service/UserService.cs | 12 ++++++++++++ 10 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateModel.cs create mode 100644 src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonationUserModel.cs diff --git a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantType.cs b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantType.cs index 7b34c5cd3..f1dd77904 100644 --- a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantType.cs +++ b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantType.cs @@ -35,6 +35,12 @@ public static class GrantType [Description("Ldap")] public const string LDAP = "ldap"; + [Description("Impersonation")] + public const string IMPERSONATION = "impersonation"; + + [Description("PssoPhoneCode")] + public const string PSSO_PHONE_CODE = "psso_phone_code"; + private static readonly List<(string, string)> _disallowCombinations = new List<(string, string)> { (IMPLICIT, AUTHORIZATION_CODE), diff --git a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantTypes.cs b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantTypes.cs index 2aa97e2d5..d9619ca2d 100644 --- a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantTypes.cs +++ b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantTypes.cs @@ -40,4 +40,10 @@ public class GrantTypes public static ICollection DeviceFlow => new[] { GrantType.DEVICE_FLOW }; + + public static ICollection Impersonation => + new[] { GrantType.IMPERSONATION }; + + public static ICollection PssoPhoneCode => + new[] { GrantType.PSSO_PHONE_CODE }; } diff --git a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj index 61538f600..a9b43daa1 100644 --- a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj +++ b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj @@ -3,6 +3,7 @@ enable enable + 1.0.1-preview.10.3 diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj index 9be2cb378..996d83efd 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj @@ -3,7 +3,7 @@ enable enable - 1.0.1-preview.12 + 1.0.1-preview.10.2 diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateModel.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateModel.cs new file mode 100644 index 000000000..ad4e10d56 --- /dev/null +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateModel.cs @@ -0,0 +1,9 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.StackSdks.Auth.Contracts.Model; + +public class ImpersonateModel +{ + public string ImpersonationToken { get; set; } = string.Empty; +} diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonationUserModel.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonationUserModel.cs new file mode 100644 index 000000000..a2e28702b --- /dev/null +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonationUserModel.cs @@ -0,0 +1,13 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.StackSdks.Auth.Contracts.Model; + +public class ImpersonationUserModel +{ + public Guid ImpersonatorUserId { get; set; } + + public Guid TargetUserId { get; set; } + + public bool IsBackToImpersonator { get; set; } +} diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj index 1a8160f8b..a3d6852f9 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj @@ -3,7 +3,7 @@ enable enable - 1.0.1-preview.12 + 1.0.1-preview.10.2 diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs index f8076f72b..541a1ecb3 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs @@ -116,5 +116,9 @@ public interface IUserService Task> GetClaimValuesAsync(Guid userId); Task AddClaimValuesAsync(UserClaimValuesModel userClaimValuesModel); + + Task GetImpersonatedUserAsync(string impersonationToken); + + Task ImpersonateAsync(Guid userId); } diff --git a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj index 09613b554..3dedc656e 100644 --- a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj +++ b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj @@ -3,7 +3,7 @@ enable enable - 1.0.1-preview.12 + 1.0.1-preview.10.2 diff --git a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs index c5fe703c1..854ea35e9 100644 --- a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs +++ b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs @@ -399,5 +399,17 @@ public Task AddClaimValuesAsync(UserClaimValuesModel userClaimValuesModel) var requestUri = $"api/user/claim-values"; return _caller.PostAsync(requestUri, userClaimValuesModel); } + + public async Task GetImpersonatedUserAsync(string impersonationToken) + { + var requestUri = $"api/user/impersonate"; + return await _caller.GetAsync(requestUri, new { impersonationToken }) ?? new(); + } + + public async Task ImpersonateAsync(Guid userId) + { + var requestUri = $"api/user/impersonate"; + return await _caller.PostAsync(requestUri, new { userId }) ?? new(); + } } From dd352dd7fc2116cb8b8c9954164c938a198bc907 Mon Sep 17 00:00:00 2001 From: wzh425 Date: Fri, 15 Mar 2024 13:29:09 +0800 Subject: [PATCH 3/5] reactor: Support Environment --- ...asa.BuildingBlocks.StackSdks.Auth.Contracts.csproj | 2 +- .../Model/GetImpersonateInputModel.cs | 11 +++++++++++ ...ationUserModel.cs => GetImpersonateOutputModel.cs} | 2 +- .../Model/ImpersonateInputModel.cs | 11 +++++++++++ ...{ImpersonateModel.cs => ImpersonateOutputModel.cs} | 2 +- .../Masa.BuildingBlocks.StackSdks.Auth.csproj | 2 +- .../Service/IUserService.cs | 4 ++-- .../Masa.Contrib.StackSdks.Auth.csproj | 2 +- .../Service/UserService.cs | 8 ++++---- 9 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/GetImpersonateInputModel.cs rename src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/{ImpersonationUserModel.cs => GetImpersonateOutputModel.cs} (90%) create mode 100644 src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateInputModel.cs rename src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/{ImpersonateModel.cs => ImpersonateOutputModel.cs} (88%) diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj index 996d83efd..15abf2dd8 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj @@ -3,7 +3,7 @@ enable enable - 1.0.1-preview.10.2 + 1.0.1-preview.10.3 diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/GetImpersonateInputModel.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/GetImpersonateInputModel.cs new file mode 100644 index 000000000..142ecab41 --- /dev/null +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/GetImpersonateInputModel.cs @@ -0,0 +1,11 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.StackSdks.Auth.Contracts.Model; + +public class GetImpersonateInputModel : IEnvironmentModel +{ + public string ImpersonationToken { get; set; } = ""; + + public string Environment { get; set; } +} diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonationUserModel.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/GetImpersonateOutputModel.cs similarity index 90% rename from src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonationUserModel.cs rename to src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/GetImpersonateOutputModel.cs index a2e28702b..9627196f7 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonationUserModel.cs +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/GetImpersonateOutputModel.cs @@ -3,7 +3,7 @@ namespace Masa.BuildingBlocks.StackSdks.Auth.Contracts.Model; -public class ImpersonationUserModel +public class GetImpersonateOutputModel { public Guid ImpersonatorUserId { get; set; } diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateInputModel.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateInputModel.cs new file mode 100644 index 000000000..213fbfd60 --- /dev/null +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateInputModel.cs @@ -0,0 +1,11 @@ +// Copyright (c) MASA Stack All rights reserved. +// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +namespace Masa.BuildingBlocks.StackSdks.Auth.Contracts.Model; + +public class ImpersonateInputModel : IEnvironmentModel +{ + public Guid UserId { get; set; } + + public string Environment { get; set; } +} diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateModel.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateOutputModel.cs similarity index 88% rename from src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateModel.cs rename to src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateOutputModel.cs index ad4e10d56..a3ee16126 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateModel.cs +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Model/ImpersonateOutputModel.cs @@ -3,7 +3,7 @@ namespace Masa.BuildingBlocks.StackSdks.Auth.Contracts.Model; -public class ImpersonateModel +public class ImpersonateOutputModel { public string ImpersonationToken { get; set; } = string.Empty; } diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj index a3d6852f9..cb00453dd 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj @@ -3,7 +3,7 @@ enable enable - 1.0.1-preview.10.2 + 1.0.1-preview.10.3 diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs index 541a1ecb3..8a57a4088 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Service/IUserService.cs @@ -117,8 +117,8 @@ public interface IUserService Task AddClaimValuesAsync(UserClaimValuesModel userClaimValuesModel); - Task GetImpersonatedUserAsync(string impersonationToken); + Task GetImpersonateAsync(GetImpersonateInputModel model); - Task ImpersonateAsync(Guid userId); + Task ImpersonateAsync(ImpersonateInputModel model); } diff --git a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj index 3dedc656e..91476341b 100644 --- a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj +++ b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj @@ -3,7 +3,7 @@ enable enable - 1.0.1-preview.10.2 + 1.0.1-preview.10.3 diff --git a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs index 854ea35e9..829b68c86 100644 --- a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs +++ b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Service/UserService.cs @@ -400,16 +400,16 @@ public Task AddClaimValuesAsync(UserClaimValuesModel userClaimValuesModel) return _caller.PostAsync(requestUri, userClaimValuesModel); } - public async Task GetImpersonatedUserAsync(string impersonationToken) + public async Task GetImpersonateAsync(GetImpersonateInputModel model) { var requestUri = $"api/user/impersonate"; - return await _caller.GetAsync(requestUri, new { impersonationToken }) ?? new(); + return await _caller.GetAsync(requestUri, model) ?? new(); } - public async Task ImpersonateAsync(Guid userId) + public async Task ImpersonateAsync(ImpersonateInputModel model) { var requestUri = $"api/user/impersonate"; - return await _caller.PostAsync(requestUri, new { userId }) ?? new(); + return await _caller.PostAsync(requestUri, model) ?? new(); } } From 3a60009de88be91c9d145709da00d3a566ea372a Mon Sep 17 00:00:00 2001 From: wzh425 Date: Fri, 29 Mar 2024 09:42:35 +0800 Subject: [PATCH 4/5] reactor: Remove GrantType.PSSO_PHONE_CODE --- .../Constans/GrantType.cs | 3 --- .../Constans/GrantTypes.cs | 3 --- ...a.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantType.cs b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantType.cs index f1dd77904..bf12f315e 100644 --- a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantType.cs +++ b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantType.cs @@ -38,9 +38,6 @@ public static class GrantType [Description("Impersonation")] public const string IMPERSONATION = "impersonation"; - [Description("PssoPhoneCode")] - public const string PSSO_PHONE_CODE = "psso_phone_code"; - private static readonly List<(string, string)> _disallowCombinations = new List<(string, string)> { (IMPLICIT, AUTHORIZATION_CODE), diff --git a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantTypes.cs b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantTypes.cs index d9619ca2d..6d1917638 100644 --- a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantTypes.cs +++ b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Constans/GrantTypes.cs @@ -43,7 +43,4 @@ public class GrantTypes public static ICollection Impersonation => new[] { GrantType.IMPERSONATION }; - - public static ICollection PssoPhoneCode => - new[] { GrantType.PSSO_PHONE_CODE }; } diff --git a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj index a9b43daa1..b8eb4f41a 100644 --- a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj +++ b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj @@ -3,7 +3,7 @@ enable enable - 1.0.1-preview.10.3 + 1.0.1-preview.10.4 From 9c240864105b05ca899004ce1f9cfe203baa004a Mon Sep 17 00:00:00 2001 From: wzh425 Date: Sat, 30 Mar 2024 13:05:16 +0800 Subject: [PATCH 5/5] feat: auth sdk add impersonate login --- Directory.Build.props | 3 ++- ...a.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj | 1 - .../Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj | 1 - .../Masa.BuildingBlocks.StackSdks.Auth.csproj | 1 - .../Masa.Contrib.StackSdks.Auth.csproj | 1 - 5 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index f89faa557..c6dc5b2d4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,8 +1,9 @@ - net6.0;net7.0; + net6.0;net7.0;net8.0 6.0.0 7.0.0 + 8.0.0 0.13.1 2.2.3 16.9.4 diff --git a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj index b8eb4f41a..61538f600 100644 --- a/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj +++ b/src/BuildingBlocks/Authentication/OpenIdConnect/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models/Masa.BuildingBlocks.Authentication.OpenIdConnect.Models.csproj @@ -3,7 +3,6 @@ enable enable - 1.0.1-preview.10.4 diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj index 15abf2dd8..d6a42c431 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth.Contracts/Masa.BuildingBlocks.StackSdks.Auth.Contracts.csproj @@ -3,7 +3,6 @@ enable enable - 1.0.1-preview.10.3 diff --git a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj index cb00453dd..d79733893 100644 --- a/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj +++ b/src/BuildingBlocks/StackSdks/Auth/Masa.BuildingBlocks.StackSdks.Auth/Masa.BuildingBlocks.StackSdks.Auth.csproj @@ -3,7 +3,6 @@ enable enable - 1.0.1-preview.10.3 diff --git a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj index 91476341b..a81ee8aee 100644 --- a/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj +++ b/src/Contrib/StackSdks/Masa.Contrib.StackSdks.Auth/Masa.Contrib.StackSdks.Auth.csproj @@ -3,7 +3,6 @@ enable enable - 1.0.1-preview.10.3