Commit graph

31 commits

Author SHA1 Message Date
Kirk Haines
ed74f2f245
Abstract DatadogStatsClient to ForemStatsClient (#12304)
* This change abstracts the DatadogStatsClient into a ForemStatsClient.
The purpose of this abstraction is to set the foundation for a subsequent PR that will allow one to use New Relic for recording Forem stats, instead of Datadog, if there is a New Relic configuration found.
This specific change creates an abstraction layer that can be built upon, without changing any actual default behavior. All specs still pass.

* Use delegate instead of explicit methods.

* Delegate instead of explicit methods.

* Fix the error.

* Refactor according to the suggestions in the comments.

* Ooops.  Stats work better when all of the code is committed.

* Removing the alias of count to increment since that was done in error.
2021-01-27 11:25:44 -05:00
Fernando Valverde
fcc5c0d2a1
Add Sign in with Apple (#11934)
* Add gem omniauth-apple

* Integrate omniauth-apple

* Integrate callback

* Add fields

* Add tests, fix bugs and make it all work

* Show only enabled providers for the current user

* Add default profile image for Apple

* Remove localhost patch

* Bring over the changed Apple username if the user changes it

* More specs fixed

* Incorporate feedback from PR

* Fix specs

* Simplify code and fix spec

* Fix Broadcast generators to take into account the new provider

* Fix spec

* Generate a truly unique apple_username

* Fix user specs

* Add omniauth-apple-0.0.2 to vendor cache

* Fix merge conflict and spec

* Update VCR fastly sloan cassette

* Revert "Generate a truly unique apple_username"

This reverts commit 2462875575b0bbd6b3c1d56b25afcd3189671608.

* Fix user specs

* Fix specs

* Fix specs

* Hide Connect Apple button behind a feature flag

* Revert "Hide Connect Apple button behind a feature flag"

This reverts commit 105bde0373389a4eb9b6e948f60734c7e0e99cba.

* Fix line lengths

* Fix spec

* ES tag

* CSRF bypass for Apple callback

* custom user_nickname in Apple provider with small tweaks + omniauth-apple bump

* Fixes username specs

* Makes Apple users default image Users::ProfileImageGenerator

* Fallback to mascot_image_url in test environment to avoid breaking Travis

* Fixes Apple CSRF error + makes default nickname more readable

* Trigger Travis

* Better devise config

* Apple SiteConfig entires in /admin/config

* Fixing specs

* Adds beta_access? to Authentication::Providers::Provider

* Fixes specs

* Codeclimate double quote fix in Gemfile

* Fixes /admin/config allowed params & adds feature flag for provider beta_access?

* Remove Enfile & adds temporary docs

* Adds custom apple auth provider settings

* Fix authenticator spec

* Fix configs spec (use last instead of first to avoid apple special case)

* Remove dangling fields from /admin/config

* updates feature flag

* More test fixes

* Hide config behind feature flag too

* omniauth-apple bump

* Takes care of edge case fallback

* Reverse apple_username update

* Adds auth_time to info hash in apple omniauth mock

* Switch to next instead of nesting for feature flag

* Fixes CVE-2015-9284

* Fixes specs after auth providers initiatior refactor from GET to POST

* Spec fixes

* More spec fixes

* Fix Rails codebase reference link

Co-authored-by: rhymes <rhymesete@gmail.com>
Co-authored-by: rhymes <rhymes@hey.com>
2020-12-18 10:22:33 -06:00
rhymes
1f562783fc
Fix new Rubocop violations (#10808)
* Fix new Rubocop violations

* Use the latest minor version of 0.93
2020-10-20 09:28:53 -04:00
Mac Siri
94869bc816
[deploy] Remove all attempts to delete cookies (#10211) 2020-09-04 15:48:52 -04:00
Vaidehi Joshi
d7d29c1bb2
[deploy] Move deletion of legacy cookie higher in omniauth callback (#10190)
* Move deletion of legacy cookie higher in omniauth callback

* Add specific date to hotfix TODO note

* Fix inverted logic that looked for wrong cookie domain
2020-09-03 16:17:34 -04:00
rhymes
ffd0ce790b
[deploy] Session cookie domain hotfix for login and logout (#10169)
* Session cookie domain hotfix for login and logout

* Add timefame for removal
2020-09-03 10:45:35 -04:00
Fernando Valverde
5342602298
Social Auth generalization refactor (#9837)
* Add gem omniauth-apple

* Integrate omniauth-apple

* Integrate callback

* Add fields

* Add tests, fix bugs and make it all work

* Show only enabled providers for the current user

* Add default profile image for Apple

* Remove localhost patch

* Bring over the changed Apple username if the user changes it

* More specs fixed

* Incorporate feedback from PR

* Fix specs

* Simplify code and fix spec

* Fix Broadcast generators to take into account the new provider

* Fix spec

* Generate a truly unique apple_username

* Fix user specs

* Add omniauth-apple-0.0.2 to vendor cache

* Fix merge conflict and spec

* Update VCR fastly sloan cassette

* Revert "Generate a truly unique apple_username"

This reverts commit 2462875575b0bbd6b3c1d56b25afcd3189671608.

* Fix user specs

* Fix specs

* Fix specs

* Hide Connect Apple button behind a feature flag

* Revert "Hide Connect Apple button behind a feature flag"

This reverts commit 105bde0373389a4eb9b6e948f60734c7e0e99cba.

* Fix line lengths

* Fix spec

* ES tag

* CSRF bypass for Apple callback

* custom user_nickname in Apple provider with small tweaks + omniauth-apple bump

* Fixes username specs

* Makes Apple users default image Users::ProfileImageGenerator

* Fallback to mascot_image_url in test environment to avoid breaking Travis

* Fixes Apple CSRF error + makes default nickname more readable

* Trigger Travis

* Removes CSRF Apple fix from Omniauth callbacks

* Removes Envfile

Co-authored-by: rhymes <rhymesete@gmail.com>
Co-authored-by: rhymes <rhymes@hey.com>
2020-08-17 20:09:44 -04:00
Molly Struve
5fcb788561
[deploy] Refactor: Remove Omniauth Error Logs, Send to Honeybadger (#9205) 2020-07-08 11:21:57 -05:00
Michael Kohl
b06e9901d5
Add ApplicationRecord#errors_as_sentence (#8265)
* Add ApplicationRecord#errors_as_sentence

* Refactor existing uses

* Use errors as sentence more consistently
2020-06-04 16:02:41 +02:00
rhymes
8407bf9b4e
[deploy] Authentication refactoring: cleanups (#7576)
* Use Devise registry to list available providers

* Cleanups following Devise+Omniauth docs

* More cleanups

* Use helpers

* More cleanups

* Oops, forgot to remove these specs
2020-04-29 10:33:30 -04:00
rhymes
6d9ecb45e6
[deploy] Authentication refactoring: improve testing on OmniauthCallbacksController (#7439)
* Improve testing on OmniauthCallbacksController

* Remove removal of legacy cookie and added validation comments
2020-04-23 17:27:04 +02:00
rhymes
d6e47a03c7
[deploy] Authentication refactoring - step 1 (#7259)
* Add Authentication providers

* Making strides on refactoring

* New usr from Twitter

* Existing Twitter user

* Existing user Github

* Test skip_confirmation!

* Refactor a bit and add simplecov groups

* Test user already logged in

* Rename to Authentication::Authenticator

* Refactor to a common class

* Add existing user test for twitter login

* Refactor global handler

* Fix spec and comment Twitter provider

* Update comments and strategy TODO

* Move providers loading code to Authentication::Providers

* add SubclassResponsibility error

* Use delegation
2020-04-15 12:13:10 -04:00
rhymes
b8f2390cb5
Fix Datadog auth failure payload and add tests (#7150)
* Fix Datadog auth failure payload and add tests

* Use functional Ruby properly
2020-04-09 09:54:51 +07:00
rhymes
02b6ec5ad7
Send auth failures to Datadog (#7135) [deploy]
* Send auth failures to Honeybadger

* Fix error when it is nil

* Use Datadog instead of Honeybadger

* Fix metric name
2020-04-07 18:24:10 +02:00
Vaidehi Joshi
c7a1bd9449
Fix logging for dev and test environments (#5922)
* Fix logging for dev and test environments

We had some unused code for Timber in our config files for development and test.
However, this was completely clobbering Rails' default behavior of logging out to log/development.log and log/test.log. We should allow for logging in these environments in particular, and since we're not using Timber there, we can just revert to using the Rails default debugging log levels.

* Add Timber logger to specs that explicitly require it

* Restore default Rails.logger in specs using Timber logger

* Explicitly use Rails.logger in OmniauthCallbacksController

We seem to have different logger classes leaking into this controller in tests.
I'm not entirely sure why this is/haven't been able to investigate yet, but I do think we should be using the Rails.logger explicitly until we can figure that out.
2020-02-07 10:15:08 -05:00
Andy Zhao
b2e18aeb72 Use Redis for session storage (#4004) [deploy]
* WIP use redis-session-store for sessions

* Use Redis as session storage

* Add redis-server to Travis

* Use integer for SESSION_EXPIRY_SECONDS env variable

Co-Authored-By: rhymes <rhymesete@gmail.com>

* Remove sessions b/c no custom sessions logic

* Use ApplicationConfig instead

* Rename default value

* Remove rememberable module

* Persist the user for the test

* Remove remember_me related tests

* Revert 'undo remember_me' commits

* Add redis to procfile

* Cleanup devise configuration

* Move REDIS configuration in the basic configuration section

* Make sure the expiration time can't zero

* Restore old order and remove useless comment line

* Delete legacy session cookie after login

Once deployed the server will start using the new session cookie, this makes sure the legacy one is deleted on the user's browser

* Remove redis from Procfile

* Add signed, secure and httponly to the Redis session cookie
2019-11-12 10:10:34 -06:00
cyrillefr
4fd66372dc Enable Layout/AlignParameters (#2340)
Check if the parameters on a multi-line method call or definition are aligned.

Resolves: #2021
2019-04-08 18:47:34 -04:00
Abraham Williams
b98565a931 Update rubocop to 0.67 (#2313) [ci skip] 2019-04-05 12:55:13 -04:00
Andy Zhao
4e120b8a8e Add more logging to sign in failures (#2038)
* Actually redirect when rescuing an error

* Use inspect to view class as string

* Use a slightly more descriptive flash message
2019-03-12 16:33:10 -07:00
Andy Zhao
300291ed70 Use proper formats for env hash variables (#1624)
* Use proper formats for env hash variables

* Use .to_s instead of .name
2019-01-22 14:15:50 -05:00
Andy Zhao
2c2bafa350 Add logging if oauth fails (#1619) 2019-01-21 18:17:36 -05:00
Andy Zhao
e3f9792b21 Add logging info in case sign in fails (#1519)
* Add logging info in case sign in fails

* Use string interpolation instead

* Remove logger from auth service
2019-01-14 10:01:17 -05:00
M. Bellucci
a52af3da8b Avoid using meta-programming for solving code duplication. (#1457)
* Add feature spec for twitter login

* Avoid using class eval for solving code duplication.

This change make code easier to change in the future.

* Fix codeclimate issues

* Introduce explanatory methods
2019-01-11 12:00:09 -05:00
Andy Zhao
c3322be9ce Improve Sign In/Up Error Handling (#832)
* Add registration view to sign_in page

* Add better sad path for failed sign ins/ups

* Ensure email is downcased for authorization

* Remove .downcase for emails

* Use partial for styles
2018-10-11 13:31:37 -04:00
Ben Halpern
cf075d4a9f
Ben/fix authorization edge case (#748)
* Add top param to article tag api

* Fix user validation persistence bug
2018-09-25 18:46:17 -04:00
Mac Siri
40f488d991 Migrate to Travis CI (part 2) (#591)
* Update Travis.yml

* Update README

* Update README

* Adjust test to not rely on env vars

* Update encryption

* Refactor

* Update env key

* Stub AWS calls

* Create ApplicationConfig

* Fix specs

* Fix lint

* Update ApplicationConfig

* Remove travis env vars

* Fix lint

* Extend character limit to 100

* Add env to travis

* Take out auto-restart after deploy

* Immediately discarded test cache

* Stub GA in request specs

* Stub Pusher

* Fix broken specs

* Update fixture

* Add CodeClimate id

* Change CodeClimate key

* Remove merge mistakes

* WIP

* Add Envied gem & Change README

* Add missing keys

* Add missing key

* Update fixture

* Fix broken spec

* Add Slack Notification for Travis

* Fix wording

* Fix typo
2018-07-20 20:17:18 -04:00
Andy Zhao
9fa9a22d54 Add a comment for more public controllers (#553) 2018-07-09 18:14:34 -04:00
Ben Halpern
4d9019f8a1 Remove raise oooofffff 2018-06-12 23:19:46 -04:00
Ben Halpern
66cb24dddf Fix callback issue 2018-06-12 22:19:44 -04:00
Ben Halpern
cb4340819e Change Twitter callback_url 2018-06-12 21:40:55 -04:00
Mac Siri
301c6080e3 Initial commit 2018-02-28 16:11:08 -05:00