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

Add a way to check whether token permissions are sufficient for a given operation #52

Closed
yiannistri opened this issue Sep 24, 2020 · 3 comments · Fixed by #53
Closed
Milestone

Comments

@yiannistri
Copy link
Collaborator

yiannistri commented Sep 24, 2020

It would be good to have a way to validate that a token has all the right permissions i.e. repo and admin:org before it's used.

For GitHub: a response header X-OAuth-Scopes is returned that includes the current scopes https://docs.github.com/en/developers/apps/scopes-for-oauth-apps

For GitLab: an API call should return the current scopes https://docs.gitlab.com/ce/api/personal_access_tokens.html

@yiannistri
Copy link
Collaborator Author

Turns out that GitLab does not support an easy way to get the scopes of the current token. The above endpoint is not available in all flavours of GitLab and also it enumerates all the available tokens as opposed to the current one being used.

@stefanprodan
Copy link
Member

We can't restrict the use of this library to GitLab Ultimate, I propose we don't implement the permission check for GitLab.

@yiannistri
Copy link
Collaborator Author

Ok I'll wait until the GitLab PR gets merged before I implement the method to return an ErrNoProviderSupport.

@foot foot added this to the v0.0.3 milestone Sep 30, 2020
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 a pull request may close this issue.

3 participants