zeroframework/Services/Identity/ZeroFramework.IdentityServer.API/Infrastructure/Authentication/GitHub/GitHubAuthenticationOptions.cs

46 lines
1.9 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.GitHub.GitHubAuthenticationConstants;
namespace ZeroFramework.IdentityServer.API.Infrastructure.Authentication.GitHub;
/// <summary>
/// Defines a set of options used by <see cref="GitHubAuthenticationHandler"/>.
/// </summary>
public class GitHubAuthenticationOptions : OAuthOptions
{
public GitHubAuthenticationOptions()
{
ClaimsIssuer = GitHubAuthenticationDefaults.Issuer;
CallbackPath = GitHubAuthenticationDefaults.CallbackPath;
AuthorizationEndpoint = GitHubAuthenticationDefaults.AuthorizationEndpoint;
TokenEndpoint = GitHubAuthenticationDefaults.TokenEndpoint;
UserInformationEndpoint = GitHubAuthenticationDefaults.UserInformationEndpoint;
ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
ClaimActions.MapJsonKey(ClaimTypes.Name, "login");
ClaimActions.MapJsonKey(ClaimTypes.Email, "email");
ClaimActions.MapJsonKey(Claims.Name, "name");
ClaimActions.MapJsonKey(Claims.Url, "url");
}
/// <summary>
/// Gets or sets the domain name to use if using a GitHub Enterprise on-premises deployment.
/// </summary>
public string? EnterpriseDomain { get; set; }
/// <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; } = GitHubAuthenticationDefaults.UserEmailsEndpoint;
}