zeroframework/Services/Identity/ZeroFramework.IdentityServer.API/Infrastructure/Authentication/Weibo/WeiboAuthenticationOptions.cs

47 lines
2.0 KiB
C#
Raw Normal View History

2023-12-05 09:22:48 +00:00
/*
* 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.Weibo.WeiboAuthenticationConstants;
namespace ZeroFramework.IdentityServer.API.Infrastructure.Authentication.Weibo;
/// <summary>
/// Defines a set of options used by <see cref="WeiboAuthenticationHandler"/>.
/// </summary>
public class WeiboAuthenticationOptions : OAuthOptions
{
public WeiboAuthenticationOptions()
{
ClaimsIssuer = WeiboAuthenticationDefaults.Issuer;
CallbackPath = WeiboAuthenticationDefaults.CallbackPath;
AuthorizationEndpoint = WeiboAuthenticationDefaults.AuthorizationEndpoint;
TokenEndpoint = WeiboAuthenticationDefaults.TokenEndpoint;
UserInformationEndpoint = WeiboAuthenticationDefaults.UserInformationEndpoint;
ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
ClaimActions.MapJsonKey(ClaimTypes.Name, "name");
ClaimActions.MapJsonKey(ClaimTypes.Gender, "gender");
ClaimActions.MapJsonKey(Claims.ScreenName, "screen_name");
ClaimActions.MapJsonKey(Claims.ProfileImageUrl, "profile_image_url");
ClaimActions.MapJsonKey(Claims.AvatarLarge, "avatar_large");
ClaimActions.MapJsonKey(Claims.AvatarHd, "avatar_hd");
ClaimActions.MapJsonKey(Claims.CoverImagePhone, "cover_image_phone");
ClaimActions.MapJsonKey(Claims.Location, "location");
Scope.Add("email");
}
/// <summary>
/// Gets or sets the address of the endpoint exposing
/// the email addresses associated with the logged in user.
/// </summary>
public string UserEmailsEndpoint { get; set; } = WeiboAuthenticationDefaults.UserEmailsEndpoint;
}