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); }
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)); }
public static async Task <InstallationContext> CreateGitHubInstallationClient(GitHubOption option, long installationId) { return(await CreateGitHubInstallationClient(CreateGitHubAppClient(option), installationId, option.AppName)); }
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; }
internal WebHookEvent(GitHubOption gitHubOption) { _gitHubOption = gitHubOption; }