Skip to content

Add load hooks to Active Storage controllers - #58452

Open
shouichi wants to merge 1 commit into
rails:mainfrom
shouichi:active-storage-controller-hooks
Open

Add load hooks to Active Storage controllers#58452
shouichi wants to merge 1 commit into
rails:mainfrom
shouichi:active-storage-controller-hooks

Conversation

@shouichi

Copy link
Copy Markdown
Contributor

Motivation / Background

Many applications need to authenticate requests to Active Storage controllers. The current guide suggests to reimplement built-in controllers just for that, which is tedious.

Detail

Add load hooks to Active Storage controllers, so applications can apply their own logic such as authentication or authorization.

ActiveSupport.on_load(:active_storage_blobs_proxy_controller) do
  include BlobAuthorization
end

Additional information

Close #34961.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Problem:

Many applications need to authenticate requests to Active Storage
controllers. The current guide suggests to reimplement built-in
controllers just for that, which is tedious.

Solution:

Add load hooks to Active Storage controllers, so applications can apply
their own logic such as authentication or authorization.

```ruby
ActiveSupport.on_load(:active_storage_blobs_proxy_controller) do
  include BlobAuthorization
end
```

Close rails#34961.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ActiveStorage: no authentication for direct uploads?

1 participant