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

Add support for Alipay certificate signing and openid. #968

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

BuknSS
Copy link

@BuknSS BuknSS commented Oct 30, 2024

I need to call Alipay's "fund expenditure interface", and I have to change the key signature method to the certificate signature method, which will make the current Alipay Provider unavailable, so I refer to the Alipay official SDK code, add some code, just add two certificate-related fields in the request content:

  • app_cert_sn
  • alipay_root_cert_sn

When options AppCertPath and RootCertPath are configured with the certificate file path, the certificate signing mode will be enabled

Alipay's certificate signature document:


Alipay now only provides open_id to new merchants, without user_id. In this case, the following code will cause an error.

identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, mainElement.GetString("user_id")!, ClaimValueTypes.String, Options.ClaimsIssuer));

Alipay's openid document:

Alipay documents are in Chinese, so they need to be translated.


Screenshot of network packet capture:
TokenEndpoint
Calling TokenEndpoint

UserInformationEndpoint
Calling UserInformationEndpoint

Comment on lines +65 to +67
public string? AppCertPath { get; set; }

public string? RootCertPath { get; set; }
Copy link
Member

@martincostello martincostello Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't assume that certificates are on the file system - they could (should?) be stored in a secure location, such as the Windows Certificate Manager, or loaded from a remote source such as Azure Key Vault. Take a look at the Apple provider for examples on handling such scenarios.

This example might also help: configuring Sign in With Apple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants