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

Google Authentication #2771

Merged
merged 76 commits into from
Jun 20, 2018
Merged

Google Authentication #2771

merged 76 commits into from
Jun 20, 2018

Conversation

SidharthBansal
Copy link
Member

@SidharthBansal SidharthBansal commented Jun 5, 2018

MAIN POINTS TO PONDER IN THIS PULL REQUEST FOR #2676

Facebook api is working on a test app. But they are changing their settings very often nowadays. So, firstly I am sending pr for Google. Most of the steps are common between different providers. So, once we are done with this. We will quickly have other providers.
@jywarren I will not be able to break into parts this pr. It will be a little longer pr as all code is linked heavily to each other.

This pr is in progress.

@SidharthBansal SidharthBansal self-assigned this Jun 5, 2018
@ghost ghost added the in progress label Jun 5, 2018
@plotsbot
Copy link
Collaborator

plotsbot commented Jun 5, 2018

1 Warning
⚠️ It looks like you merged from master in this pull request. Please rebase to get rid of the merge commits – you may want to rewind the master branch and rebase instead of merging in from master, which can cause problems when accepting new code!
1 Message
📖 @SidharthBansal Thank you for your pull request! I’m here to help with some tips and recommendations. Please take a look at the list provided and help us review and accept your contribution! And don’t be discouraged if you see errors – we’re here to help.

Generated by 🚫 Danger

@SidharthBansal
Copy link
Member Author

SidharthBansal commented Jun 5, 2018

Only Google login account will be made as instructions given here. https://scotch.io/tutorials/integrating-social-login-in-a-ruby-on-rails-application#creating-applications.
My app_id and app_secret on developers account is functional. But as I can't share the app_secret so @jywarren you can probably create an account there and change the app_id and app_secret once the pr is merged.

@jywarren jywarren changed the title Google Authentication Google Authentication (in progress) Jun 5, 2018
@SidharthBansal
Copy link
Member Author

SidharthBansal commented Jun 7, 2018

I am making simple text as sign up with google, login with google etc. for now. Later, I will raise a fto issue so that newcomers can add buttons and can add CSS on those buttons.
Or @jywarren if you wish I can also add CSS but as public lab wants more contributors so fto is better.
Thanks

@jywarren
Copy link
Member

jywarren commented Jun 7, 2018 via email

@ghost ghost added the in progress label Jun 8, 2018
@SidharthBansal
Copy link
Member Author

I am adding commits according to functionality completed and writing a comment so that you can check that functionality code @jywarren. Trying to make the things modular in a pr.
Thanks

@SidharthBansal
Copy link
Member Author

SidharthBansal commented Jun 9, 2018

Google api in development mode works on http and not on https.

checkpoint 1 Basic Linking and Unlinking of the different providers to the user account

  • A user who is signed in can link a google/facebook/twitter/github account with the user model via /profile/edit page
  • A user who is signed in and tries to relink same account then he/she will be notified that the account already has the provider identity.
  • A user who is signed in and tries to relink different account but of same provider then he/she will be notified that the account already has the provider identity
  • A user who is signed in and tries to delete the oauth:provider user tag can do so via profile page.
  • A user can view other user_tags of oauth:providers but cannot delete them.
  • A user who is signed in can delete the google account and can link another google account with the user model.
  • I have labelled the commit as checkpoint 1( to make a note that this much we are done with)
  • A user is able to link only a single account with a user model of a single provider. But can add multiple providers.
  • Button on the header created
  • Button on the login page created
  • Button on the profile/edit created
  • Button on the sign up created

params[:user_session].delete(:password)
params[:user_session].delete(:username)
params[:openid] = username # pack up username for second runthrough
if signed_in?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jywarren is signed in part is ready. Can you please tell if any changes?

!!current_user
end

def current_user=(user)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am having trouble here. Trying to make it work. Any help appreciated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this error is solved, it means we are done with login via a provider

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH, can you paste in the error you're having? Perhaps highlight exactly where this is done by the existing login system?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I marked it just now

@SidharthBansal SidharthBansal added the enhancement explains that the issue is to improve upon one of our existing features label Jun 9, 2018
@jywarren
Copy link
Member

jywarren commented Jun 20, 2018 via email

@jywarren
Copy link
Member

jywarren commented Jun 20, 2018 via email

@jywarren
Copy link
Member

i forgot the env variables there... adding!

@jywarren
Copy link
Member

and oops it's actually stable.publiclab.org lol

@SidharthBansal
Copy link
Member Author

You can watch it build on the Jenkins site.

can you provide me the link please?

@SidharthBansal
Copy link
Member Author

You have written staging in the app
image
Is it staging or stable?

@jywarren
Copy link
Member

it's stable. i just changed them all -- whoops!

https://stable.publiclab.org/auth/google_oauth2

@jywarren
Copy link
Member

rebuilding!

@jywarren
Copy link
Member

Hmm, stable isn't working, not sure why?

@jywarren
Copy link
Member

jywarren commented Jun 20, 2018 via email

@jywarren
Copy link
Member

Hmm, did you made changes to docker-compose-stable.yml as well?

@jywarren
Copy link
Member

yes, i see you did!

@jywarren
Copy link
Member

uh oh, i see what we merged wasn't precisely the same as this PR - i guess it wasn't squashed, but it should be the same otherwise:

https://jenkins.laboratoriopublico.org/job/Plots-Stable/changes vs
https://jenkins.laboratoriopublico.org/job/Plots-Unstable/changes

@jywarren
Copy link
Member

It works!! Is it OK that there is a value visible on the profile page?
https://stable.publiclab.org/profile/warren at the very bottom.

@SidharthBansal
Copy link
Member Author

SidharthBansal commented Jun 20, 2018

Uid can be copied and pasted to be used by another user at most for his or her application. Then if he tries to login he will be asked for password which he does not has. So this will not result in any vulnerability

@SidharthBansal
Copy link
Member Author

SidharthBansal commented Jun 20, 2018

It will be better if we will open this issue for uid and discuss this there, if needed.
Earlier when I made a PR for identity model creation you told me that uid are visible to all. Hence this will not create any vulnerability.

@jywarren
Copy link
Member

jywarren commented Jun 20, 2018 via email

@SidharthBansal
Copy link
Member Author

I think now the next and the last step is our actual website www.publiclab.org right?

@SidharthBansal
Copy link
Member Author

And then local host so that new developers can use it.

@jywarren
Copy link
Member

jywarren commented Jun 20, 2018 via email

@jywarren
Copy link
Member

We'll be publishing this in the next 10m!

@SidharthBansal
Copy link
Member Author

Great

@SidharthBansal
Copy link
Member Author

@jywarren the google api is not working on publiclab.org Can you make the changes to the main website before you publish the note? So that Soc people can review it on the main website.
Also, to the localhost.
Thanks

@jywarren
Copy link
Member

jywarren commented Jun 21, 2018 via email

@SidharthBansal
Copy link
Member Author

SidharthBansal commented Jun 21, 2018

@jywarren Last thing remaining in this --> Change the settings so that it will also work for all the developers on localhost:3000 as you indicated in #2855 (comment).
Thanks

@SidharthBansal
Copy link
Member Author

Moved to #2892

@SidharthBansal
Copy link
Member Author

git push -f https://github.com/publiclab/plots2.git HEAD:unstable

@SidharthBansal SidharthBansal added this to the OAuth Login milestone Jul 9, 2018
SrinandanPai pushed a commit to SrinandanPai/plots2 that referenced this pull request May 5, 2019
* Routes modified

* Set the views

* Modified error messages and user_tag

* Add User_Tag as identity and find user_tag

* User_sessions_controller modified

* User_tag modified

* user session controller modified

* Checkpoint 1

*  checkpoint1 codeclimate errors fixed

* Checkpoint 2

* checkpoint 2

* User is created from sign up process successfully

* create a usertag_with_omniauth

* Search a usertag for oauth

* search user_tag existing in db

* create a user with omniauth test

* LOGIN WORKS

* current_user=(user) method removed

* sign up correction

* routing tests for google oauth

