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

gitlab oauth scope setting #613

Merged
merged 5 commits into from
Jun 12, 2024
Merged

gitlab oauth scope setting #613

merged 5 commits into from
Jun 12, 2024

Conversation

JerrySentry
Copy link
Contributor

@JerrySentry JerrySentry commented Jun 12, 2024

Test locally with adding gitlab_scope to the config/codecov.yml file in umbrella-hat.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@codecov-staging
Copy link

codecov-staging bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.46%. Comparing base (7bed118) to head (a32390f).

✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main     #613   +/-   ##
=======================================
  Coverage   91.46%   91.46%           
=======================================
  Files         615      615           
  Lines       16363    16367    +4     
=======================================
+ Hits        14966    14970    +4     
  Misses       1397     1397           
Flag Coverage Δ
unit 91.46% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 91.46% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
codecov/settings_base.py 85.02% <100.00%> (+0.08%) ⬆️
codecov_auth/views/gitlab.py 98.48% <100.00%> (+0.07%) ⬆️

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

Copy link

codecov-public-qa bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.46%. Comparing base (7bed118) to head (a32390f).

✅ All tests successful. No failed tests found ☺️

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #613   +/-   ##
=======================================
  Coverage   91.46%   91.46%           
=======================================
  Files         615      615           
  Lines       16363    16367    +4     
=======================================
+ Hits        14966    14970    +4     
  Misses       1397     1397           
Flag Coverage Δ
unit 91.46% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 91.46% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
codecov/settings_base.py 85.02% <100.00%> (+0.08%) ⬆️
codecov_auth/views/gitlab.py 98.48% <100.00%> (+0.07%) ⬆️

Impacted file tree graph

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.91%. Comparing base (7bed118) to head (a32390f).

Additional details and impacted files
@@             Coverage Diff             @@
##               main       #613   +/-   ##
===========================================
  Coverage   95.91000   95.91000           
===========================================
  Files           793        793           
  Lines         17680      17684    +4     
===========================================
+ Hits          16958      16962    +4     
  Misses          722        722           
Flag Coverage Δ
unit 91.46% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 91.46% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -40,11 +41,16 @@ def get_url_to_redirect_to(self):
redirect_info = self.redirect_info
base_url = urljoin(redirect_info["repo_service"].service_url, "oauth/authorize")
state = self.generate_state()

scope = get_config("gitlab_scopes", default="api")
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make sure it's set correctly in gitlab config, change this to get_config("gitlab", "scopes", default="api") This is how codecov yaml should look like:
Screenshot 2024-06-12 at 10 49 40 AM

Copy link
Contributor Author

@JerrySentry JerrySentry Jun 12, 2024

Choose a reason for hiding this comment

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

Trying not to set scopes like this is because this would get parsed as a list when parsing yaml file while when we set the scopes as env var it would be parsed as a string, so don't want to check for both string and list types at run time. So I'm just using a space separated string for setting the scope, setting the env var would be like GITLAB__SCOPE='api read_repository'

@@ -40,11 +41,16 @@ def get_url_to_redirect_to(self):
redirect_info = self.redirect_info
base_url = urljoin(redirect_info["repo_service"].service_url, "oauth/authorize")
state = self.generate_state()

scope = get_config("gitlab_scopes", default="api")
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add this config it to settings base, and use it in redirect info, it's easier to tweak/follow convention here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved.

Copy link
Contributor

@RulaKhaled RulaKhaled left a comment

Choose a reason for hiding this comment

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

Looks good to me. One thing i would add is a test where we mock settings variable and make sure it's sent in the request. Not gonna let it block the PR though as i tested things locally.

@JerrySentry JerrySentry changed the title draft: gitlab scope setting gitlab oauth scope setting Jun 12, 2024
@JerrySentry JerrySentry added this pull request to the merge queue Jun 12, 2024
Merged via the queue into main with commit ff7cbca Jun 12, 2024
21 of 22 checks passed
@JerrySentry JerrySentry deleted the jun_11_gitlab branch June 12, 2024 15:37
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.

None yet

2 participants