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

Check if supplied GitHub account has read and write access to the repository #15

Closed
mdio opened this issue Apr 30, 2015 · 6 comments
Closed
Labels

Comments

@mdio
Copy link
Contributor

mdio commented Apr 30, 2015

We ran into a problem with our private repository and the GitHub user account used for Buildasaur had read only access to the repository.
Credential validation from Buildasaur was successful and Bots were created, integrations ran.
But posting the integration result to GitHub and adding the comment failed and it took us a while to figure out why.

It would be cool if Buildasaur could check for write access as well and at least warn that integration results cannot be published on GitHub without write access.

@czechboy0 czechboy0 added the bug label Apr 30, 2015
@czechboy0
Copy link
Member

Good point, right now Builda verifies access to the repository just by trying to read Pull Requests, which probably succeeded in your case. I guess I could try all the rights needed, by trying to create/delete a commit status and adding/deleting a comment on a PR. Or maybe there's a GitHub API call to verify rights of a token?

@mdio
Copy link
Contributor Author

mdio commented Apr 30, 2015

A few tests with the repos GET endpoint make me confident that the part with permissions is the key here. push (write) and pull (read) must be true in order to do everything Buildasaur does. Of course the requests need to be done with the token to reflect the permissions of the user which the token belongs to (but Buildasaur does that anyway).

"permissions": {
      "admin": false,
      "push": true,
      "pull": true
    }

@czechboy0
Copy link
Member

@mdio 👍 Yeah that's it exactly. Feel free to send a pull request with the change if you want, it'd mean adding a method to GitHubServer called getRepository, creating a new entity Repository and then just changing the verification call in checkAvailabilityOfGitHubWithCurrentSettingsOfProject to use the permissions metadata to return whether Buildasaur has all the rights required. If not I'll tackle it in the next couple of days.

Thanks for taking the time to look up the API call!

@mdio
Copy link
Contributor Author

mdio commented Apr 30, 2015

I'm afraid that I won't be able to implement that today and due to tomorrow being a public holiday I won't start before monday.
Also I'm just learning Swift but thanks to your detailed idea it looks doable.

@czechboy0
Copy link
Member

No problem, I'll take a look at it over the weekend.

@czechboy0
Copy link
Member

Fixed in 6642a08. Let me know if this works for you, @mdio!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants