Commit graph

64 commits

Author SHA1 Message Date
Mac Siri
cd9d5df963
Set hash_digest_class to SHA256 (#18364) 2023-07-06 17:38:56 -04:00
Mac Siri
0ea60867d4
Revert all Rack::Attack changes (#18407) 2022-08-31 18:11:56 -04:00
Mac Siri
9c0fc6b918
Use remote_ip in Rack::Attack (#18397) 2022-08-31 10:50:26 -04:00
Mac Siri
7880f46829
Remove yaml_column_permitted_classes (#18108) 2022-07-13 18:43:39 -04:00
Mac Siri
52676c3cac
Update yaml_column_permitted_classes (#18110) 2022-07-13 17:34:33 -04:00
Mac Siri
b30f016604
Update yaml_column_permitted_classes (#18106) 2022-07-13 16:26:43 -04:00
Mac Siri
66761cb89b
Update yaml_column_permitted_classes (#18101) 2022-07-13 11:55:17 -04:00
Mac Siri
1c40cd0305
Bump Rails to 7.0.3.1 (#18096)
* Bump Rails to 7.0.3.1

* Add yaml_column_permitted_classes

* Update yaml_column_permitted_classes

* Fix broken spec
2022-07-13 10:57:08 -04:00
Mac Siri
9dd52c24e1
Enable Rails 7's framework wrap_parameters_by_default & cookies_serializer (#17984) 2022-06-27 09:33:37 -04:00
Mac Siri
dc55db5708
Change Rails load_defaults to 6.1 (#17877) 2022-06-13 10:40:53 -04:00
Mac Siri
a87f70048c
Enable some Rails 6.1 framework default part2 (#17855)
* Enable form_with_generates_remote_forms and deliver_later_queue_name

* Change form_with_generates_remote_forms to true

* Move config to application.rb

* Enable urlsafe_csrf_tokens

* Update comment
2022-06-08 10:56:10 -04:00
Mac Siri
16cc9014f8
Revert "Remove IE-specific setting (#16073)" (#16719)
This reverts commit 92b1958181.
2022-02-28 11:40:09 -05:00
Jeremy Friesen
d055613676
Adjusting ArticlePolicy for admin only posting (#16614)
* Adjusting ArticlePolicy for admin only posting

The goal of this commit is actually two fold:

1) To add documentation regarding my current emerging understanding of
   our caching implementation as it relates to our authorization and
   authentication.
2) Flippiing "on" the feature's core authorization check.

Buried within this is the desired normalization of the authorization
between the `ArticlePolicy`'s `#create?`, `#preview?`, `#new?`.

My testing plan for this is to ask for SRE to spin-up a canary, then
test.  What does that look like?  I'm uncertain because this is nudge
closer towards our edge-caching strategy.  Which makes robust testing
more difficult.

Closes forem/forem#16483
Related to #16529, #16571, #16536, #16529
Informs #16490, #16606

* Update spec/requests/editor_spec.rb

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
2022-02-21 10:09:13 -05:00
Jeremy Friesen
955d9ee51a
Plumbing application for probable AuthN/Z changes (#16571)
* Plumbing application for probable AuthN/Z changes

For further details, core members can read:

- [Forem Article Authorization Discrepencies][1]
- [Forem Authentication and Authorization Principles][2]

(Note: there's nothing "private" about these articles, I happened to
post them on https://forem.team for internal discussion.)

Related to #16529

[1]:https://forem.team/jeremy/forem-article-authorization-discrepencies-45df
[2]:https://forem.team/jeremy/forem-authentication-and-authorization-principles-58l3

* Adding changes based on feedback
2022-02-16 09:10:18 -05:00
Michael Kohl
681ab3aac2
Enable use_cookies_with_metadata option (#16087) 2022-01-13 10:27:19 -05:00
Michael Kohl
813222a414
Remove explicit Zeitwerk config, require hack (#16086) 2022-01-13 20:56:47 +07:00
Michael Kohl
f471ba9bd6
Don't load ActiveJob railtie (#16074) 2022-01-12 22:29:54 +07:00
Michael Kohl
92b1958181
Remove IE-specific setting (#16073) 2022-01-12 22:16:57 +07:00
Michael Kohl
3a4fce3b88
Enable AR cache versioning (#16043) 2022-01-12 13:21:16 +07:00
Michael Kohl
6c26a8b40e
Update framework defaults (#15988)
* Update framework defaults to 6.0

* Update application.rb
2022-01-10 13:35:28 -05:00
Daniel Uber
b2203fbe0d
Load any translation files in subdirectories (#15077)
* Load any translation files in subdirectories

This ensures files in config/locales/views/ are loaded, for example.

* Move i18n load path additions from initializer to rails config
2021-10-14 11:17:07 -05:00
Ben Halpern
036d75aa6e
Admin-configurable display locale (#14620)
* Admin-configurable display locale

* Add i18n-js and namespacing

* Basic tests and clean up

* A few test adjustments

* Update vendor cache

* Fix a few tests

* Fix a few tests

* Update app/views/articles/_actions.html.erb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update app/views/articles/_comments_actions.html.erb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update app/views/articles/_single_story.html.erb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update app/views/articles/_single_story.html.erb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update app/views/comments/_comment_header.html.erb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update app/views/layouts/_sidebar_tags.html.erb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update app/views/listings/index.html.erb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update spec/system/homepage/user_visits_homepage_articles_spec.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update spec/system/user/view_user_index_spec.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Alphabetical locale page

* Add activerecord custom validation error translations

* Add i18n to webpacker

* Fix a few tests

* Adjust error messages

* Add i18n-tasks

* Adjust JS to get working with jest

* Adjust the way translations are pulled in

* Adjust jest tests

* Remove time localization

* Remove superfluous public js

* Add basic tests for i18n application controller

* Remove unnecessary content

Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-09-28 11:04:35 -04:00
rhymes
70e0e9b83a
[15 min fix] Fix some autoloading deprecation warnings (#13793)
* Fix autoloading for RateLimitChecker

* Fix autoloading for ForemStatsClient

* Fix autoloading for middlewares

* Move things to their proper place

* Move middleware usage to the proper place

* Re-add rest-client in datadog driver correctly

* Already required in config/initializers/middlewares.rb

* Bring that back

* Fix Honeybadger spec
2021-05-20 18:10:25 +02:00
rhymes
b6360fb80c
Upgrade Rails to 6.1.3.1 (#11333)
* Upgrade Rails to 6.1

* Switch to unreleased bullet

* Run rails app:update

* Add deprecation notices after reading changelogs

* Fix app:update error

* Move middleware in the correct place

* Temporarily disable ransack which does not support Rails 6.1

* Remove wrongly merged file

* Re-run spring binstub

* Fix double quotes

* Track ransack branch with Rails 6.1 support

* Fix deprecation

* Switch to Ransack 2.4 which supports Rails 6.1 rc1

* Fix missing default params for the duration substitution

* Fix new behavior of relation.pluck with contradictory queries

* Fix uploaders specs by tracking rspec-rails main repo

* Disable bullet temporarily

* Fix remaining fixture_file_upload usages

* Add default seconds for video article duration

* Trigger Travis CI

* Upgrade Rails to 6.1.0.rc2

* Remove file deleted on master

* Add Rails 6.1 gem to Gemfile

* Trigger Travis CI

* Revert "Disable bullet temporarily"

This reverts commit cee0c2ce61fb72cbc16d52c94b12ee681e873031.

* Fix bullet version

* Upgrade to acts-as-taggable 7 and fix conflict

* Update Gemfile and rspec-* gems

* Fix nokogiri in Gemfile.lock

* Switch to rspec-rails main branch

* Remove leftover vendored cached items

* Fix path for Rails 6.1

* Use latest release of erb_lint

* Re-run rails app:update to incorporate new changes

* Disable erb_lint's ErbSafety checks

* Fix Gemfile.lock and re-add platform specific gems of Nokogiri

* Add mini_portile2 as well

* Fix latest merge conflict by removing now unused faraday_middleware

* Upgrade to Rails 6.1.3.1

* Regenerate Gemfile.lock and vendor/cache

* Add x86_64 linux gem

* Mark spec as flaky

* Revert "Mark spec as flaky"

This reverts commit 3caba94b33645f9b59c84ba78ee8df042fc7aee0.

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2021-04-05 10:39:48 -04:00
Michael Kohl
09fc23fd56
Move back from after_initialize to explicit call (#11881) 2020-12-14 17:16:27 -05:00
rhymes
d8bc399a56
Restore static error pages (#11882)
* Revert "Use static error files in serviceworker (#11806)"

This reverts commit 2c96c14021.

* Revert "Use custom, dynamic, error pages (#11744)"

This reverts commit 2ab0719501.

* Remove GitHub report prompt for good, see #11718

* Bump service worker cache version
2020-12-14 12:06:41 -05:00
Michael Kohl
62c107c948
Move profile initialization to after_initialize hook (#11783)
Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2020-12-08 12:49:51 +07:00
rhymes
2ab0719501
Use custom, dynamic, error pages (#11744)
* Use ErrorsController to render error pages

* Hide GitHub bug report prompt from anything other than dev.to and forem.dev

* Update service worker to use 404 and 500

* Other fixes
2020-12-07 18:55:41 +01:00
rhymes
b90bbdd87a
[deploy] Fix URL.domain in development by correctly loading authentication providers (#10296) 2020-09-13 16:49:18 -05:00
Ben Halpern
3a469a99e2
[deploy] Enable admin-configured app_domain (#10206)
* Move app_domain from env var to siteconfig *within app area*

* Fix SiteConfig

* Don't change URL.domain yet

* Not use in fastly cache purge yet

* Session store magoo

* Revert domain issue

* Add SetCookie middleware

* Temporarily remove cookie middleware and release tasks

* Re-enable SetCookieDomain

* Add some more comments, get it ready for testing

* Remove host from url options and temporarily show errors

* Allow forwarded host to be cookie

* Fix typo

* Change invalidAuthenticityToken

* Properly set app domain

* Proper Fastly cache

* Remove config.app_domain

* Remove config.app_domain

* Explicitely set remember_user_token

* More play with cookies

* Fiddle with remember_user_token

* Add remember_user_token changes

* Monkeypatch devise

* Sessions controller

* Include rememberable

* Include rememberable

* Proper cookie monkeypatch

* Proper cookie monkeypatch

* Proper cookie monkeypatch

* Remove extra cookie code

* User sign in tweak

* Close the loop

* Experiment with carrierwave public_url

* Finalize carrierwave monkeypatch

* Remove async controller specs

* Change some tests

* Update domain test

* Remove temporary production.rb change

* modify cookie logic

* Remove unneeded changes

* Remove unneeded changes

* Explicitely pass host

* Fix linting

* Fix social image test

* Add some cookie tests

* Modify article url

* Fix canonical urls

* Fix typo

* Remove sessions controller

* Remove devise monkeypatch

* Add monkeypatch

* Remove elsif

* Update spec/helpers/application_helper_spec.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Adjust remember_cookie_sync

* Remember user token experimentation

* Fiddle with devise

* Properly configure devise

* Fix typo

* Fix formatting issue

* Add comment about middleware

* Fix typo

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* Remove commented-out code

Co-authored-by: Michael Kohl <citizen428@dev.to>
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
2020-09-11 09:38:34 -04:00
Molly Struve
0a64ac067b
[deploy] Remove ENVied Gem, Use dotenv Take 2 (#9767) 2020-08-14 12:20:47 -05:00
rhymes
e727956640
Revert "[deploy] Refactor:Remove ENVied Gem, Use dotenv Instead for Test and Development (#9621)" (#9757)
This reverts commit 1be8c72206.
2020-08-12 13:28:38 -04:00
Molly Struve
1be8c72206
[deploy] Refactor:Remove ENVied Gem, Use dotenv Instead for Test and Development (#9621)
* Refactor:Remove ENVied Gem in Favor of Default application.yml

* Copy sample_application.yml for Travis

* Create .env_sample file, Warn of missing ENV variables, ignore .env file

* Use dotenv For ENV variables and create Rake Task to Populate

* Update docs to copy .env_sample file

* make application config a bit more resilient

* update more documentation and only initialize dotenv in dev and test

* Update doc code snippet types and refactor rake task and app config

* remove push defaults

* Make initializers more resilient, remove unused ENV from travis

* Exit new rake task if application.yml does not exist, include dotenv in docs
2020-08-12 11:01:38 -04:00
rhymes
6cd64c4071
Rubocop: enable and fix Style/Send and Style/Next (#9366)
* Enable and fix Style/Send

* Enable and fix Style/Next

* Fix private cookies send

* Fix merging indentation issues
2020-07-20 16:28:00 +02:00
rhymes
36786cf554
Rails 6: enable zeitwerk autoloader (#8766)
* More loading fixes

* Go back to OpenStruct

* Shuffle things around

* Remove obsolete patches and unneeded requires

* Disable config.add_autoload_paths_to_load_path

* Fix pre-require errors

* Config not reloader
2020-06-22 16:27:55 +02:00
narender2031
e78a0078a7
[deploy] Refactor 🚀 : Replaced Chat Channel Setting page with Preact component. (#8271)
* Feature 🚀 : Ability to delete messages in chat channels

- Sending message ID to frontend
- Deleting Message
- Use pusher to delete message realtime

* Minor Bug 🐞: Show message action only for current user

- User can delete or edit their own messages

* Test cases added

* Bug 🐞: Update message id for receiver

Message id was not sent to receiver by pusher

* Refactoring🛠: Message controller refactoring

* Test Cases📝 : Specs for Delete message added

* Feature 🚀 : Ability to edit messages

* Test Cases📝 : Specs for Edit message added

* 🐞 Channel List bug in mobile view

* changes in joining request responses

* 🛠  Request Managers Frontend ready

* changes in routes for adding and removing remembership

* 🚀 New routes implemented for request manager

* fix issues

* changes in api for remove membership

* Merge conflict resolved

* 🐞 Channel List bug in mobile view

* changes in joining request responses

* 🛠  Request Managers Frontend ready

* changes in routes for adding and removing remembership

* 🚀 New routes implemented for request manager

* fix issues

* changes in api for remove membership

* 🛠Optimizing for CodeClimate

* 🛠Optimizing again for CodeClimate

* 🛠Optimizing again 2 for CodeClimate

* 🛠 Added more test cases

* 🛠 Optimizing code

* 🚀 Action to open setting page added

* 🛠  Dummy page added for chat setting

* add JSON routes for chat channel settings

* Integrate chat channel settings API with UI

* 🐞 Channel List bug in mobile view

* 🛠  Request Managers Frontend ready

* changes in routes for adding and removing remembership

* 🚀 New routes implemented for request manager

* fix issues

* 🐞 Channel List bug in mobile view

* 🛠  Request Managers Frontend ready

* changes in routes for adding and removing remembership

* 🚀 New routes implemented for request manager

* fix issues

* 🛠Optimizing again for CodeClimate

* 🚀 Action to open setting page added

* 🛠  Dummy page added for chat setting

* add JSON routes for chat channel settings

* Integrate chat channel settings API with UI

* Fix PR requested changes

* Add JSDoc documentation to exported functions

* fix/add rspec test cases

* refactor channelSettinngs render part

* add test cases for chat channel settings component

* fix code-climate

* add rest component tests

* add more test coverage

* fix code-climate bugs

* add API function test

Co-authored-by: Sarthak Sharma <7lovesharma7@gmail.com>
Co-authored-by: Parasgr-code <paras.gaur@skynox.tech>
2020-06-10 16:58:37 -04:00
Ernesto Tagwerker
9ea3a8c67d
Upgrade to Rails 6.0 (#7658)
* Add dual booting logic to Gemfile

This might be helpful for the Rails 6.0 upgrade project.

* Add more than one gemfile to Travis' configuration

We want to see how the application behaves with more than one Rails versions:

- Gemfile -> Rails 5.2
- Gemfile.next -> Rails 6.0

This will help us figure out what needs to be addressed before migrating to Rails 6.0.

If you want to read more about this technique (dual booting) you can check out this page: https://www.fastruby.io/blog/upgrade-rails/dual-boot/dual-boot-with-rails-6-0-beta.html

* Fix joins

* Upgrade Gemfile.next.lock

* Make sure we're installing the correct versions of gems

* Add Rails 6 notes

* Update rubocop in Gemfile.next.lock

* Fix organization spec

* Fix page_views_spec

* Add Rails 6 and run rails app:update

* Remove some tricks

* Remove Gemfile.next for now

* Fix .content_type deprecation

* Fix deprecation of .where.not NAND/NOR behavior

* Fix deprecation of parameterized emails

* Fix specs

* Remove next flag for now

* Fix spec (hopefully)

* Add wait_for_javascript

* Fix spec, thanks @maestromac!

* Try without wait for javascript hack

* Remove unnecessary bin/update

* Remove file that snuck in the rebase

* Update the vendored gems

* Replace migrate+db:setup with db:prepare

* Update vendored gems

* Fix Gemfile.lock and update vendored stuff

* Fix Gemfile.lock to be the same as master's minus the changes

Co-authored-by: rhymes <rhymesete@gmail.com>
2020-06-04 11:54:25 +02:00
Michael Kohl
99da2a0863
Run rails app:update for 5.2.4.2 (#6743) [deploy]
* Run rails app:update for 5.2.4.2

* Remove bin/update and disable ActiveStorage
2020-03-23 10:38:20 -04:00
rhymes
20fd8cdb92
Replace observers with callbacks and remove rails-observers (#6675)
* Add test for vomit reactions ping

* Remove reaction observer

* Add tests for new published article ping

* Remove reaction observer

* Remove comment observer

* Fix specs

* Remove rails-observer gem
2020-03-18 09:58:36 +01:00
rhymes
13ebedbc6d
Disable CORS logging by default in development (#6592)
* Disable CORS logging by default in development

* Fix typos
2020-03-11 15:30:18 -04:00
rhymes
b05d14a851
Enable CORS preflight caching (#6153) [deploy] 2020-02-18 13:37:54 -05:00
rhymes
a56eb8fab0
Enable CORS on public API endpoints (#6116) [deploy]
* Enable CORS for public API

* Add specs for Articles API

* Mention CORS in the API docs
2020-02-18 10:47:07 -05:00
Alex
2bd2800365
Update queue_adapter to Sidekiq (#6066) [deploy] 2020-02-14 11:07:49 -05:00
Alex
41d812b8a7
Revert "Update queue_adapter to Sidekiq (#5960)" (#5961) [deploy]
This reverts commit 05ce09b899.
2020-02-07 18:37:05 -05:00
Alex
05ce09b899
Update queue_adapter to Sidekiq (#5960) [deploy] 2020-02-07 14:48:19 -08:00
Keith Bennett
70e1ffbbc3 Fix rubocop Rails.root.path complaints (#5114) 2019-12-16 12:13:15 -05:00
Anna Buianova
4c9a40be41 Dispatch events to the webhook endpoints #3715 (#3872)
* Start with webhooks: table and model

* Start with webhooks api

* Start with webhooks api

* Webhook::Event class and events list

* Remove commented callbacks

* Start with sending events to webhook endpoints

* A couple of tests for Articles::Creator

* Send event to webhook endpoint on article destroy

* Dispatch event on article update

* Dispatch event when an article updated from admin

* Spec for the webhook job

* One more test for the dispatch event job

* Integration-like spec for event dispatching to webhook endpoints when creating an article

* Use Addressable::URI to parse endpoint url

* Add oj as a faster fast_jsonapi backend

* Renamed serializers

* Move article serialization out of a model

* Don't allow to create a webhook event with invalid type

* Add fields for ArticleSerializer

* Fix webhook event job specs

* Specify timeout when dispatching events

* Fix webhook job spec

* Change webhook events queue name

* Change serialized article fields for the dispatchable events

* Include user data when serializing an article for webhook event

* Moved decorating out of Webhook::DispatchEvent, fixed most specs

* Fix route in ArticleSerializer

* Move Article decoration to Webhook::PayloadAdapter

* Refactor image url helpers to avoid including helpers into serializer

* Fix specs

* Default url options for production
2019-09-07 13:17:45 -04:00
rhymes
6ea4b55658 Require only used parts of Rails (#2988)
Rails by defaults loads all its railties and engines, the current app does not use neither ActiveStorage, nor ActionCable nor TestUnit.
We can, hence, dispense of them.
2019-05-28 17:30:05 -04:00
rhymes
f17d0f34e1 Update framework defaults to match those in Rails 5.1 (#2309)
* Enable all Rails 5.0 defaults, except for CSRF mitigations

* Enable all Rails 5.1 defaults

* Enable per_form_csrf_tokens

* Enable forgery_protection_origin_check

* Avoid replacing the CSRF in the comment form

Each form now has its own CSRF in addition to the global one.
I've left in place the setInterval

* Restore per_form_csrf_tokens to false
2019-04-17 12:21:15 -04:00
Andy Zhao
3e89796d9d Add API Analytics Endpoints (#2293)
* Add API endpoints for analytics

* Remove comment and spacing

* Use proper time formatting

* Refactor and clean up some logic

* Add pro and org member traits

* Use shared examples for analytics API spec

* Add analytics authorization specs

* Remove accidental include Pundit

* Raise not_authorized for invalid requests

* Make attributes and time methods private

* Add custom UnauthorizedError

* Raise and use rescue_from to handle 4xx requests

* Enforce date parameters to follow a specific format

* Use current user to allow same origin requests

* Use custom headers and not params for token auth

* Default to current user for same origin requests

* Use correct boolean for choosing user

* Update tests to use request headers and add stricter tests
2019-04-04 10:52:45 -04:00