Skip to content

Commit

Permalink
Update feishu provider claims.
Browse files Browse the repository at this point in the history
Signed-off-by: Vicente.Yu <^@^>
  • Loading branch information
Vicente.Yu committed Dec 29, 2023
1 parent 77713f3 commit dea3c98
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
14 changes: 14 additions & 0 deletions src/AspNet.Security.OAuth.Feishu/FeishuAuthenticationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
14 changes: 14 additions & 0 deletions test/AspNet.Security.OAuth.Providers.Tests/Feishu/FeishuTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "[email protected]")]
[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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"avatar_big": "https://www.feishu.cn/avatar/icon_big",
"email": "[email protected]",
"user_id": "5d9bdxxx",
"employee_no": "111222333",
"mobile": "+86130xxxx0000"
}
}
Expand Down

0 comments on commit dea3c98

Please sign in to comment.