Commit Graph

168 Commits

Author SHA1 Message Date
Rafael Mendonça França
cceeeb6e57
Preparing for 5.2.0.beta1 release 2017-11-27 14:50:03 -05:00
Rafael Mendonça França
fb09e05bdf
Update yarn lock 2017-11-27 12:55:20 -05:00
George Claghorn
fbb12910bd Avoid connecting to GCS during app boot 2017-11-23 19:48:25 -05:00
George Claghorn
4d5f0bb30b Fix loading ActiveStorage::DiskController when CSRF protection is disabled by default 2017-11-21 14:59:30 -05:00
George Claghorn
3fa812615a Fix that some ASt route helpers silently discarded options 2017-11-21 14:17:12 -05:00
George Claghorn
1d24e47140
Provide attachment writers
Permit creating a record and attaching files in a single step.

    # Before:
    User.create!(user_params.except(:avatar)).tap do |user|
      user.avatar.attach(user_params[:avatar])
    end

    # After:
    User.create!(user_params)

[Yoshiyuki Hirano & George Claghorn]
2017-11-20 18:06:06 -05:00
George Claghorn
ae7593e7e8 Load 5.2 defaults in ASt dummy app 2017-11-20 10:57:33 -05:00
George Claghorn
2d20a7696a Fix direct uploads to local service
Disable CSRF protection for ActiveStorage::DiskController#update. The local disk service is intended to imitate a third-party service like S3 or GCS, so we don't care where direct uploads originate: they’re authorized by signed tokens.

Closes #30290.

[Shinichi Maeshima & George Claghorn]
2017-11-20 10:54:46 -05:00
George Claghorn
e05e2ae44f Permit attaching files to new records
Closes #31164.
2017-11-19 17:34:07 -05:00
Ryuta Kamizono
1a0f85e139 Fix ASt CI failure with rack-test 0.7.1
Due to 5fd3631078.
2017-11-20 05:11:12 +09:00
George Claghorn
499a4164ce Introduce ActiveStorage::Attached::{One,Many}#detach 2017-11-14 10:42:51 -05:00
George Claghorn
704a7e425c Preserve existing metadata when analyzing a blob
Closes #31138.
2017-11-13 16:36:39 -05:00
George Claghorn
daf77db65d Remove needless block parameter 2017-11-07 09:06:23 -05:00
George Claghorn
86938c495e
Fix streaming downloads from S3/Azure Storage
Closes #31073.
2017-11-06 21:29:37 -05:00
George Claghorn
9ec6736205 Permit configuring Active Storage's job queue 2017-11-03 11:29:21 -04:00
George Claghorn
aa6bcbbac8 Allow third-party previewers/analyzers to customize their tempdirs 2017-11-02 15:07:41 -04:00
George Claghorn
f4d1aa5310 Use the indicative mood consistently [ci skip] 2017-10-22 23:14:44 -04:00
George Claghorn
398e4fecde Fix links [ci skip] 2017-10-22 13:36:37 -04:00
George Claghorn
605484079d Extract metadata from images and videos 2017-10-22 13:16:59 -04:00
Eileen M. Uchitelle
1ca6710e92 Merge pull request #30821 from GBH/active-storage-readme
ActiveStorage install note [skip ci]
2017-10-22 11:36:58 -04:00
Akira Matsuda
20c9111990 [Active Storage] require_relative => require 2017-10-21 22:48:29 +09:00
bogdanvlviv
19323d3bcc
Use require_relative instead of require with full path in activestorage/
Related to #29417
2017-10-13 21:26:57 +03:00
bogdanvlviv
f1e47b0348
Define path with __dir__ in activestorage/
Related to #29176
2017-10-13 20:47:56 +03:00
George Claghorn
29da7d1ff5 Clarify comment [ci skip] 2017-10-13 07:52:39 -04:00
George Claghorn
62ff514d33 Accept variation keys in #preview and #variant 2017-10-12 13:40:49 -04:00
George Claghorn
445c682a84 Introduce ActiveStorage::Blob#representation 2017-10-12 11:47:21 -04:00
Oleg
2ab561932e how do we install active_storage? [skip ci] 2017-10-06 12:54:23 -07:00
khall
ead60686e8 Replace variation key use with SHA256 of key to prevent long filenames
If a variant has a large set of options associated with it, the generated
filename will be too long, causing Errno::ENAMETOOLONG to be raised. This
change replaces those potentially long filenames with a much more compact
SHA256 hash. Fixes #30662.
2017-10-05 20:57:33 -07:00
Yoshiyuki Hirano
53c1618892 Fix third-party system libraries list in ActiveStorage::Preview [ci skip] 2017-10-04 03:36:21 +09:00
George Claghorn
45ed61ac47 Associate blobs with their attachments 2017-10-03 08:27:21 -05:00
Ryuta Kamizono
325c06fbc4 Fix test "signed URL generation" failure
https://travis-ci.org/rails/rails/jobs/281044755#L5582-L5586
2017-09-30 05:48:23 +09:00
Ryuta Kamizono
83b7cb3a47 Fix "warning: `*' interpreted as argument prefix" 2017-09-30 05:40:55 +09:00
George Claghorn
d30586211b Preview PDFs and videos 2017-09-28 16:43:37 -04:00
bogdanvlviv
7f3ba970b4
Set version in activestorage/package.json in proper format.
`5.2.0.alpha` => `5.2.0-alpha`

