File tree Expand file tree Collapse file tree 7 files changed +76
-1
lines changed
Expand file tree Collapse file tree 7 files changed +76
-1
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ gem "thruster", require: false
4444# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
4545# gem "image_processing", "~> 1.2"
4646
47+ # auth gems
48+ gem 'omniauth'
49+ gem 'omniauth-google-oauth2'
50+
4751group :development , :production do
4852 gem "sidekiq"
4953 gem "sidekiq-scheduler"
Original file line number Diff line number Diff line change 121121 et-orbi (1.2.11 )
122122 tzinfo
123123 event_emitter (0.2.6 )
124+ faraday (2.13.1 )
125+ faraday-net_http (>= 2.0 , < 3.5 )
126+ json
127+ logger
128+ faraday-net_http (3.4.0 )
129+ net-http (>= 0.5.0 )
124130 ffi (1.17.1-aarch64-linux-gnu )
125131 ffi (1.17.1-aarch64-linux-musl )
126132 ffi (1.17.1-arm-linux-gnu )
133139 raabro (~> 1.4 )
134140 globalid (1.2.1 )
135141 activesupport (>= 6.1 )
142+ hashie (5.0.0 )
136143 http-accept (1.7.0 )
137144 http-cookie (1.0.8 )
138145 domain_name (~> 0.5 )
151158 actionview (>= 5.0.0 )
152159 activesupport (>= 5.0.0 )
153160 json (2.10.2 )
161+ jwt (2.10.1 )
162+ base64
154163 kamal (2.6.1 )
155164 activesupport (>= 7.0 )
156165 base64 (~> 0.2 )
182191 mini_mime (1.1.5 )
183192 minitest (5.25.5 )
184193 msgpack (1.8.0 )
194+ multi_xml (0.7.2 )
195+ bigdecimal (~> 3.1 )
185196 mutex_m (0.3.0 )
197+ net-http (0.6.0 )
198+ uri
186199 net-imap (0.5.6 )
187200 date
188201 net-protocol
213226 racc (~> 1.4 )
214227 nokogiri (1.18.8-x86_64-linux-musl )
215228 racc (~> 1.4 )
229+ oauth2 (2.0.12 )
230+ faraday (>= 0.17.3 , < 4.0 )
231+ jwt (>= 1.0 , < 4.0 )
232+ logger (~> 1.2 )
233+ multi_xml (~> 0.5 )
234+ rack (>= 1.2 , < 4 )
235+ snaky_hash (~> 2.0 , >= 2.0.3 )
236+ version_gem (>= 1.1.8 , < 3 )
237+ omniauth (2.1.3 )
238+ hashie (>= 3.4.6 )
239+ rack (>= 2.2.3 )
240+ rack-protection
241+ omniauth-google-oauth2 (1.2.1 )
242+ jwt (>= 2.9.2 )
243+ oauth2 (~> 2.0 )
244+ omniauth (~> 2.0 )
245+ omniauth-oauth2 (~> 1.8 )
246+ omniauth-oauth2 (1.8.0 )
247+ oauth2 (>= 1.4 , < 3 )
248+ omniauth (~> 2.0 )
216249 opus-ruby (1.0.1 )
217250 ffi
218251 ostruct (0.6.1 )
238271 raabro (1.4.0 )
239272 racc (1.8.1 )
240273 rack (3.1.15 )
274+ rack-protection (4.1.1 )
275+ base64 (>= 0.1.0 )
276+ logger (>= 1.6.0 )
277+ rack (>= 3.0.0 , < 4 )
241278 rack-session (2.1.1 )
242279 base64 (>= 0.1.0 )
243280 rack (>= 3.0.0 )
338375 rufus-scheduler (~> 3.2 )
339376 sidekiq (>= 6 , < 8 )
340377 tilt (>= 1.4.0 , < 3 )
378+ snaky_hash (2.0.3 )
379+ hashie (>= 0.1.0 , < 6 )
380+ version_gem (>= 1.1.8 , < 3 )
341381 solid_cable (3.0.8 )
342382 actioncable (>= 7.2 )
343383 activejob (>= 7.2 )
381421 unicode-emoji (4.0.4 )
382422 uri (1.0.3 )
383423 useragent (0.16.11 )
424+ version_gem (1.1.8 )
384425 web-console (4.2.1 )
385426 actionview (>= 6.0.0 )
386427 activemodel (>= 6.0.0 )
@@ -422,6 +463,8 @@ DEPENDENCIES
422463 importmap-rails
423464 jbuilder
424465 kamal
466+ omniauth
467+ omniauth-google-oauth2
425468 pg (~> 1.5.9 )
426469 propshaft
427470 puma (>= 5.0 )
Original file line number Diff line number Diff line change 1+ class SessionsController < ApplicationController
2+ def create
3+ auth = request . env [ 'omniauth.auth' ]
4+ session [ :user_token ] = auth . credentials . token
5+ session [ :user_email ] = auth . info . email
6+ redirect_to root_path
7+ end
8+
9+ def destroy
10+ reset_session
11+ redirect_to root_path
12+ end
13+ end
Original file line number Diff line number Diff line change 1+ module SessionsHelper
2+ end
Original file line number Diff line number Diff line change 1+ Rails . application . config . middleware . use OmniAuth ::Builder do
2+ provider :google_oauth2 , ENV [ 'GOOGLE_CLIENT_ID' ] , ENV [ 'GOOGLE_CLIENT_SECRET' ]
3+ end
4+ OmniAuth . config . allowed_request_methods = %i[ get ]
Original file line number Diff line number Diff line change 55 # Can be used by load balancers and uptime monitors to verify that the app is live.
66 get "up" => "rails/health#show" , as : :rails_health_check
77
8+ get '/auth/:provider/callback' , to : 'sessions#create'
9+
810 # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb)
911 # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest
1012 # get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
1113
1214 # Defines the root path route ("/")
13- # root "posts#index "
15+ root "static#home "
1416end
Original file line number Diff line number Diff line change 1+ require "test_helper"
2+
3+ class SessionsControllerTest < ActionDispatch ::IntegrationTest
4+ # test "the truth" do
5+ # assert true
6+ # end
7+ end
You can’t perform that action at this time.
0 commit comments