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(admin) Add authorization provider in snuba admin #2301

Merged
merged 3 commits into from
Jan 4, 2022

Conversation

fpacifici
Copy link
Contributor

The admin relies on a proxy to perform authentication and authorization.
This is not great for two reasons:

  • it would by default allow everybody if the proxy was misconfigured while failing open (blocking everybody) would be safer.
  • it does not allow to decide which features to show depending on roles.

This adds an abstraction to performa authorization before each server request on the admin UI.
This abstraction has multiple implementations for multiple authorization providers. The default is NOOP and allows everything through. The next to be implemented is IAP, then we can add one for basic HTTP auth useful on prem.

@fpacifici fpacifici requested a review from a team December 17, 2021 01:26
@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2021

Codecov Report

Merging #2301 (af9b76e) into master (0f49805) will decrease coverage by 0.00%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2301      +/-   ##
==========================================
- Coverage   92.75%   92.74%   -0.01%     
==========================================
  Files         558      559       +1     
  Lines       25668    25694      +26     
==========================================
+ Hits        23808    23831      +23     
- Misses       1860     1863       +3     
Impacted Files Coverage Δ
snuba/admin/auth.py 88.23% <88.23%> (ø)
snuba/admin/views.py 42.18% <88.88%> (+3.02%) ⬆️
snuba/settings/__init__.py 93.75% <100.00%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f49805...af9b76e. Read the comment docs.

# TODO: provide a more structured representation of the User that
# includes the role at least.
def authorize_request() -> str:
provider_id = state.settings.ADMIN_AUTH_PROVIDER
Copy link
Member

Choose a reason for hiding this comment

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

Don't think you need to go through state module for this

Suggested change
provider_id = state.settings.ADMIN_AUTH_PROVIDER
provider_id = snuba.settings.ADMIN_AUTH_PROVIDER

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right I changed it from runtime config to settings sand forgot to fix that

Copy link
Member

@lynnagara lynnagara left a comment

Choose a reason for hiding this comment

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

Thanks, this will be useful

@fpacifici fpacifici merged commit 1a54e8a into master Jan 4, 2022
@fpacifici fpacifici deleted the feat/add_sec_assert branch January 4, 2022 22:51
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.

4 participants