forked from gongxuegit/tiku-backend.net
feat: add wechat authentication
This commit is contained in:
@@ -36,6 +36,12 @@ public sealed record SmsLoginRequest(
|
||||
string? IpAddress,
|
||||
string? UserAgent);
|
||||
|
||||
public sealed record WechatLoginRequest(
|
||||
Guid TenantId,
|
||||
string Code,
|
||||
string? IpAddress,
|
||||
string? UserAgent);
|
||||
|
||||
public sealed record RefreshSessionRequest(
|
||||
string RefreshToken,
|
||||
string? IpAddress,
|
||||
|
||||
@@ -16,3 +16,6 @@ public sealed class SessionRevokedException()
|
||||
|
||||
public sealed class SmsRateLimitedException()
|
||||
: AuthException("sms_rate_limited", "SMS verification requests are rate limited.");
|
||||
|
||||
public sealed class AuthProviderNotConfiguredException(string provider)
|
||||
: AuthException("auth_provider_not_configured", $"The {provider} auth provider is not configured.");
|
||||
|
||||
@@ -10,6 +10,14 @@ public interface IAuthService
|
||||
SmsLoginRequest request,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<AuthenticatedUser> LoginWithWechatWebAsync(
|
||||
WechatLoginRequest request,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<AuthenticatedUser> LoginWithWechatMiniAppAsync(
|
||||
WechatLoginRequest request,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<AuthTokenPair> RefreshAsync(
|
||||
RefreshSessionRequest request,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
26
Tiku.Application/Auth/IWechatOAuthClient.cs
Normal file
26
Tiku.Application/Auth/IWechatOAuthClient.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace Tiku.Application.Auth;
|
||||
|
||||
public sealed record WechatProviderOptions(
|
||||
string AppId,
|
||||
string AppSecret);
|
||||
|
||||
public sealed record WechatIdentity(
|
||||
string OpenId,
|
||||
string? UnionId,
|
||||
string? Nickname,
|
||||
string? AvatarUrl,
|
||||
string? SessionKey,
|
||||
string RawJson);
|
||||
|
||||
public interface IWechatOAuthClient
|
||||
{
|
||||
Task<WechatIdentity> ExchangeWebCodeAsync(
|
||||
WechatProviderOptions options,
|
||||
string code,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<WechatIdentity> ExchangeMiniAppCodeAsync(
|
||||
WechatProviderOptions options,
|
||||
string code,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
Reference in New Issue
Block a user