System versioning isn't compliant with npm.
2017-09-27 23:59:21 +03:00
yalab
cadf6f85f3 Fixed broken bundle exec rake install 2017-09-26 17:56:38 +09:00
George Claghorn
4e68525e33 Add missing word [ci skip] 2017-09-20 15:35:01 -04:00
George Claghorn
91edf754c4 Flesh out ActiveStorage::Filename docs 2017-09-20 15:34:04 -04:00
Eileen M. Uchitelle
e7f39af3fa Merge pull request #30629 from yhirano55/add_scope_to_has_one_attached_macro
Add `with_attached_*` scope to `has_one_attached` macro
2017-09-20 13:04:00 -04:00
Yoshiyuki Hirano
704bf9b9c6 Add with_attached_* scope to has_one_attached macro
* For avoiding N+1 problem, added `with_attached_*` scope to
  `has_one_attached` macro.
2017-09-19 06:02:00 +09:00
Yoshiyuki Hirano
0993cbe3e0 Remove unused require in ActiveStorage::Variation 2017-09-18 09:13:00 +09:00
Ryuta Kamizono
2402dd5588 Merge pull request #30628 from yhirano55/add_local_option_to_message_form
Add local option to Message form [ci skip]
2017-09-17 22:29:02 +09:00
Yoshiyuki Hirano
7d14bda3a7 Fix file missing in activestorage's example code [ci skip]
* File.open("~/face.jpg") raise error:
  `Errno::ENOENT: No such file or directory @ rb_sysopen - ~/face.jpg`
2017-09-17 21:00:23 +09:00
Yoshiyuki Hirano
194a93385b Add local option to Message form [ci skip]
* MessagesController redirects to `GET /message/:id`.
* It looks it don't expect XHR request.
* `form_with` behaves for XHR by default.
* I've added `local: true` option to `form_with`.
2017-09-17 17:44:04 +09:00
yuuji.yaginuma
3bf95f9513 Don't expose Active Storage routes
These routes are only used internally in Active Storage, and it seems
that there is no need for the user to directly use them.

