Example #1
0
        private static Dictionary <string, object> GetPayload(GitHubOption option)
        {
            var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();

            var payload = new Dictionary <string, object>
            {
                { "iat", now },
                { "exp", now + 550 },
                { "iss", option.AppIdentifier }
            };

            return(payload);
        }
Example #2
0
        private static GitHubClient GetAppClient(GitHubOption option, string appName)
        {
            var rsaParams = GetRsaParameters(option.PrivateKey);

            var payload = GetPayload(option);

            string jwtToken;

            using (var csp = new RSACryptoServiceProvider())
            {
                csp.ImportParameters(rsaParams);
                var encoder = GetRS256JWTEncoder(csp);
                jwtToken = encoder.Encode(payload, new byte[0]);
            }

            return(GetGitHubClient(appName, jwtToken));
        }
Example #3
0
 public static async Task <InstallationContext> CreateGitHubInstallationClient(GitHubOption option, long installationId)
 {
     return(await CreateGitHubInstallationClient(CreateGitHubAppClient(option), installationId, option.AppName));
 }
Example #4
0
 public static GitHubClient CreateGitHubAppClient(GitHubOption option)
 {
     return(GetAppClient(option, option.AppName));
 }
 public WebHookHandlerRegistry(IServiceProvider serviceProvider)
 {
     _serviceProvider = serviceProvider;
     _gitHubOption    = serviceProvider.GetService <IOptions <GitHubOption> >().Value;
     _httpContext     = serviceProvider.GetService <IHttpContextAccessor>().HttpContext;
 }
Example #6
0
 internal WebHookEvent(GitHubOption gitHubOption)
 {
     _gitHubOption = gitHubOption;
 }