QQAuthenticationOptions.cs 2.04 KB
/*
 * 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 System.Security.Claims;
using Microsoft.AspNetCore.Authentication;
using static Yi.Framework.AspNetCore.Authentication.OAuth.QQ.QQAuthenticationConstants;

namespace Yi.Framework.AspNetCore.Authentication.OAuth.QQ;

/// <summary>
/// Defines a set of options used by <see cref="QQAuthenticationHandler"/>.
/// </summary>
public class QQAuthenticationOptions : AuthenticationOAuthOptions
{
    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; }

}