Therefore, I think that routes should not be exposed to users.
2017-09-16 14:54:51 +09:00
George Claghorn
cffa32f95d Avoid making HTTP requests to generate signed URLs for GCS objects 2017-09-13 22:44:04 -04:00
_N_I_X_O_N_
c06b614c12 Fix activestorage direct upload on firefox
Direct upload on firefox is not working because it can’t handle click
events on “input[type=submit]”.
After a successful upload we can see on console a xml parse error, it
happens because AWS S3 success body response is empty, so changing the
reponseType suppress this error.
2017-09-12 18:45:23 +00:00
George Claghorn
21e690cba8 Rename activestorage/test/service/configurations.yml to activestorage/test/service/configurations.example.yml 2017-09-11 18:06:08 -04:00
David Heinemeier Hansson
69f976b859 Add credentials using a generic EncryptedConfiguration class (#30067)
* WIP: Add credentials using a generic EncryptedConfiguration class

This is sketch code so far.

* Flesh out EncryptedConfiguration and test it

* Better name

* Add command and generator for credentials

* Use the Pathnames

* Extract EncryptedFile from EncryptedConfiguration and add serializers

* Test EncryptedFile

* Extract serializer validation

* Stress the point about losing comments

* Allow encrypted configuration to be read without parsing for display

* Use credentials by default and base them on the master key

* Derive secret_key_base in test/dev, source it from credentials in other envs

And document the usage.

* Document the new credentials setup

* Stop generating the secrets.yml file now that we have credentials

* Document what we should have instead

Still need to make it happen, tho.

* [ci skip] Keep wording to `key base`; prefer defaults.

Usually we say we change defaults, not "spec" out a release.

Can't use backticks in our sdoc generated documentation either.

* Abstract away OpenSSL; prefer MessageEncryptor.

* Spare needless new when raising.

* Encrypted file test shouldn't depend on subclass.

* [ci skip] Some woordings.

* Ditch serializer future coding.

* I said flip it. Flip it good.

* [ci skip] Move require_master_key to the real production.rb.

* Add require_master_key to abort the boot process.

In case the master key is required in a certain environment
we should inspect that the key is there and abort if it isn't.

* Print missing key message and exit immediately.

Spares us a lengthy backtrace and prevents further execution.

I've verified the behavior in a test app, but couldn't figure the
test out as loading the app just exits immediately with:

```
/Users/kasperhansen/Documents/code/rails/activesupport/lib/active_support/testing/isolation.rb:23:in `load': marshal data too short (ArgumentError)
	from /Users/kasperhansen/Documents/code/rails/activesupport/lib/active_support/testing/isolation.rb:23:in `run'
	from /Users/kasperhansen/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:830:in `run_one_method'
	from /Users/kasperhansen/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest/parallel.rb:32:in `block (2 levels) in start'
```

It's likely we need to capture and prevent the exit somehow.
Kernel.stub(:exit) didn't work. Leaving it for tomorrow.

* Fix require_master_key config test.

Loading the app would trigger the `exit 1` per require_master_key's
semantics, which then aborted the test.

Fork and wait for the child process to finish, then inspect the
exit status.

Also check we aborted because of a missing master key, so something
else didn't just abort the boot.

Much <3 to @tenderlove for the tip.

* Support reading/writing configs via methods.

* Skip needless deep symbolizing.

* Remove save; test config reader elsewhere.

* Move secret_key_base check to when we're reading it.

Otherwise we'll abort too soon since we don't assign the secret_key_base
to secrets anymore.

* Add missing string literal comments; require unneeded yaml require.

* ya ya ya, rubocop.

* Add master_key/credentials after bundle.

Then we can reuse the existing message on `rails new bc4`.

It'll look like:

```
Using web-console 3.5.1 from https://github.com/rails/web-console.git (at master@ce985eb)
Using rails 5.2.0.alpha from source at `/Users/kasperhansen/Documents/code/rails`
Using sass-rails 5.0.6
Bundle complete! 16 Gemfile dependencies, 72 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Adding config/master.key to store the master encryption key: 97070158c44b4675b876373a6bc9d5a0

Save this in a password manager your team can access.

If you lose the key, no one, including you, can access anything encrypted with it.

      create  config/master.key
```

And that'll be executed even if `--skip-bundle` was passed.

* Ensure test app has secret_key_base.

* Assign secret_key_base to app or omit.

* Merge noise

* Split options for dynamic delegation into its own method and use deep symbols to make it work

* Update error to point to credentials instead

* Appease Rubocop

* Validate secret_key_base when reading it.

Instead of relying on the validation in key_generator move that into
secret_key_base itself.

* Fix generator and secrets test.

Manually add config.read_encrypted_secrets since it's not there by default
anymore.

Move mentions of config/secrets.yml to config/credentials.yml.enc.

* Remove files I have no idea how they got here.

* [ci skip] swap secrets for credentials.

* [ci skip] And now, changelogs are coming.
2017-09-11 20:21:20 +02:00
Yuji Yaginuma
83bfe07583 Use v3 of the AWS SDK 2017-09-09 23:22:10 -04:00
George Claghorn
eba7f85867 Accept GCS client options 2017-09-01 23:13:12 -04:00