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 an authorization plugin #2967

Open
sonalkr132 opened this issue Feb 19, 2022 · 2 comments
Open

Add an authorization plugin #2967

sonalkr132 opened this issue Feb 19, 2022 · 2 comments
Labels

Comments

@sonalkr132
Copy link
Member

sonalkr132 commented Feb 19, 2022

Historically, ownership was the only authorization check in our code. All profile-related checks were handled with current_user. With the introduction of api_key, ownership_call and ownership_requests, we have authorization checks like following sitting awkwardly in the controller (sometimes even model).

# app/controllers/ownership_calls_controller.rb#L4
before_action :render_forbidden, unless: :owner?, only: %i[create close]

# app/controllers/ownership_requests_controller.rb
 render_forbidden && return unless current_user.can_request_ownership?(@rubygem)
 
 # app/controllers/api/v1/owners_controller.rb
 return render_api_key_forbidden unless @api_key.can_add_owner?
 
 app/models/ownership_request.rb#L24
 can_close?(user) && update(status: :closed)

It would be nicer if we moved all these checks out of the controller and let an authorization plugin like cancancan or pundit handle it.

Is your feature request related to a problem?

code health

Describe the solution you'd like

Add cancancan or pundit

@simi
Copy link
Member

simi commented Feb 29, 2024

Pundit is added now. Would it make sense to migrate those mentioned checks to Pundit @segiddins? It seems it is used used for Avo only currently.

@segiddins
Copy link
Member

Yes, i think using pundit in more places makes sense!

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

3 participants