Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Apps Proof-of-Concept #69

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

GitHub Apps Proof-of-Concept #69

wants to merge 12 commits into from

Conversation

kfcampbell
Copy link
Member

This PR is the .NET side of octokit/go-sdk#69. It's a work in progress.

It's pending some discussion and decisions:

  • How should the examples be structured?
  • Are we comfortable using the GitHubJwt library?

Copy link

github-actions bot commented May 8, 2024

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@MatisseHack
Copy link

FWIW, it's pretty easy to generate JWTs with Microsoft.IdentityModel.JsonWebTokens if you'd prefer to take a dependency on a more "official" library:

using System.Security.Cryptography;
using Microsoft.IdentityModel.JsonWebTokens;
using Microsoft.IdentityModel.Tokens;

string CreateJsonWebToken(string clientId, string privateKey)
{
    var rsa = RSA.Create();
    rsa.ImportFromPem(privateKey);

    var now = DateTimeOffset.Now;
    var tokenDescriptor = new SecurityTokenDescriptor
    {
        Issuer = clientId,
        IssuedAt = now.UtcDateTime,
        NotBefore = now.UtcDateTime,
        Expires = now.AddMinutes(10).UtcDateTime,
        SigningCredentials = new(new RsaSecurityKey(rsa), SecurityAlgorithms.RsaSha256)
    };
    
    return new JsonWebTokenHandler().CreateToken(tokenDescriptor);
}

var token = CreateJsonWebToken("foo", "bar");

@kfcampbell
Copy link
Member Author

@MatisseHack Ooh, I should probably swap over. I used the library I did because I was going off of the Octokit docs 😬; perhaps we should change those as well?

@MatisseHack
Copy link

Good point! I've got nothing against GitHubJwt, but using Microsoft's library is easy enough that it might be wroth switching the recommendation in the docs.

kfcampbell and others added 8 commits May 9, 2024 13:55
- Nothing is working/fully-implemented
- Some refactoring is still needed after implementation
- Auth options error handling in the Build method need to go in their own helper
- Middleware defaults still need to be loaded
- App token creation and refresh still need to be implemented
…ow uses the more patform common package Microsoft.Identity..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

None yet

3 participants