* Google auth details saved

* Google should return omniauth hash test

* sign up and login via provider

* sign up and login via provider alternative flow

* flash message test added

* login user with an email and then connect google provider

* .

* Changes according to rails 5 done

* Changes according to rails 5 done

* Environment nomenclature updated

* Comments added

* Adding application.yml

* Submitting a draft  (publiclab#2747)

* Checkbox and JS function added

* publish_draft method, routes, mail_notify_stop

* coauthor can see and publish

* bower update

* undo and trying

* draft label on dashboard

* draft option not visible to first timer

* updating bower

* debug1

* removing debug statement

* button view

* view 2

* normal

* generate path added

* publish privil update

* code climate

* displaying comment with status1 only

* coauthor can view draft

* test correction

* button text change to save if draft

* fixture addition and 1 test

* tests , fixtures and minor changes

* test addition

* codeclimate 1

* codeclimate 2

* codeclimate 3

* minor fixes

* enable method=post for data-url image upload at /post (publiclab#2675)

* enable method=post for data-url image upload at /post

* Update editor_controller.rb

* Update editor_controller.rb

* Fixed first part of Issue publiclab#2352 Sorting headers added in wiki index page (publiclab#2353)

* sorting headers added in wiki index page

* replaced sorting header icon

* Improved translate widget (publiclab#2553)

* enhanced translate widget

* changed title formatting of widget

* Fix the clone command (publiclab#2766)

* List subscription change (publiclab#2767)

* Add sidekiq gem (publiclab#2738)

* added resque gem

* made changes for resqu installation

* added sidekiq gem

* minor changes

* modified docker-compose.yml for redis

* minor changes

* resolve conflicts

* Place tag detection and replacing "-" with "" (publiclab#2734)

* Place tag detection and replacing "-" with ""

* Javascript changed

* Geocode method added

* Tweaks

* Tweaks

* Tweaks

* Tweaks 2

* Tweaks 3

* Update Gemfile.lock

* Climate fix

* add geocoded tags

* Tweaks

* Block shift and callback to onComplete

* onComplete binded with ajax

* place in starting of tag detection

* Tweaks

* make descriptive tag links move to bottom of page (publiclab#2770)

* skylight config (publiclab#2773)

* Reply to comment by email feature (publiclab#2669)

* Added mailman script

* Added migration file for adding comment_via column to comment table

* Added reverse_markdown gem for converting html to markdown format

* Added migration file for adding message_id column to comment table

* Added function to handle received mail to create comment

* Added icon for comment added via email to distinguish between the normal comment and reply by email comment

* Added node_id in Mailer subjects to be used in reply by email feature

* Minor changes

* Updated schema.rb.example file

* Improved tests

* Added migrations

* Added migrations

* Added migrations

* Corrected tests

* Added enviroment variable for server address

* Added sql sphefic conditions

* Unwanted changes in schema.rb.example file is removed

* Gem added

* Log file is moved to public folder

* Corrected tests

* forward-date timestamps

* Rename 20180605190014_add_message_id_column_to_comments.rb to 20180605010014_add_message_id_column_to_comments.rb

* Update schema.rb.example

* Added whenever cron update command in Makefile for redeploy-container (publiclab#2780)

* Fix rss images and email images (publiclab#2784)

* Fix rss images and email images

* Update rss.rss.builder

* Update rss_for_tagged_with_author.rss.builder

* Update rss.rss.builder

* Update rss.rss.builder

* Update notify_node_creation.html.erb

* Rails 5.0 upgrade (publiclab#2726) (publiclab#2783)

* Rails 5.0 upgrade (publiclab#2726)

* Upgraded the .gitignore according to rails diff

* Initial Gemfile update

* Update README.md

* Showing message at the top of upgrade page (publiclab#2713)

* added an upgrade alert tag

* Additional questions page tweak (publiclab#2721)

* added the tag to determine which upgrade is listed on the website

* changed regex back

* added an upgrade alert tag

* added the tag to determine which upgrade is listed on the website

* changed regex back

* added upgrade after pull and rebase master

* Upgrade to Rails 5

* Uncommented composite_primary_key gem

* Removed the dual occurence of rails_autolink

* Update readme installation, fixes publiclab#2729 (publiclab#2730)

Updates the readme to change the installation instructions, fixes publiclab#2729

* Commented activerecord-tableless

* Draft display on Dashboard (publiclab#2666)

* draft display on dashboard

* moderator file view permitted

* checking

* fix

* test fix

* Added and modified few config files according to railsdiff.org

* Removed mass_assignment_sanitizer

* Removed composite primary key gem

* Removed all attr_accessible in all models

* Added composite_primary_key gem again

* Downgraded rails and removed few attr_accessible commands

* Added strong parameters to the controllers

* Added strong parameters gem and also include params.require inside private methods

* Added strongparameters.rb file to initializers folder

* Removed unnecessary strong_parameter functions

* Removed some errors

* Changed test command temporarily in .travis.yml

* Corrected config/puma.rb file with adding some assets

* Added all the config.precompile files in one line

* Removed error of problem in updating of user profile

* Removed the error while creating a user

* Removed error RecordNotFound: Couldn't find Node with 'nid'=

* Removed some errors related to ids

* Removed comment.reload in comment_controller_test

* Track Dockerfiles accross instances. (publiclab#2593)

* Track Dockerfiles accross instances.

* Specify jessie as base

* Add commands to build&deploy container with Makefile. (publiclab#2746)

* Added Sample Cron Job to check working of Whenever Gem (publiclab#2715)

*  Added Sample Cron Job to test Whenever Gem

* Added make targets for deployment and cron service start

* Added make to image

* Tweak Makefile

* Fix cron starting command in Makefile

* Trim whitespace

* Explicitly set jessie as base container

* Fixed codeclimate issues

* Auto-set wiki slug (publiclab#2743)

* Added keyword arguments to the tag_model.rb

* changed the query statement in search method of node.rb

* Force removal of pid file (see
docker/compose#1393)

* Updated the tests due to change in arguments of search function in node.rb

* Removed all the failures from tag_controller_test.rb

* Changed the style of params in notes_controller_test.rb

* Removed all depreciation warnings related to notes_controller

* Removed all deprecation warnings related to image_controller and answers_controller

* Removed all deprecation warnings of like_controller and fixed syntax error of answer_controller_test.rb

* Removed all dep warnings of editor_controller and syntax error of like_controller_test.rb

* removed all errors of answer_controller and some errors of tag_controller.rb

* Removed all dep warnings of tag_controller_test.rb

* Removed several dep warnings

* Removed dep warnings of wiki_controller

* Removed dep warnings of talk_controller

* Removed dep warnings of legacy_controller_test.rb

* Removed some warnings related to comment_controller

* Removed the syntax errors

* Removed two failures regarding application/xml+rss

* Removed 2 failures due to wrong way of passing parameters in tests

* Removed 2 failures

* Fix params

* Remove deprecations

* Removed some dep warnings

* Remove deprecations

* Reverted to nothing => true

* Reverted to nothing => true

* Avoid rendering more than once in the same action

* Removed all dep warnings related to user_tags_controller_test

* Remove deprecation

* Removed Dep warnings

* Fix deprecation

* Replace before_filter

* Remove deprecation

* Remove deprecation

* Remove deprecation

* Remove deprecation

* Bump Ruby version to match Travis'

* Simplify email regex to work with Ruby 2.4.1

* Changed the ruby version in Dockerfile

* Remove deprecation

* Remove deprecation

* Removed the depreciation warning related to dynamic :controller and :action segment in routes

* Changed the default ActiveRecord to ApplicationRecord in models

* Clean Gemfile

* Reverted to ['nid'] in tag_controller_test.rb

* Changed the tests to rake test:all in .travis.yml

* Minor spacing correction in .travis.yml

* added a commit in application.js an application.css regarding the precompilation of files

* Added more indentation

* Small fixes

* Separated the rails test and jasmine and coveralls task

* Modified ['nid'] to ['node']['nid']

* Removed the extra puts in Rakefile

* Changed the serial of tests

* Added rake/testtask to Rakefile

* Removed puma

* Changed to ruby 2.4.1-jessie

* Removed the whitelist_attributes command from config/application.rb

* Removed two failures due to old usage of params

* Fixed some new deprecation warnigs introduced

* fixes publiclab#2731 'add spam button,line 16 _answers.html.erb' (publiclab#2785)

* add spam button,line 16 _answers.html.erb

* changed comment.ids to answer.ids

* changed from comment path to answer

* changed comment.parent.path to answer.path

* some more cleanup to the button

* change answer.aid to answer id

* First timers recaptcha Environment Variables (publiclab#2786)

* Edited the if statement

* Added the env variables

* Edited ENV variable, and added fallback

* Fixed issue#2445 added both direction sort order (publiclab#2557)

* fixed issue#2445 added both direction sort order

* added function get_order_string in tags_controller

* Changed get to post (publiclab#2788)

* Update container definitions to match actual files used. (publiclab#2791)

* Update container definitions to match actual files used.

* Fix paths for running docker-compose.yml from subdir

* Fix reference to Dockerfile

* Reformat range stats page to table (publiclab#2792)

* Index page listing for UserTags per issue publiclab#2741. (publiclab#2753)

* Index page listing for UserTags per issue publiclab#2741.

* Changes per pull request checks.

* Removed debugging line.

* Added routes to reflect 'groups' naming convention for user_tags per pull request spec.

* Tests rewritten after rebase.

* Index page listing for UserTags per issue publiclab#2741.

* Changes per pull request checks.

* Removed debugging line.

* Added routes to reflect 'groups' naming convention for user_tags per pull request spec.

* Fix for test of sort by value.

* Update routes.rb for wiki update (publiclab#2804)

* Update routes.rb

* fixes

* integration tests for assets (publiclab#2806)

* integration tests for assets

* full assets included

* Update assets.rb

* Added routes to notes/edit (publiclab#2808)

* Added routes to notes/edit

* Removed redundant notes#edit and added get instead of post in edit actions

* Update routes.rb (publiclab#2810)

* Create OPENID.md

* fixing error in home_controller related to `group by` (publiclab#2794)

* Added group by note.nid

* correction

* Openid fix with post route and better alert texts (publiclab#2815)

* Added group by note.nid

* correction

* reworded openid requests and added post method for 2nd step

* adjust message

* Update openid_test.rb

* Update openid_test.rb

* Update openid_test.rb

* Update openid_test.rb

* Update Dangerfile (publiclab#2816)

* Update routes.rb to fix embeddable features (publiclab#2818)

* Update routes.rb

* Removed the apostrophe mismatch

* Added tests for embed in feature

* Delete route for notes (publiclab#2820)

* Documentation for the reply-by-email to comment feature (publiclab#2774)

* Added documentation for the reply-by-email to comment feature

* Added documentation for the reply-by-email to comment feature

* Added documentation for the reply-by-email to comment feature

* Added documentation for the reply-by-email to comment feature

* Re-order comment options and messages (publiclab#2834)

* Update _comment.html.erb

* Update _comment.html.erb

* encoding issue resolved for migrating DrupalUsers to User records (publiclab#2257)

* encoding issue solved

fixes publiclab#2209

* minor changes

* Rename 20180206161706_add_user_for_orphaned_drupal_user.rb to 20180614000000_add_user_for_orphaned_drupal_user.rb

* resolves issue 2520 (publiclab#2831)

* Emoji autocomplete (publiclab#2832)

* basic emoji autocomplete

* minor changes

* minor tweaks

* code climate fixes

* minor change

* changes

* remove unnecessary style

* Fix parent powertags for wikis like /barnraising (publiclab#2844)

* application.yml added

* Views removed

* Application.yml removed

* application removed

* Docker changes

* sign up page removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design issue requires more design work and discussion (i.e. mockups and sketches) enhancement explains that the issue is to improve upon one of our existing features feature explains that the issue is to add a new feature summer-of-code
Projects
None yet
Development

Successfully merging this pull request may close these issues.