Skip to content

Commit 13e690e

Browse files
committed
Remove UserId Obsolete Marker and Improve Certificate Mode Validation
- Removed the [Obsolete] marker from AlipayAuthenticationConstants.UserId while retaining explanatory comments. - ClaimActions now directly maps “urn:alipay:user_id” to “user_id” and removes the obsolete mapping for Claims.UserId. - Added non-null validation for PublicKey in certificate mode.
1 parent c9aae07 commit 13e690e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/AspNet.Security.OAuth.Alipay/AlipayAuthenticationConstants.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public static class Claims
3636
/// The internal identifier for Alipay users will no longer be independently available going forward and will be replaced by OpenID.
3737
/// See https://opendocs.alipay.com/common/0ai736
3838
/// </summary>
39-
[Obsolete("The internal identifier for Alipay users will no longer be independently available going forward and will be replaced by OpenID. See https://opendocs.alipay.com/common/0ai736")]
4039
public const string UserId = "urn:alipay:user_id";
4140
}
4241
}

src/AspNet.Security.OAuth.Alipay/AlipayAuthenticationOptions.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public AlipayAuthenticationOptions()
3030
ClaimActions.MapJsonKey(Claims.Nickname, "nick_name");
3131
ClaimActions.MapJsonKey(Claims.Province, "province");
3232
ClaimActions.MapJsonKey(Claims.OpenId, "open_id");
33-
#pragma warning disable CS0618
34-
ClaimActions.MapJsonKey(Claims.UserId, "user_id");
35-
#pragma warning restore CS0618
33+
34+
// https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers/pull/1131#discussion_r2657531257
35+
ClaimActions.MapJsonKey("urn:alipay:user_id", "user_id");
3636
}
3737

3838
/// <summary>
@@ -79,6 +79,11 @@ public override void Validate()
7979
{
8080
throw new ArgumentException($"The '{nameof(RootCertificateSnKeyId)}' option must be provided if the '{nameof(UseCertificateSignatures)}' option is set to true.", nameof(RootCertificateSnKeyId));
8181
}
82+
83+
if (PublicKey == null)
84+
{
85+
throw new ArgumentException($"The '{nameof(PublicKey)}' option must be provided if the '{nameof(UseCertificateSignatures)}' option is set to true.", nameof(PublicKey));
86+
}
8287
}
8388
}
8489
}

0 commit comments

Comments
 (0)