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

Feat: Add support for Github App Installation Authentication Closes #390 #414

Merged
merged 16 commits into from Apr 11, 2024

Conversation

ParthaI
Copy link
Contributor

@ParthaI ParthaI commented Apr 5, 2024

Example query results

Results
> select * from github_my_repository
+-----------+----------------------------------+------------------------------------------+---------------------+---------------------------+--------------------+------------------------------------------------------------------------->
| id        | node_id                          | name                                     | allow_update_branch | archived_at               | auto_merge_allowed | code_of_conduct                                                         >
+-----------+----------------------------------+------------------------------------------+---------------------+---------------------------+--------------------+------------------------------------------------------------------------->
| 196109283 | MDEwOlJlcG9zaXRvcnkxOTYxMDkyODM= | sdk                                      | false               | 2023-10-31T06:06:46+05:30 | false              | <null>                                                                  >
| 187956219 | MDEwOlJlcG9zaXRvcnkxODc5NTYyMTk= | Java-lambda-expression-wiki              | false               | <null>                    | false              | <null>                                                                  >
| 177038814 | MDEwOlJlcG9zaXRvcnkxNzcwMzg4MTQ= | errors                                   | false               | 2019-12-19T11:11:30+05:30 | false              | <null>                                                                  >
| 206827103 | MDEwOlJlcG9zaXRvcnkyMDY4MjcxMDM= | terraform-provider-turbot                | false               | 2019-12-20T03:03:53+05:30 | false              | <null>                                                                  >
| 185492576 | MDEwOlJlcG9zaXRvcnkxODU0OTI1NzY= | aws-sdk                                  | false               | 2019-12-19T12:47:28+05:30 | false              | <null>                                                                  >

@ParthaI ParthaI requested a review from cbruno10 April 5, 2024 13:35
@ParthaI ParthaI self-assigned this Apr 5, 2024
@ParthaI ParthaI linked an issue Apr 5, 2024 that may be closed by this pull request
@ParthaI ParthaI changed the title Feat: Using a Github App token with Steampipe doesn't work Closes #390 Feat: Add support for Github App Installation Authentication Closes #390 Apr 5, 2024
Copy link
Contributor

@cbruno10 cbruno10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ParthaI Please see review comments, thanks!

github/connection_config.go Outdated Show resolved Hide resolved
github/connection_config.go Outdated Show resolved Hide resolved
Copy link
Contributor

@misraved misraved left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ParthaI please take a look at the review comments. Thanks!!

config/github.spc Show resolved Hide resolved
github/utils.go Outdated Show resolved Hide resolved
github/utils.go Show resolved Hide resolved
Token *string `hcl:"token"`
BaseURL *string `hcl:"base_url"`
Token *string `hcl:"token,optional"`
BaseURL *string `hcl:"base_url,optional"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should BaseURL be optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the BaseURL should be an optional parameter. This is only required for the GitHub Enterprise account.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ParthaI I think all the config arguments should remove the optional part.

github/utils.go Outdated Show resolved Hide resolved
github/utils.go Outdated Show resolved Hide resolved
github/utils.go Outdated
if err != nil {
panic(err)
}
itr, err := ghinstallation.NewKeyFromFile(http.DefaultTransport, ghAppId, ghInstallationId, privateKeyPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add in a function to check if privateKeypath exists or not? Or is that taken care of by ghinstallation.NewKeyFromFile function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not check if privateKeypath exists or not. It would be better to return the error directly that is returning from the ghinstallation.NewKeyFromFile function.

The following error we are getting:

Error: rpc error: code = Internal desc = github: rpc error: code = Internal desc = hydrate function tableGitHubMyRepositoryList failed with panic Error occurred in 'connectV4()' during GitHub App Installation client creation could not read private key: open /Users/parthas/abc/def/testappsetting.2024-01-18.private-key.pem: no such file or directory

github/utils.go Outdated
Comment on lines 215 to 231
if githubAppId != "" && githubInstallationId != "" && privateKeyPath != "" && token == "" {
ghAppId, err := strconv.ParseInt(githubAppId, 10, 64)
if err != nil {
panic(err)
}
ghInstallationId, err := strconv.ParseInt(githubInstallationId, 10, 64)
if err != nil {
panic(err)
}
itr, err := ghinstallation.NewKeyFromFile(http.DefaultTransport, ghAppId, ghInstallationId, privateKeyPath)
if err != nil {
panic("Error occurred in 'connectV4()' during GitHub App Installation client creation" + err.Error())
}
transport = itr

client = githubv4.NewClient(&http.Client{Transport: itr})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at similar comments above?

@misraved misraved merged commit e66de80 into main Apr 11, 2024
1 check passed
@misraved misraved deleted the issue-390 branch April 11, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using a Github App token with Steampipe doesn't work
3 participants