zeroframework/Services/Identity/ZeroFramework.IdentityServer.API/Infrastructure/Authentication/Tencent/QQAuthenticationOptions.cs
2023-12-05 17:22:48 +08:00

50 lines
2.1 KiB
C#

/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
* for more information concerning the license and the contributors participating to this project.
*/
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OAuth;
using System.Security.Claims;
using static ZeroFramework.IdentityServer.API.Infrastructure.Authentication.QQ.QQAuthenticationConstants;
namespace ZeroFramework.IdentityServer.API.Infrastructure.Authentication.QQ;
/// <summary>
/// Defines a set of options used by <see cref="QQAuthenticationHandler"/>.
/// </summary>
public class QQAuthenticationOptions : OAuthOptions
{
public QQAuthenticationOptions()
{
ClaimsIssuer = QQAuthenticationDefaults.Issuer;
CallbackPath = QQAuthenticationDefaults.CallbackPath;
AuthorizationEndpoint = QQAuthenticationDefaults.AuthorizationEndpoint;
TokenEndpoint = QQAuthenticationDefaults.TokenEndpoint;
UserIdentificationEndpoint = QQAuthenticationDefaults.UserIdentificationEndpoint;
UserInformationEndpoint = QQAuthenticationDefaults.UserInformationEndpoint;
Scope.Add("get_user_info");
ClaimActions.MapJsonKey(ClaimTypes.Name, "nickname");
ClaimActions.MapJsonKey(ClaimTypes.Gender, "gender");
ClaimActions.MapJsonKey(Claims.PictureUrl, "figureurl");
ClaimActions.MapJsonKey(Claims.PictureMediumUrl, "figureurl_1");
ClaimActions.MapJsonKey(Claims.PictureFullUrl, "figureurl_2");
ClaimActions.MapJsonKey(Claims.AvatarUrl, "figureurl_qq_1");
ClaimActions.MapJsonKey(Claims.AvatarFullUrl, "figureurl_qq_2");
}
/// <summary>
/// Gets or sets if the union Id (the primary key of an owner for different apps of the QQ platform) should be put into the user claims.
/// </summary>
public bool ApplyForUnionId { get; set; }
/// <summary>
/// Gets or sets the URL of the user identification endpoint (a.k.a. the "OpenID endpoint").
/// </summary>
public string UserIdentificationEndpoint { get; set; }
}