Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update feishu provider claims. #821

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/AspNet.Security.OAuth.Feishu/FeishuAuthenticationConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ public static class FeishuAuthenticationConstants
public static class Claims
{
public const string UnionId = "urn:feishu:unionid";
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 EnglishName = "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 EmployeeNumber = "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.EmployeeNumber, "employee_no");
ClaimActions.MapJsonKey(Claims.EnglishName, "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.EmployeeNumber, "111222333")]
[InlineData(FeishuAuthenticationConstants.Claims.EnglishName, "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