diff --git a/src/AspNet.Security.OAuth.Feishu/FeishuAuthenticationConstants.cs b/src/AspNet.Security.OAuth.Feishu/FeishuAuthenticationConstants.cs index 977b7ad9c..87bbb8f1e 100644 --- a/src/AspNet.Security.OAuth.Feishu/FeishuAuthenticationConstants.cs +++ b/src/AspNet.Security.OAuth.Feishu/FeishuAuthenticationConstants.cs @@ -13,7 +13,21 @@ public static class FeishuAuthenticationConstants { public static class Claims { - public const string UnionId = "urn:feishu:unionid"; + public const string UnionId = "urn:feishu:union_id"; + public const string Sub = "urn:feishu:sub"; + public const string Name = "urn:feishu:name"; + public const string Picture = "urn:feishu:picture"; + public const string OpenId = "urn:feishu:open_id"; + public const string EnName = "urn:feishu:en_name"; + public const string TenantKey = "urn:feishu:tenant_key"; public const string Avatar = "urn:feishu:avatar"; + public const string AvatarUrl = "urn:feishu:avatar_url"; + public const string AvatarThumb = "urn:feishu:avatar_thumb"; + public const string AvatarMiddle = "urn:feishu:avatar_middle"; + public const string AvatarBig = "urn:feishu:avatar_big"; + public const string Email = "urn:feishu:email"; + public const string UserId = "urn:feishu:userid"; + public const string EmployeeNo = "urn:feishu:employee_no"; + public const string Mobile = "urn:feishu:mobile"; } } diff --git a/src/AspNet.Security.OAuth.Feishu/FeishuAuthenticationOptions.cs b/src/AspNet.Security.OAuth.Feishu/FeishuAuthenticationOptions.cs index c949017cb..2d4fb05c9 100644 --- a/src/AspNet.Security.OAuth.Feishu/FeishuAuthenticationOptions.cs +++ b/src/AspNet.Security.OAuth.Feishu/FeishuAuthenticationOptions.cs @@ -25,6 +25,20 @@ public FeishuAuthenticationOptions() ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "open_id"); ClaimActions.MapJsonKey(ClaimTypes.Name, "name"); + ClaimActions.MapJsonKey(Claims.AvatarBig, "avatar_big"); + ClaimActions.MapJsonKey(Claims.AvatarMiddle, "avatar_middle"); + ClaimActions.MapJsonKey(Claims.AvatarThumb, "avatar_thumb"); + ClaimActions.MapJsonKey(Claims.AvatarUrl, "avatar_url"); + ClaimActions.MapJsonKey(Claims.Email, "email"); + ClaimActions.MapJsonKey(Claims.EmployeeNo, "employee_no"); + ClaimActions.MapJsonKey(Claims.EnName, "en_name"); + ClaimActions.MapJsonKey(Claims.Mobile, "mobile"); + ClaimActions.MapJsonKey(Claims.Name, "name"); + ClaimActions.MapJsonKey(Claims.OpenId, "open_id"); + ClaimActions.MapJsonKey(Claims.Picture, "picture"); + ClaimActions.MapJsonKey(Claims.Sub, "sub"); + ClaimActions.MapJsonKey(Claims.TenantKey, "tenant_key"); + ClaimActions.MapJsonKey(Claims.UserId, "user_id"); ClaimActions.MapJsonKey(Claims.UnionId, "union_id"); ClaimActions.MapJsonKey(Claims.Avatar, "avatar_big"); } diff --git a/test/AspNet.Security.OAuth.Providers.Tests/Feishu/FeishuTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/Feishu/FeishuTests.cs index d045a4006..d13eb908b 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/Feishu/FeishuTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/Feishu/FeishuTests.cs @@ -20,6 +20,20 @@ protected internal override void RegisterAuthentication(AuthenticationBuilder bu [InlineData(ClaimTypes.Name, "test-name")] [InlineData(FeishuAuthenticationConstants.Claims.UnionId, "test-union-id")] [InlineData(FeishuAuthenticationConstants.Claims.Avatar, "https://www.feishu.cn/avatar/icon_big")] + [InlineData(FeishuAuthenticationConstants.Claims.AvatarBig, "https://www.feishu.cn/avatar/icon_big")] + [InlineData(FeishuAuthenticationConstants.Claims.AvatarMiddle, "https://www.feishu.cn/avatar/icon_middle")] + [InlineData(FeishuAuthenticationConstants.Claims.AvatarThumb, "https://www.feishu.cn/avatar/icon_thumb")] + [InlineData(FeishuAuthenticationConstants.Claims.AvatarUrl, "https://www.feishu.cn/avatar/icon")] + [InlineData(FeishuAuthenticationConstants.Claims.Email, "zhangsan@feishu.cn")] + [InlineData(FeishuAuthenticationConstants.Claims.EmployeeNo, "111222333")] + [InlineData(FeishuAuthenticationConstants.Claims.EnName, "Lilei")] + [InlineData(FeishuAuthenticationConstants.Claims.Mobile, "+86130xxxx0000")] + [InlineData(FeishuAuthenticationConstants.Claims.Name, "test-name")] + [InlineData(FeishuAuthenticationConstants.Claims.OpenId, "test-open-id")] + [InlineData(FeishuAuthenticationConstants.Claims.Picture, "https://www.feishu.cn/avatar")] + [InlineData(FeishuAuthenticationConstants.Claims.Sub, "ou_caecc734c2e3328a62489fe0648c4b98779515d3")] + [InlineData(FeishuAuthenticationConstants.Claims.TenantKey, "736588c92lxf175d")] + [InlineData(FeishuAuthenticationConstants.Claims.UserId, "5d9bdxxx")] public async Task Can_Sign_In_Using_Feishu(string claimType, string claimValue) => await AuthenticateUserAndAssertClaimValue(claimType, claimValue); } diff --git a/test/AspNet.Security.OAuth.Providers.Tests/Feishu/bundle.json b/test/AspNet.Security.OAuth.Providers.Tests/Feishu/bundle.json index 8a2763e2f..7e291edd5 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/Feishu/bundle.json +++ b/test/AspNet.Security.OAuth.Providers.Tests/Feishu/bundle.json @@ -32,6 +32,7 @@ "avatar_big": "https://www.feishu.cn/avatar/icon_big", "email": "zhangsan@feishu.cn", "user_id": "5d9bdxxx", + "employee_no": "111222333", "mobile": "+86130xxxx0000" } }